Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

287 lines
7.3 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 1999-2001 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: ns.cpp
  6. * Content: Noise Suppression DMO implementation.
  7. *
  8. ***************************************************************************/
  9. #include <windows.h>
  10. #include "nsp.h"
  11. #include "kshlp.h"
  12. #include "clone.h"
  13. STD_CAPTURE_CREATE(NoiseSuppress)
  14. //////////////////////////////////////////////////////////////////////////////
  15. //
  16. // CDirectSoundCaptureNoiseSuppressDMO::NDQueryInterface
  17. //
  18. STDMETHODIMP CDirectSoundCaptureNoiseSuppressDMO::NDQueryInterface
  19. (
  20. REFIID riid,
  21. LPVOID *ppv
  22. )
  23. {
  24. IMP_DSDMO_QI(riid, ppv);
  25. if (riid == IID_IPersist)
  26. {
  27. return GetInterface((IPersist*)this, ppv);
  28. }
  29. else if (riid == IID_IMediaObject)
  30. {
  31. return GetInterface((IMediaObject*)this, ppv);
  32. }
  33. else if (riid == IID_IDirectSoundCaptureFXNoiseSuppress)
  34. {
  35. return GetInterface((IDirectSoundCaptureFXNoiseSuppress*)this, ppv);
  36. }
  37. else if (riid == IID_IMediaParams)
  38. {
  39. return GetInterface((IMediaParams*)this, ppv);
  40. }
  41. else if (riid == IID_IMediaParamInfo)
  42. {
  43. return GetInterface((IMediaParamInfo*)this, ppv);
  44. }
  45. else
  46. {
  47. return CComBase::NDQueryInterface(riid, ppv);
  48. }
  49. }
  50. //////////////////////////////////////////////////////////////////////////////
  51. //
  52. // CDirectSoundCaptureNoiseSuppressDMO constructor
  53. //
  54. CDirectSoundCaptureNoiseSuppressDMO::CDirectSoundCaptureNoiseSuppressDMO(IUnknown *pUnk, HRESULT *phr)
  55. : CComBase(pUnk, phr),
  56. m_fEnable(FALSE),
  57. m_fDirty(FALSE),
  58. m_bInitialized(FALSE)
  59. {
  60. }
  61. //////////////////////////////////////////////////////////////////////////////
  62. //
  63. // CDirectSoundCaptureNoiseSuppressDMO destructor
  64. //
  65. CDirectSoundCaptureNoiseSuppressDMO::~CDirectSoundCaptureNoiseSuppressDMO()
  66. {
  67. }
  68. const MP_CAPS g_NsCapsAll = 0;
  69. static ParamInfo g_params[] =
  70. {
  71. // index type caps min, max, neutral, unit text, label, pwchText??
  72. NSP_Enable, MPT_BOOL, g_NsCapsAll, 0, 1, 0, L"", L"", L"",
  73. };
  74. //////////////////////////////////////////////////////////////////////////////
  75. //
  76. // CDirectSoundCaptureNoiseSuppressDMO::InitOnCreation
  77. //
  78. HRESULT CDirectSoundCaptureNoiseSuppressDMO::InitOnCreation()
  79. {
  80. HRESULT hr = InitParams(1, &GUID_TIME_REFERENCE, 0, 0, sizeof g_params / sizeof *g_params, g_params);
  81. return hr;
  82. }
  83. //////////////////////////////////////////////////////////////////////////////
  84. //
  85. // CDirectSoundCaptureNoiseSuppressDMO::Init
  86. //
  87. HRESULT CDirectSoundCaptureNoiseSuppressDMO::Init()
  88. {
  89. m_bInitialized = TRUE;
  90. return S_OK;
  91. }
  92. //////////////////////////////////////////////////////////////////////////////
  93. //
  94. // CDirectSoundCaptureNoiseSuppressDMO::Clone
  95. //
  96. STDMETHODIMP CDirectSoundCaptureNoiseSuppressDMO::Clone(IMediaObjectInPlace **pp)
  97. {
  98. return StandardDMOClone<CDirectSoundCaptureNoiseSuppressDMO, DSCFXNoiseSuppress>(this, pp);
  99. }
  100. //////////////////////////////////////////////////////////////////////////////
  101. //
  102. // CDirectSoundCaptureNoiseSuppressDMO::Discontinuity
  103. //
  104. HRESULT CDirectSoundCaptureNoiseSuppressDMO::Discontinuity()
  105. {
  106. return NOERROR;
  107. }
  108. //////////////////////////////////////////////////////////////////////////////
  109. //
  110. // CDirectSoundCaptureNoiseSuppressDMO::FBRProcess
  111. //
  112. HRESULT CDirectSoundCaptureNoiseSuppressDMO::FBRProcess
  113. (
  114. DWORD cSamples,
  115. BYTE *pIn,
  116. BYTE *pOut
  117. )
  118. {
  119. if (!m_bInitialized)
  120. return DMO_E_TYPE_NOT_SET;
  121. return NOERROR;
  122. }
  123. // ==============Implementation of the private INoiseSuppress interface ==========
  124. // ==================== needed to support the property page ===============
  125. //////////////////////////////////////////////////////////////////////////////
  126. //
  127. // CDirectSoundCaptureNoiseSuppressDMO::SetAllParameters
  128. //
  129. STDMETHODIMP CDirectSoundCaptureNoiseSuppressDMO::SetAllParameters(LPCDSCFXNoiseSuppress pParm)
  130. {
  131. if (pParm == NULL)
  132. {
  133. Trace(1, "ERROR: pParm is NULL\n");
  134. return E_POINTER;
  135. }
  136. HRESULT hr = SetParam(NSP_Enable, static_cast<MP_DATA>(pParm->fEnable));
  137. if (SUCCEEDED(hr))
  138. {
  139. m_fDirty = true;
  140. }
  141. return hr;
  142. }
  143. //////////////////////////////////////////////////////////////////////////////
  144. //
  145. // CDirectSoundCaptureNoiseSuppressDMO::GetAllParameters
  146. //
  147. STDMETHODIMP CDirectSoundCaptureNoiseSuppressDMO::GetAllParameters(LPDSCFXNoiseSuppress pParm)
  148. {
  149. if (pParm == NULL)
  150. {
  151. return E_POINTER;
  152. }
  153. MP_DATA var;
  154. HRESULT hr = GetParam(NSP_Enable, &var);
  155. if (SUCCEEDED(hr))
  156. {
  157. pParm->fEnable = (BOOL)var;
  158. }
  159. return hr;
  160. }
  161. //////////////////////////////////////////////////////////////////////////////
  162. //
  163. // CDirectSoundCaptureNoiseSuppressDMO::Reset
  164. //
  165. STDMETHODIMP CDirectSoundCaptureNoiseSuppressDMO::Reset()
  166. {
  167. return KsTopologyNodeReset(m_hPin, m_ulNodeId, true);
  168. }
  169. //////////////////////////////////////////////////////////////////////////////
  170. //
  171. // CDirectSoundCaptureNoiseSuppressDMO::SetParam
  172. //
  173. STDMETHODIMP CDirectSoundCaptureNoiseSuppressDMO::SetParam
  174. (
  175. DWORD dwParamIndex,
  176. MP_DATA value,
  177. bool fSkipPasssingToParamManager
  178. )
  179. {
  180. HRESULT hr = S_OK;
  181. switch (dwParamIndex)
  182. {
  183. case NSP_Enable:
  184. if ((BOOL)value != m_fEnable)
  185. {
  186. hr = KsSetTopologyNodeEnable(m_hPin, m_ulNodeId, (BOOL)value);
  187. if (SUCCEEDED(hr)) m_fEnable = (BOOL)value;
  188. }
  189. break;
  190. }
  191. if (SUCCEEDED(hr))
  192. {
  193. Init(); // FIXME - temp hack (sets m_bInitialized flag)
  194. }
  195. // Let the base class set this so it can handle all the rest of the param calls.
  196. // Skip the base class if fSkipPasssingToParamManager. This indicates that we're
  197. // calling the function internally using values that came from the base class --
  198. // thus there's no need to tell it values it already knows.
  199. return (FAILED(hr) || fSkipPasssingToParamManager) ? hr : CParamsManager::SetParam(dwParamIndex, value);
  200. }
  201. //////////////////////////////////////////////////////////////////////////////
  202. //
  203. // CDirectSoundCaptureNoiseSuppressDMO::GetParam
  204. //
  205. STDMETHODIMP CDirectSoundCaptureNoiseSuppressDMO::GetParam
  206. (
  207. DWORD dwParamIndex,
  208. MP_DATA* value
  209. )
  210. {
  211. HRESULT hr = S_OK;
  212. BOOL fTemp;
  213. switch (dwParamIndex)
  214. {
  215. case NSP_Enable:
  216. hr = KsGetTopologyNodeEnable(m_hPin, m_ulNodeId, &fTemp);
  217. if (SUCCEEDED(hr))
  218. {
  219. m_fEnable = fTemp;
  220. *value = (MP_DATA)fTemp;
  221. }
  222. break;
  223. }
  224. return hr;
  225. }
  226. //////////////////////////////////////////////////////////////////////////////
  227. //
  228. // CDirectSoundCaptureNoiseSuppressDMO::ProcessInPlace
  229. //
  230. HRESULT CDirectSoundCaptureNoiseSuppressDMO::ProcessInPlace
  231. (
  232. ULONG ulQuanta,
  233. LPBYTE pcbData,
  234. REFERENCE_TIME rtStart,
  235. DWORD dwFlags
  236. )
  237. {
  238. // Update parameter values from any curves that may be in effect.
  239. // Do this in the same order as SetAllParameters in case there are any interdependencies.
  240. return FBRProcess(ulQuanta, pcbData, pcbData);
  241. }