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.

319 lines
8.0 KiB

  1. #include "stdafx.h"
  2. #include "Direct.h"
  3. #include "dms.h"
  4. #include "dMusPortObj.h"
  5. #include "dMusBufferObj.h"
  6. #include "dsoundobj.h"
  7. #include "dsoundbufferobj.h"
  8. #include "dsounddownloadedwaveobj.h"
  9. #include "dsoundsinkobj.h"
  10. extern void *g_dxj_DirectMusicPort;
  11. extern void *g_dxj_DirectSoundSink;
  12. extern void *g_dxj_DirectMusicBuffer;
  13. extern void *g_dxj_DirectSoundDownloadedWave;
  14. ///////////////////////////////////////////////////////////////////
  15. // InternalAddRef
  16. ///////////////////////////////////////////////////////////////////
  17. DWORD C_dxj_DirectMusicPortObject::InternalAddRef(){
  18. DWORD i;
  19. i=CComObjectRoot::InternalAddRef();
  20. DPF2(1,"DirectMusicPort [%d] AddRef %d \n",creationid,i);
  21. return i;
  22. }
  23. ///////////////////////////////////////////////////////////////////
  24. // InternalRelease
  25. ///////////////////////////////////////////////////////////////////
  26. DWORD C_dxj_DirectMusicPortObject::InternalRelease(){
  27. DWORD i;
  28. i=CComObjectRoot::InternalRelease();
  29. DPF2(1,"DirectMusicPort [%d] Release %d \n",creationid,i);
  30. return i;
  31. }
  32. ///////////////////////////////////////////////////////////////////
  33. // C_dxj_DirectMusicPortObject
  34. ///////////////////////////////////////////////////////////////////
  35. C_dxj_DirectMusicPortObject::C_dxj_DirectMusicPortObject(){
  36. DPF1(1,"Constructor Creation DirectMusicPort Object[%d] \n ",g_creationcount);
  37. m__dxj_DirectMusicPort = NULL;
  38. parent = NULL;
  39. pinterface = NULL;
  40. nextobj = g_dxj_DirectMusicPort;
  41. creationid = ++g_creationcount;
  42. g_dxj_DirectMusicPort = (void *)this;
  43. }
  44. ///////////////////////////////////////////////////////////////////
  45. // ~C_dxj_DirectMusicPortObject
  46. ///////////////////////////////////////////////////////////////////
  47. C_dxj_DirectMusicPortObject::~C_dxj_DirectMusicPortObject()
  48. {
  49. DPF(1,"Entering ~C_dxj_DirectMusicPortObject destructor \n");
  50. C_dxj_DirectMusicPortObject *prev=NULL;
  51. for(C_dxj_DirectMusicPortObject *ptr=(C_dxj_DirectMusicPortObject *)g_dxj_DirectMusicPort ; ptr; ptr=(C_dxj_DirectMusicPortObject *)ptr->nextobj)
  52. {
  53. if(ptr == this)
  54. {
  55. if(prev)
  56. prev->nextobj = ptr->nextobj;
  57. else
  58. g_dxj_DirectMusicPort = (void*)ptr->nextobj;
  59. DPF(1,"DirectMusicPortObject found in g_dxj list now removed\n");
  60. break;
  61. }
  62. prev = ptr;
  63. }
  64. if(m__dxj_DirectMusicPort){
  65. int count = IUNK(m__dxj_DirectMusicPort)->Release();
  66. #ifdef DEBUG
  67. char buffer[256];
  68. wsprintf(buffer,"DirectX IDirectMusicPort Ref count [%d] \n",count);
  69. #endif
  70. if(count==0) m__dxj_DirectMusicPort = NULL;
  71. }
  72. if(parent) IUNK(parent)->Release();
  73. }
  74. HRESULT C_dxj_DirectMusicPortObject::InternalGetObject(IUnknown **pUnk){
  75. *pUnk=(IUnknown*)m__dxj_DirectMusicPort;
  76. return S_OK;
  77. }
  78. HRESULT C_dxj_DirectMusicPortObject::InternalSetObject(IUnknown *pUnk){
  79. m__dxj_DirectMusicPort=(LPDIRECTMUSICPORT8)pUnk;
  80. return S_OK;
  81. }
  82. HRESULT C_dxj_DirectMusicPortObject::PlayBuffer(I_dxj_DirectMusicBuffer *Buffer)
  83. {
  84. HRESULT hr;
  85. DO_GETOBJECT_NOTNULL(LPDIRECTMUSICBUFFER, lpMusBuf, Buffer);
  86. if (FAILED(hr = m__dxj_DirectMusicPort->PlayBuffer(lpMusBuf) ) )
  87. return hr;
  88. return S_OK;
  89. }
  90. HRESULT C_dxj_DirectMusicPortObject::SetReadNotificationHandle(long hEvent)
  91. {
  92. HRESULT hr;
  93. if (FAILED(hr = m__dxj_DirectMusicPort->SetReadNotificationHandle((HANDLE) hEvent) ) )
  94. return hr;
  95. return S_OK;
  96. }
  97. HRESULT C_dxj_DirectMusicPortObject::Read(I_dxj_DirectMusicBuffer **Buffer)
  98. {
  99. HRESULT hr;
  100. LPDIRECTMUSICBUFFER lpBuf = NULL;
  101. if (FAILED(hr = m__dxj_DirectMusicPort->Read(lpBuf) ) )
  102. return hr;
  103. INTERNAL_CREATE(_dxj_DirectMusicBuffer, lpBuf, Buffer);
  104. return S_OK;
  105. }
  106. // [helpcontext(1)] HRESULT DownloadInstrument(THIS_ IDirectMusicInstrument *pInstrument,
  107. // IDirectMusicDownloadedInstrument **ppDownloadedInstrument,
  108. // DMUS_NOTERANGE *pNoteRanges,
  109. // DWORD dwNumNoteRanges);
  110. // [helpcontext(1)] HRESULT UnloadInstrument(THIS_ IDirectMusicDownloadedInstrument *pDownloadedInstrument);
  111. HRESULT C_dxj_DirectMusicPortObject::GetLatencyClock(I_dxj_ReferenceClock **Clock)
  112. {
  113. HRESULT hr;
  114. return S_OK;
  115. }
  116. HRESULT C_dxj_DirectMusicPortObject::GetRunningStats(DMUS_SYNTHSTATS_CDESC *Stats)
  117. {
  118. HRESULT hr;
  119. if (FAILED(hr = m__dxj_DirectMusicPort->GetRunningStats((DMUS_SYNTHSTATS*)Stats) ) )
  120. return hr;
  121. return S_OK;
  122. }
  123. HRESULT C_dxj_DirectMusicPortObject::Compact()
  124. {
  125. HRESULT hr;
  126. if (FAILED (hr = m__dxj_DirectMusicPort->Compact() ))
  127. return hr;
  128. return S_OK;
  129. }
  130. HRESULT C_dxj_DirectMusicPortObject::GetCaps(DMUS_PORTCAPS_CDESC *PortCaps)
  131. {
  132. HRESULT hr;
  133. if (FAILED (hr = m__dxj_DirectMusicPort->GetCaps((DMUS_PORTCAPS*)PortCaps) ))
  134. return hr;
  135. return S_OK;
  136. }
  137. HRESULT C_dxj_DirectMusicPortObject::SetNumChannelGroups(long lChannelGroups)
  138. {
  139. HRESULT hr;
  140. if (FAILED (hr = m__dxj_DirectMusicPort->SetNumChannelGroups((DWORD) lChannelGroups) ) )
  141. return hr;
  142. return S_OK;
  143. }
  144. HRESULT C_dxj_DirectMusicPortObject::GetNumChannelGroups(long *ChannelGroups)
  145. {
  146. HRESULT hr;
  147. if (FAILED (hr = m__dxj_DirectMusicPort->GetNumChannelGroups((DWORD*) ChannelGroups) ) )
  148. return hr;
  149. return S_OK;
  150. }
  151. HRESULT C_dxj_DirectMusicPortObject::Activate(VARIANT_BOOL fActive)
  152. {
  153. HRESULT hr;
  154. if (fActive == VARIANT_FALSE)
  155. {
  156. if (FAILED (hr = m__dxj_DirectMusicPort->Activate(FALSE) ) )
  157. return hr;
  158. } else
  159. {
  160. if (FAILED (hr = m__dxj_DirectMusicPort->Activate(TRUE) ) )
  161. return hr;
  162. }
  163. return S_OK;
  164. }
  165. HRESULT C_dxj_DirectMusicPortObject::SetChannelPriority(long lChannelGroup, long lChannel, long lPriority)
  166. {
  167. HRESULT hr;
  168. if (FAILED (hr = m__dxj_DirectMusicPort->SetChannelPriority((DWORD) lChannelGroup, (DWORD) lChannel, (DWORD) lPriority) ) )
  169. return hr;
  170. return S_OK;
  171. }
  172. HRESULT C_dxj_DirectMusicPortObject::GetChannelPriority(long lChannelGroup, long lChannel, long *lPriority)
  173. {
  174. HRESULT hr;
  175. if (FAILED (hr = m__dxj_DirectMusicPort->GetChannelPriority((DWORD) lChannelGroup, (DWORD) lChannel, (DWORD*) lPriority) ) )
  176. return hr;
  177. return S_OK;
  178. }
  179. HRESULT C_dxj_DirectMusicPortObject::SetDirectSound(I_dxj_DirectSound *DirectSound, I_dxj_DirectSoundBuffer *DirectSoundBuffer)
  180. {
  181. HRESULT hr;
  182. DO_GETOBJECT_NOTNULL(LPDIRECTSOUND, lpDSound, DirectSound);
  183. DO_GETOBJECT_NOTNULL(LPDIRECTSOUNDBUFFER, lpDSoundBuf, DirectSoundBuffer);
  184. if (FAILED ( hr = m__dxj_DirectMusicPort->SetDirectSound(lpDSound, lpDSoundBuf) ) )
  185. return hr;
  186. return S_OK;
  187. }
  188. HRESULT C_dxj_DirectMusicPortObject::GetFormat(WAVEFORMATEX_CDESC *WaveFormatEx)
  189. {
  190. HRESULT hr;
  191. return S_OK;
  192. }
  193. // New for DMusPort8
  194. HRESULT C_dxj_DirectMusicPortObject::DownloadWave(I_dxj_DirectSoundWave *Wave,long lFlags,I_dxj_DirectSoundDownloadedWave **retWave)
  195. {
  196. HRESULT hr;
  197. LPDIRECTSOUNDDOWNLOADEDWAVE lpDWave = NULL;
  198. DO_GETOBJECT_NOTNULL(LPDIRECTSOUNDWAVE, lpWave, Wave);
  199. if (FAILED (hr = m__dxj_DirectMusicPort->DownloadWave(lpWave, (DWORD) lFlags, &lpDWave) ) )
  200. return hr;
  201. INTERNAL_CREATE(_dxj_DirectSoundDownloadedWave, lpDWave, retWave);
  202. return S_OK;
  203. }
  204. HRESULT C_dxj_DirectMusicPortObject::UnloadWave(I_dxj_DirectSoundDownloadedWave *Wave)
  205. {
  206. HRESULT hr;
  207. DO_GETOBJECT_NOTNULL(LPDIRECTSOUNDDOWNLOADEDWAVE, lpWave, Wave);
  208. if (FAILED (hr = m__dxj_DirectMusicPort->UnloadWave(lpWave) ) )
  209. return hr;
  210. return S_OK;
  211. }
  212. HRESULT C_dxj_DirectMusicPortObject::AllocVoice(I_dxj_DirectSoundDownloadedWave *Wave,long lChannel,long lChannelGroup,long rtStart,long rtReadahead,I_dxj_DirectMusicVoice **Voice)
  213. {
  214. HRESULT hr;
  215. return S_OK;
  216. }
  217. HRESULT C_dxj_DirectMusicPortObject::AssignChannelToBuses(long lChannelGroup,long lChannel,SAFEARRAY **lBuses,long lBusCount)
  218. {
  219. HRESULT hr;
  220. return S_OK;
  221. }
  222. HRESULT C_dxj_DirectMusicPortObject::SetSink(I_dxj_DirectSoundSink *Sink)
  223. {
  224. HRESULT hr;
  225. DO_GETOBJECT_NOTNULL(LPDIRECTSOUNDSINK8, lpSink, Sink);
  226. if (FAILED (hr = m__dxj_DirectMusicPort->SetSink(lpSink) ) )
  227. return hr;
  228. return S_OK;
  229. }
  230. HRESULT C_dxj_DirectMusicPortObject::GetSink(I_dxj_DirectSoundSink **Sink)
  231. {
  232. HRESULT hr;
  233. LPDIRECTSOUNDSINK8 lpSink = NULL;
  234. if (FAILED (hr = m__dxj_DirectMusicPort->GetSink(&lpSink) ) )
  235. return hr;
  236. INTERNAL_CREATE(_dxj_DirectSoundSink, lpSink, Sink);
  237. return S_OK;
  238. }