Source code of Windows XP (NT5)
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.

243 lines
6.1 KiB

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