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.

268 lines
6.4 KiB

  1. /*
  2. * DirectSound DirectMediaObject base classes
  3. *
  4. * Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  5. */
  6. #include "DsDmoBse.h"
  7. #include "debug.h"
  8. #include <devioctl.h>
  9. #include <ks.h>
  10. #include <ksmedia.h>
  11. struct KSMEDIAPARAM
  12. {
  13. KSNODEPROPERTY ksnp;
  14. ULONG ulIndex; // Instance data is index of parameter
  15. };
  16. static BOOL SyncIoctl(
  17. IN HANDLE handle,
  18. IN ULONG ulIoctl,
  19. IN PVOID pvInBuffer OPTIONAL,
  20. IN ULONG ulInSize,
  21. OUT PVOID pvOutBuffer OPTIONAL,
  22. IN ULONG ulOutSize,
  23. OUT PULONG pulBytesReturned);
  24. // XXX C1in1out calls InitializeCriticalSection in a constructor with
  25. // no handler.
  26. //
  27. //////////////////////////////////////////////////////////////////////////////
  28. //
  29. // CDirectSoundDMO::CDirectSoundDMO
  30. //
  31. CDirectSoundDMO::CDirectSoundDMO()
  32. {
  33. m_mpvCache = NULL;
  34. m_fInHardware = false;
  35. m_pKsPropertySet = NULL;
  36. }
  37. //////////////////////////////////////////////////////////////////////////////
  38. //
  39. // CDirectSoundDMO::~CDirectSoundDMO
  40. //
  41. CDirectSoundDMO::~CDirectSoundDMO()
  42. {
  43. delete[] m_mpvCache;
  44. m_mpvCache = NULL;
  45. m_fInHardware = false;
  46. RELEASE(m_pKsPropertySet);
  47. }
  48. //////////////////////////////////////////////////////////////////////////////
  49. //
  50. // CDirectSoundDMO::GetClassID
  51. //
  52. // This should always return E_NOTIMPL
  53. //
  54. STDMETHODIMP CDirectSoundDMO::GetClassID(THIS_ CLSID *pClassID)
  55. {
  56. return E_NOTIMPL;
  57. }
  58. //////////////////////////////////////////////////////////////////////////////
  59. //
  60. // CDirectSoundDMO::IsDirty
  61. //
  62. // Override if doing something other than just standard save.
  63. //
  64. STDMETHODIMP CDirectSoundDMO::IsDirty(THIS)
  65. {
  66. return E_NOTIMPL;
  67. }
  68. //////////////////////////////////////////////////////////////////////////////
  69. //
  70. // CDirectSoundDMO::Load
  71. //
  72. // Override if doing something other than just standard load.
  73. //
  74. STDMETHODIMP CDirectSoundDMO::Load(THIS_ IStream *pStm)
  75. {
  76. return E_NOTIMPL;
  77. }
  78. //////////////////////////////////////////////////////////////////////////////
  79. //
  80. // CDirectSoundDMO::Save
  81. //
  82. // Override if doing something other than just standard save.
  83. //
  84. STDMETHODIMP CDirectSoundDMO::Save(THIS_ IStream *pStm, BOOL fClearDirty)
  85. {
  86. return E_NOTIMPL;
  87. }
  88. //////////////////////////////////////////////////////////////////////////////
  89. //
  90. // CDirectSoundDMO::GetSizeMax
  91. //
  92. // Override if doing something other than just standard save.
  93. //
  94. STDMETHODIMP CDirectSoundDMO::GetSizeMax(THIS_ ULARGE_INTEGER *pcbSize)
  95. {
  96. return E_NOTIMPL;
  97. }
  98. //////////////////////////////////////////////////////////////////////////////
  99. //
  100. // CDirectSoundDMO::Process
  101. //
  102. STDMETHODIMP CDirectSoundDMO::Process(THIS_ ULONG ulSize, BYTE *pData, REFERENCE_TIME rtStart, DWORD dwFlags)
  103. {
  104. DMO_MEDIA_TYPE *pmt = InputType();
  105. if (pmt == NULL)
  106. return E_FAIL;
  107. assert(pmt->formattype == FORMAT_WaveFormatEx);
  108. ulSize /= LPWAVEFORMATEX(pmt->pbFormat)->nBlockAlign;
  109. return ProcessInPlace(ulSize, pData, rtStart, dwFlags);
  110. }
  111. //////////////////////////////////////////////////////////////////////////////
  112. //
  113. // CDirectSoundDMO::GetLatency
  114. //
  115. STDMETHODIMP CDirectSoundDMO::GetLatency(THIS_ REFERENCE_TIME *prt)
  116. {
  117. *prt = 0;
  118. return S_OK;
  119. }
  120. //////////////////////////////////////////////////////////////////////////////
  121. //
  122. // CDirectSoundDMO::AcquireResources
  123. //
  124. // Override if doing something other than just standard save.
  125. //
  126. STDMETHODIMP CDirectSoundDMO::AcquireResources(THIS_ IKsPropertySet *pKsPropertySet)
  127. {
  128. return E_NOTIMPL;
  129. }
  130. //////////////////////////////////////////////////////////////////////////////
  131. //
  132. // CDirectSoundDMO::ReleaseResources
  133. //
  134. // Override if doing something other than just standard save.
  135. //
  136. STDMETHODIMP CDirectSoundDMO::ReleaseResources(THIS_)
  137. {
  138. return E_NOTIMPL;
  139. }
  140. //////////////////////////////////////////////////////////////////////////////
  141. //
  142. // CDirectSoundDMO::InitializeNode
  143. //
  144. // Override if doing something other than just standard save.
  145. //
  146. STDMETHODIMP CDirectSoundDMO::InitializeNode(THIS_ HANDLE hPin, ULONG ulNodeId)
  147. {
  148. m_hPin = hPin;
  149. m_ulNodeId = ulNodeId;
  150. return S_OK;
  151. }
  152. #if 0
  153. // FIXME: no longer in medparam.idl
  154. //////////////////////////////////////////////////////////////////////////////
  155. //
  156. // CDirectSoundDMO::GetParams
  157. //
  158. STDMETHODIMP CDirectSoundDMO::GetParams(THIS_ DWORD dwParamIndexStart, DWORD *pdwNumParams, MP_DATA **ppValues)
  159. {
  160. HRESULT hr;
  161. if (dwParamIndexStart >= ParamCount())
  162. {
  163. // XXX Real error code
  164. //
  165. return E_FAIL;
  166. }
  167. DWORD dw;
  168. DWORD dwParamIndexEnd = dwParamIndexStart + *pdwNumParams;
  169. for (dw = dwParamIndexStart; dw < dwParamIndexEnd; dw++)
  170. {
  171. if (dw >= ParamCount())
  172. {
  173. *pdwNumParams = dw - dwParamIndexStart;
  174. return S_FALSE;
  175. }
  176. hr = GetParam(dw, ppValues[dw]);
  177. if (FAILED(hr))
  178. {
  179. *pdwNumParams = dw - dwParamIndexStart;
  180. return hr;
  181. }
  182. }
  183. return S_OK;
  184. }
  185. //////////////////////////////////////////////////////////////////////////////
  186. //
  187. // CDirectSoundDMO::SetParams
  188. //
  189. STDMETHODIMP CDirectSoundDMO::SetParams(THIS_ DWORD dwParamIndexStart, DWORD *pdwNumParams, MP_DATA __RPC_FAR *pValues)
  190. {
  191. HRESULT hr;
  192. if (dwParamIndexStart >= ParamCount())
  193. {
  194. // XXX Real error code
  195. //
  196. return E_FAIL;
  197. }
  198. DWORD dw;
  199. DWORD dwParamIndexEnd = dwParamIndexStart + *pdwNumParams;
  200. for (dw = dwParamIndexStart; dw < dwParamIndexEnd; dw++)
  201. {
  202. if (dw >= ParamCount())
  203. {
  204. *pdwNumParams = dw - dwParamIndexStart;
  205. return S_FALSE;
  206. }
  207. hr = SetParam(dw, pValues[dw]);
  208. if (FAILED(hr))
  209. {
  210. *pdwNumParams = dw - dwParamIndexStart;
  211. return hr;
  212. }
  213. }
  214. return S_OK;
  215. }
  216. #endif
  217. //////////////////////////////////////////////////////////////////////////////
  218. //
  219. // CDirectSoundDMO::ProxySetParam
  220. //
  221. HRESULT CDirectSoundDMO::ProxySetParam(DWORD dwParamIndex, MP_DATA value)
  222. {
  223. assert(m_pKsPropertySet);
  224. return m_pKsPropertySet->Set(
  225. IID_IMediaParams, 0, // Set, item
  226. &dwParamIndex, sizeof(dwParamIndex), // Instance data
  227. &value, sizeof(value)); // Property data
  228. }