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.

124 lines
3.3 KiB

  1. #include "stdafx.h"
  2. #include "Direct.h"
  3. #include "dms.h"
  4. #include "dPlayVoiceSetupObj.h"
  5. extern void *g_dxj_DirectPlayVoiceSetup;
  6. extern BSTR GUIDtoBSTR(LPGUID pGuid);
  7. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  8. ///////////////////////////////////////////////////////////////////
  9. // InternalAddRef
  10. ///////////////////////////////////////////////////////////////////
  11. DWORD C_dxj_DirectPlayVoiceSetupObject::InternalAddRef(){
  12. DWORD i;
  13. i=CComObjectRoot::InternalAddRef();
  14. DPF2(1,"DirectPlayVoiceTest [%d] AddRef %d \n",creationid,i);
  15. return i;
  16. }
  17. ///////////////////////////////////////////////////////////////////
  18. // InternalRelease
  19. ///////////////////////////////////////////////////////////////////
  20. DWORD C_dxj_DirectPlayVoiceSetupObject::InternalRelease(){
  21. DWORD i;
  22. i=CComObjectRoot::InternalRelease();
  23. DPF2(1,"DirectPlayVoiceTest [%d] Release %d \n",creationid,i);
  24. return i;
  25. }
  26. ///////////////////////////////////////////////////////////////////
  27. // C_dxj_DirectPlayVoiceSetupObject
  28. ///////////////////////////////////////////////////////////////////
  29. C_dxj_DirectPlayVoiceSetupObject::C_dxj_DirectPlayVoiceSetupObject(){
  30. DPF1(1,"Constructor Creation DirectPlayVoiceTest Object[%d] \n ",g_creationcount);
  31. m__dxj_DirectPlayVoiceSetup = NULL;
  32. parent = NULL;
  33. pinterface = NULL;
  34. nextobj = g_dxj_DirectPlayVoiceSetup;
  35. creationid = ++g_creationcount;
  36. g_dxj_DirectPlayVoiceSetup = (void *)this;
  37. }
  38. ///////////////////////////////////////////////////////////////////
  39. // ~C_dxj_DirectPlayVoiceSetupObject
  40. ///////////////////////////////////////////////////////////////////
  41. C_dxj_DirectPlayVoiceSetupObject::~C_dxj_DirectPlayVoiceSetupObject()
  42. {
  43. DPF(1,"Entering ~C_dxj_DirectPlayVoiceSetupObject destructor \n");
  44. C_dxj_DirectPlayVoiceSetupObject *prev=NULL;
  45. for(C_dxj_DirectPlayVoiceSetupObject *ptr=(C_dxj_DirectPlayVoiceSetupObject *)g_dxj_DirectPlayVoiceSetup ; ptr; ptr=(C_dxj_DirectPlayVoiceSetupObject *)ptr->nextobj)
  46. {
  47. if(ptr == this)
  48. {
  49. if(prev)
  50. prev->nextobj = ptr->nextobj;
  51. else
  52. g_dxj_DirectPlayVoiceSetup = (void*)ptr->nextobj;
  53. DPF(1,"DirectPlayVoiceTestObject found in g_dxj list now removed\n");
  54. break;
  55. }
  56. prev = ptr;
  57. }
  58. if(m__dxj_DirectPlayVoiceSetup){
  59. int count = IUNK(m__dxj_DirectPlayVoiceSetup)->Release();
  60. #ifdef DEBUG
  61. char buffer[256];
  62. wsprintf(buffer,"DirectX IDirectPlayVoiceTest Ref count [%d] \n",count);
  63. #endif
  64. if(count==0) m__dxj_DirectPlayVoiceSetup = NULL;
  65. }
  66. if(parent) IUNK(parent)->Release();
  67. }
  68. HRESULT C_dxj_DirectPlayVoiceSetupObject::InternalGetObject(IUnknown **pUnk){
  69. *pUnk=(IUnknown*)m__dxj_DirectPlayVoiceSetup;
  70. return S_OK;
  71. }
  72. HRESULT C_dxj_DirectPlayVoiceSetupObject::InternalSetObject(IUnknown *pUnk){
  73. m__dxj_DirectPlayVoiceSetup=(LPDIRECTPLAYVOICETEST)pUnk;
  74. return S_OK;
  75. }
  76. STDMETHODIMP C_dxj_DirectPlayVoiceSetupObject::CheckAudioSetup (
  77. BSTR guidPlaybackDevice,
  78. BSTR guidCaptureDevice,
  79. #ifdef _WIN64
  80. HWND hwndOwner,
  81. #else
  82. long hwndOwner,
  83. #endif
  84. long lFlags,
  85. long *retval)
  86. {
  87. HRESULT hr;
  88. LPGUID pPlayback = NULL;
  89. LPGUID pCapture = NULL;
  90. __try {
  91. hr = BSTRtoGUID(pPlayback, guidPlaybackDevice);
  92. hr = BSTRtoGUID(pCapture, guidCaptureDevice);
  93. if ( FAILED (hr = m__dxj_DirectPlayVoiceSetup->CheckAudioSetup(pPlayback, pCapture, (HWND) hwndOwner, (DWORD) lFlags)))
  94. return hr;
  95. }
  96. __except(EXCEPTION_EXECUTE_HANDLER)
  97. {
  98. return E_FAIL;
  99. }
  100. return S_OK;
  101. }