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.

224 lines
5.7 KiB

  1. #include "stdafx.h"
  2. #include "Direct.h"
  3. #include "dms.h"
  4. #include "dSoundSinkObj.h"
  5. #include "dSoundBufferObj.h"
  6. extern void *g_dxj_DirectSoundSink;
  7. extern HRESULT InternalCreateSoundBufferFromFileSink(LPDIRECTSOUNDSINK8 lpDirectSound,LPDSBUFFERDESC pDesc,WCHAR *file,LPDIRECTSOUNDBUFFER *lplpDirectSoundBuffer, DWORD dwBusID) ;
  8. ///////////////////////////////////////////////////////////////////
  9. // InternalAddRef
  10. ///////////////////////////////////////////////////////////////////
  11. DWORD C_dxj_DirectSoundSinkObject::InternalAddRef(){
  12. DWORD i;
  13. i=CComObjectRoot::InternalAddRef();
  14. DPF2(1,"DirectSoundSink [%d] AddRef %d \n",creationid,i);
  15. return i;
  16. }
  17. ///////////////////////////////////////////////////////////////////
  18. // InternalRelease
  19. ///////////////////////////////////////////////////////////////////
  20. DWORD C_dxj_DirectSoundSinkObject::InternalRelease(){
  21. DWORD i;
  22. i=CComObjectRoot::InternalRelease();
  23. DPF2(1,"DirectSoundSink [%d] Release %d \n",creationid,i);
  24. return i;
  25. }
  26. ///////////////////////////////////////////////////////////////////
  27. // C_dxj_DirectSoundSinkObject
  28. ///////////////////////////////////////////////////////////////////
  29. C_dxj_DirectSoundSinkObject::C_dxj_DirectSoundSinkObject(){
  30. DPF1(1,"Constructor Creation DirectSoundSink Object[%d] \n ",g_creationcount);
  31. m__dxj_DirectSoundSink = NULL;
  32. parent = NULL;
  33. pinterface = NULL;
  34. nextobj = g_dxj_DirectSoundSink;
  35. creationid = ++g_creationcount;
  36. g_dxj_DirectSoundSink = (void *)this;
  37. }
  38. ///////////////////////////////////////////////////////////////////
  39. // ~C_dxj_DirectSoundSinkObject
  40. ///////////////////////////////////////////////////////////////////
  41. C_dxj_DirectSoundSinkObject::~C_dxj_DirectSoundSinkObject()
  42. {
  43. DPF(1,"Entering ~C_dxj_DirectSoundSinkObject destructor \n");
  44. C_dxj_DirectSoundSinkObject *prev=NULL;
  45. for(C_dxj_DirectSoundSinkObject *ptr=(C_dxj_DirectSoundSinkObject*)g_dxj_DirectSoundSink ; ptr; ptr=(C_dxj_DirectSoundSinkObject *)ptr->nextobj)
  46. {
  47. if(ptr == this)
  48. {
  49. if(prev)
  50. prev->nextobj = ptr->nextobj;
  51. else
  52. g_dxj_DirectSoundSink = (void*)ptr->nextobj;
  53. DPF(1,"DirectSoundSink found in g_dxj list now removed\n");
  54. break;
  55. }
  56. prev = ptr;
  57. }
  58. if(m__dxj_DirectSoundSink){
  59. int count = IUNK(m__dxj_DirectSoundSink)->Release();
  60. #ifdef DEBUG
  61. char buffer[256];
  62. wsprintf(buffer,"DirectX IDirectSoundSink Ref count [%d] \n",count);
  63. #endif
  64. if(count==0) m__dxj_DirectSoundSink = NULL;
  65. }
  66. if(parent) IUNK(parent)->Release();
  67. }
  68. HRESULT C_dxj_DirectSoundSinkObject::InternalGetObject(IUnknown **pUnk){
  69. *pUnk=(IUnknown*)m__dxj_DirectSoundSink;
  70. return S_OK;
  71. }
  72. HRESULT C_dxj_DirectSoundSinkObject::InternalSetObject(IUnknown *pUnk){
  73. m__dxj_DirectSoundSink=(LPDIRECTSOUNDSINK)pUnk;
  74. return S_OK;
  75. }
  76. HRESULT C_dxj_DirectSoundSinkObject::Activate(long fEnable){
  77. HRESULT hr;
  78. if ( FAILED ( hr = m__dxj_DirectSoundSink->Activate(fEnable) ) )
  79. return hr;
  80. return S_OK;
  81. }
  82. HRESULT C_dxj_DirectSoundSinkObject::CreateSoundBuffer(DSBUFFERDESC_CDESC *BufferDesc,
  83. long lBusID, I_dxj_DirectSoundBuffer **Buffer){
  84. LPDIRECTSOUNDBUFFER dsb; // Need to get the buffer first
  85. BufferDesc->lSize = sizeof(DSBUFFERDESC);
  86. LPDSBUFFERDESC lpds ;
  87. lpds = (LPDSBUFFERDESC)&BufferDesc;
  88. HRESULT hr=S_OK;
  89. hr = m__dxj_DirectSoundSink->CreateSoundBuffer(lpds, (DWORD*)&lBusID, (DWORD)lBusID, &dsb );
  90. if SUCCEEDED(hr)
  91. INTERNAL_CREATE(_dxj_DirectSoundBuffer, dsb, Buffer );
  92. return S_OK;
  93. }
  94. HRESULT C_dxj_DirectSoundSinkObject::CreateSoundBufferFromFile(BSTR fileName,
  95. DSBUFFERDESC_CDESC *BufferDesc,
  96. long lBusID, I_dxj_DirectSoundBuffer **Buffer){
  97. LPDIRECTSOUNDBUFFER dsb;
  98. LPDSBUFFERDESC lpds ;
  99. HRESULT hr=S_OK;
  100. *Buffer=NULL;
  101. BufferDesc->lSize = sizeof(DSBUFFERDESC);
  102. lpds = (LPDSBUFFERDESC)&BufferDesc;
  103. hr=InternalCreateSoundBufferFromFileSink(m__dxj_DirectSoundSink,(LPDSBUFFERDESC)&BufferDesc,
  104. (WCHAR*)fileName,&dsb, (DWORD) lBusID);
  105. if SUCCEEDED(hr)
  106. INTERNAL_CREATE(_dxj_DirectSoundBuffer, dsb, Buffer);
  107. return S_OK;
  108. }
  109. HRESULT C_dxj_DirectSoundSinkObject::GetBusCount(long *lCount){
  110. HRESULT hr;
  111. if ( FAILED ( hr = m__dxj_DirectSoundSink->GetBusCount((DWORD*)lCount) ) )
  112. return hr;
  113. return S_OK;
  114. }
  115. HRESULT C_dxj_DirectSoundSinkObject::PlayWave(long rt,
  116. I_dxj_DirectSoundWave *Wave,
  117. long lFlags)
  118. {
  119. HRESULT hr;
  120. DO_GETOBJECT_NOTNULL( LPDIRECTSOUNDWAVE8, lpDSoundWave, Wave);
  121. if ( FAILED ( hr = m__dxj_DirectSoundSink->PlayWave((REFERENCE_TIME) rt, lpDSoundWave, (DWORD)lFlags) ) )
  122. return hr;
  123. return S_OK;
  124. }
  125. HRESULT C_dxj_DirectSoundSinkObject::GetLatencyClock(I_dxj_ReferenceClock **Clock)
  126. {
  127. return S_OK;
  128. }
  129. HRESULT C_dxj_DirectSoundSinkObject::AddSource(I_dxj_DirectSoundSource *Source)
  130. {
  131. HRESULT hr;
  132. DO_GETOBJECT_NOTNULL( LPDIRECTSOUNDSOURCE8, lpDSoundSource, Source);
  133. if (FAILED ( hr = m__dxj_DirectSoundSink->AddSource(lpDSoundSource) ) )
  134. return hr;
  135. return S_OK;
  136. }
  137. HRESULT C_dxj_DirectSoundSinkObject::RemoveSource(I_dxj_DirectSoundSource *Source)
  138. {
  139. HRESULT hr;
  140. DO_GETOBJECT_NOTNULL( LPDIRECTSOUNDSOURCE8, lpDSoundSource, Source);
  141. if (FAILED ( hr = m__dxj_DirectSoundSink->RemoveSource(lpDSoundSource) ) )
  142. return hr;
  143. return S_OK;
  144. }
  145. HRESULT C_dxj_DirectSoundSinkObject::SetMasterClock(I_dxj_ReferenceClock *MasterClock)
  146. {
  147. HRESULT hr;
  148. DO_GETOBJECT_NOTNULL( IReferenceClock*, lpRefClock, MasterClock);
  149. if (FAILED ( hr = m__dxj_DirectSoundSink->SetMasterClock(lpRefClock) ) )
  150. return hr;
  151. return S_OK;
  152. }
  153. HRESULT C_dxj_DirectSoundSinkObject::GetSoundBuffer(long lBuffer, I_dxj_DirectSoundBuffer **SoundBuffer)
  154. {
  155. return S_OK;
  156. }
  157. HRESULT C_dxj_DirectSoundSinkObject::GetBusIDs(SAFEARRAY **lBusIDs)
  158. {
  159. return S_OK;
  160. }
  161. HRESULT C_dxj_DirectSoundSinkObject::GetSoundBufferBusIDs(I_dxj_DirectSoundBuffer *buffer, SAFEARRAY **lBusIDs)
  162. {
  163. return S_OK;
  164. }