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.

306 lines
10 KiB

  1. #include "stdafx.h"
  2. #include "Direct.h"
  3. #include "dms.h"
  4. #include "dMusAudioPathObj.h"
  5. #include "dsound3dbuffer.h"
  6. #include "dsoundbufferobj.h"
  7. #include "dsoundprimarybufferobj.h"
  8. #include "dsound3dlistener.h"
  9. #include "dsoundFXGargleobj.h"
  10. #include "dsoundFXEchoobj.h"
  11. #include "dsoundFXChorusobj.h"
  12. #include "dsoundFXCompressorobj.h"
  13. #include "dsoundFXDistortionobj.h"
  14. #include "dsoundFXFlangerobj.h"
  15. #include "dsoundfxi3dl2reverbobj.h"
  16. #if 0
  17. #include "dsoundfxi3dl2sourceobj.h"
  18. #include "dsoundfxsendobj.h"
  19. #endif
  20. #include "dsoundfxparameqobj.h"
  21. #include "dsoundfxwavesreverbobj.h"
  22. extern void *g_dxj_DirectSoundFXWavesReverb;
  23. extern void *g_dxj_DirectSoundFXCompressor;
  24. extern void *g_dxj_DirectSoundFXChorus;
  25. extern void *g_dxj_DirectSoundFXGargle;
  26. extern void *g_dxj_DirectSoundFXEcho;
  27. extern void *g_dxj_DirectSoundFXSend;
  28. extern void *g_dxj_DirectSoundFXDistortion;
  29. extern void *g_dxj_DirectSoundFXFlanger;
  30. extern void *g_dxj_DirectSoundFXParamEQ;
  31. extern void *g_dxj_DirectSoundFXI3DL2Reverb;
  32. #if 0
  33. extern void *g_dxj_DirectSoundFXI3DL2Source;
  34. #endif
  35. extern HRESULT AudioBSTRtoGUID(LPGUID,BSTR);
  36. extern void *g_dxj_DirectMusicAudioPath;
  37. extern void *g_dxj_DirectSoundPrimaryBuffer;
  38. ///////////////////////////////////////////////////////////////////
  39. // InternalAddRef
  40. ///////////////////////////////////////////////////////////////////
  41. DWORD C_dxj_DirectMusicAudioPathObject::InternalAddRef(){
  42. DWORD i;
  43. i=CComObjectRoot::InternalAddRef();
  44. DPF2(1,"DirectMusicAudioPath [%d] AddRef %d \n",creationid,i);
  45. return i;
  46. }
  47. ///////////////////////////////////////////////////////////////////
  48. // InternalRelease
  49. ///////////////////////////////////////////////////////////////////
  50. DWORD C_dxj_DirectMusicAudioPathObject::InternalRelease(){
  51. DWORD i;
  52. i=CComObjectRoot::InternalRelease();
  53. DPF2(1,"DirectMusicAudioPath [%d] Release %d \n",creationid,i);
  54. return i;
  55. }
  56. ///////////////////////////////////////////////////////////////////
  57. // C_dxj_DirectMusicAudioPathObject
  58. ///////////////////////////////////////////////////////////////////
  59. C_dxj_DirectMusicAudioPathObject::C_dxj_DirectMusicAudioPathObject(){
  60. DPF1(1,"Constructor Creation DirectMusicAudioPath Object[%d] \n ",g_creationcount);
  61. m__dxj_DirectMusicAudioPath = NULL;
  62. parent = NULL;
  63. pinterface = NULL;
  64. nextobj = g_dxj_DirectMusicAudioPath;
  65. creationid = ++g_creationcount;
  66. g_dxj_DirectMusicAudioPath = (void *)this;
  67. }
  68. ///////////////////////////////////////////////////////////////////
  69. // ~C_dxj_DirectMusicAudioPathObject
  70. ///////////////////////////////////////////////////////////////////
  71. C_dxj_DirectMusicAudioPathObject::~C_dxj_DirectMusicAudioPathObject()
  72. {
  73. DPF(1,"Entering ~C_dxj_DirectMusicAudioPathObject destructor \n");
  74. C_dxj_DirectMusicAudioPathObject *prev=NULL;
  75. for(C_dxj_DirectMusicAudioPathObject *ptr=(C_dxj_DirectMusicAudioPathObject *)g_dxj_DirectMusicAudioPath ; ptr; ptr=(C_dxj_DirectMusicAudioPathObject *)ptr->nextobj)
  76. {
  77. if(ptr == this)
  78. {
  79. if(prev)
  80. prev->nextobj = ptr->nextobj;
  81. else
  82. g_dxj_DirectMusicAudioPath = (void*)ptr->nextobj;
  83. DPF(1,"DirectMusicAudioPathObject found in g_dxj list now removed\n");
  84. break;
  85. }
  86. prev = ptr;
  87. }
  88. if(m__dxj_DirectMusicAudioPath){
  89. int count = IUNK(m__dxj_DirectMusicAudioPath)->Release();
  90. #ifdef DEBUG
  91. char AudioPath[256];
  92. wsprintf(AudioPath,"DirectX IDirectMusicAudioPath Ref count [%d] \n",count);
  93. #endif
  94. if(count==0) m__dxj_DirectMusicAudioPath = NULL;
  95. }
  96. if(parent) IUNK(parent)->Release();
  97. }
  98. HRESULT C_dxj_DirectMusicAudioPathObject::InternalGetObject(IUnknown **pUnk){
  99. *pUnk=(IUnknown*)m__dxj_DirectMusicAudioPath;
  100. return S_OK;
  101. }
  102. HRESULT C_dxj_DirectMusicAudioPathObject::InternalSetObject(IUnknown *pUnk){
  103. m__dxj_DirectMusicAudioPath=(IDirectMusicAudioPath8*)pUnk;
  104. return S_OK;
  105. }
  106. HRESULT C_dxj_DirectMusicAudioPathObject::GetObjectInPath(long lPChannel, long lStage, long lBuffer, BSTR guidObject, long lIndex, BSTR iidInterface, IUnknown **ppObject)
  107. {
  108. HRESULT hr;
  109. GUID guidObj;
  110. GUID guidIID;
  111. __try {
  112. if (FAILED (hr = AudioBSTRtoGUID(&guidObj, guidObject) ) )
  113. return hr;
  114. if (FAILED (hr = AudioBSTRtoGUID(&guidIID, iidInterface ) ) )
  115. return hr;
  116. if( 0==_wcsicmp(iidInterface,L"iid_idirectsound3dbuffer")){
  117. IDirectSound3DBuffer *lpRetObj = NULL;
  118. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  119. return hr;
  120. INTERNAL_CREATE(_dxj_DirectSound3dBuffer, lpRetObj, ppObject);
  121. }
  122. else if( 0==_wcsicmp(iidInterface,L"iid_idirectsoundbuffer8")){
  123. IDirectSoundBuffer8 *lpRetObj = NULL;
  124. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  125. return hr;
  126. INTERNAL_CREATE(_dxj_DirectSoundBuffer, lpRetObj, ppObject);
  127. }
  128. else if( 0==_wcsicmp(iidInterface,L"iid_idirectsoundbuffer")){
  129. IDirectSoundBuffer *lpRetObj = NULL;
  130. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  131. return hr;
  132. INTERNAL_CREATE(_dxj_DirectSoundPrimaryBuffer, lpRetObj, ppObject);
  133. }
  134. else if( 0==_wcsicmp(iidInterface,L"iid_idirectsound3dlistener")){
  135. IDirectSound3DListener *lpRetObj = NULL;
  136. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  137. return hr;
  138. INTERNAL_CREATE(_dxj_DirectSound3dListener, lpRetObj, ppObject);
  139. }
  140. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_gargle")){
  141. IDirectSoundFXGargle *lpRetObj = NULL;
  142. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  143. return hr;
  144. INTERNAL_CREATE(_dxj_DirectSoundFXGargle, lpRetObj, ppObject);
  145. }
  146. #if 0
  147. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_send")){
  148. IDirectSoundFXSend *lpRetObj = NULL;
  149. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  150. return hr;
  151. INTERNAL_CREATE(_dxj_DirectSoundFXSend, lpRetObj, ppObject);
  152. }
  153. #endif
  154. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_echo")){
  155. IDirectSoundFXEcho *lpRetObj = NULL;
  156. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  157. return hr;
  158. INTERNAL_CREATE(_dxj_DirectSoundFXEcho, lpRetObj, ppObject);
  159. }
  160. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_chorus")){
  161. IDirectSoundFXChorus *lpRetObj = NULL;
  162. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  163. return hr;
  164. INTERNAL_CREATE(_dxj_DirectSoundFXChorus, lpRetObj, ppObject);
  165. }
  166. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_compressor")){
  167. IDirectSoundFXCompressor *lpRetObj = NULL;
  168. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  169. return hr;
  170. INTERNAL_CREATE(_dxj_DirectSoundFXCompressor, lpRetObj, ppObject);
  171. }
  172. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_distortion")){
  173. IDirectSoundFXDistortion *lpRetObj = NULL;
  174. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  175. return hr;
  176. INTERNAL_CREATE(_dxj_DirectSoundFXDistortion, lpRetObj, ppObject);
  177. }
  178. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_flanger")){
  179. IDirectSoundFXFlanger *lpRetObj = NULL;
  180. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  181. return hr;
  182. INTERNAL_CREATE(_dxj_DirectSoundFXFlanger, lpRetObj, ppObject);
  183. }
  184. #if 0
  185. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_i3dl2source")){
  186. IDirectSoundFXI3DL2Source *lpRetObj = NULL;
  187. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  188. return hr;
  189. INTERNAL_CREATE(_dxj_DirectSoundFXI3DL2Source, lpRetObj, ppObject);
  190. }
  191. #endif
  192. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_i3dl2reverb")){
  193. IDirectSoundFXI3DL2Reverb *lpRetObj = NULL;
  194. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  195. return hr;
  196. INTERNAL_CREATE(_dxj_DirectSoundFXI3DL2Reverb, lpRetObj, ppObject);
  197. }
  198. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_standard_parameq")){
  199. IDirectSoundFXParamEq *lpRetObj = NULL;
  200. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  201. return hr;
  202. INTERNAL_CREATE(_dxj_DirectSoundFXParamEQ, lpRetObj, ppObject);
  203. }
  204. else if( 0==_wcsicmp(guidObject,L"guid_dsfx_waves_reverb")){
  205. IDirectSoundFXWavesReverb *lpRetObj = NULL;
  206. if (FAILED ( hr= m__dxj_DirectMusicAudioPath->GetObjectInPath((DWORD) lPChannel, (DWORD) lStage, (DWORD) lBuffer, guidObj, (DWORD) lIndex, guidIID, (void**) &lpRetObj) ) )
  207. return hr;
  208. INTERNAL_CREATE(_dxj_DirectSoundFXWavesReverb, lpRetObj, ppObject);
  209. }
  210. else
  211. return E_INVALIDARG;
  212. }
  213. __except(EXCEPTION_EXECUTE_HANDLER)
  214. {
  215. return E_FAIL;
  216. }
  217. return S_OK;
  218. }
  219. HRESULT C_dxj_DirectMusicAudioPathObject::Activate(VARIANT_BOOL fActive)
  220. {
  221. HRESULT hr;
  222. __try {
  223. if (FAILED (hr = m__dxj_DirectMusicAudioPath->Activate((BOOL) fActive) ) )
  224. return hr;
  225. }
  226. __except(EXCEPTION_EXECUTE_HANDLER)
  227. {
  228. return E_FAIL;
  229. }
  230. return S_OK;
  231. }
  232. HRESULT C_dxj_DirectMusicAudioPathObject::SetVolume(long lVolume, long lDuration)
  233. {
  234. HRESULT hr;
  235. __try {
  236. if (FAILED (hr = m__dxj_DirectMusicAudioPath->SetVolume(lVolume, (DWORD) lDuration) ) )
  237. return hr;
  238. }
  239. __except(EXCEPTION_EXECUTE_HANDLER)
  240. {
  241. return E_FAIL;
  242. }
  243. return S_OK;
  244. }