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.

190 lines
4.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1998
  6. //
  7. // File: dmussongobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "dmusici.h"
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "dmusSongObj.h"
  15. #include "dmSegmentObj.h"
  16. extern void *g_dxj_DirectMusicSong;
  17. extern void *g_dxj_DirectMusicSegment;
  18. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  19. extern BOOL IsEmptyString(BSTR szString);
  20. CONSTRUCTOR(_dxj_DirectMusicSong, {});
  21. DESTRUCTOR(_dxj_DirectMusicSong, {});
  22. GETSET_OBJECT(_dxj_DirectMusicSong);
  23. HRESULT C_dxj_DirectMusicSongObject::Compose()
  24. {
  25. HRESULT hr;
  26. __try {
  27. if (FAILED (hr = m__dxj_DirectMusicSong->Compose() ) )
  28. return hr;
  29. }
  30. __except(EXCEPTION_EXECUTE_HANDLER)
  31. {
  32. return E_FAIL;
  33. }
  34. return S_OK;
  35. }
  36. HRESULT C_dxj_DirectMusicSongObject::GetSegment(BSTR Name, I_dxj_DirectMusicSegment **ret)
  37. {
  38. WCHAR wszSegName[MAX_PATH];
  39. HRESULT hr;
  40. IDirectMusicSegment *lpOldSeg = NULL;
  41. IDirectMusicSegment8 *lpSeg = NULL;
  42. __try {
  43. if (!IsEmptyString(Name))
  44. {
  45. wcscpy(wszSegName, Name);
  46. if (FAILED( hr = m__dxj_DirectMusicSong->GetSegment(wszSegName, &lpOldSeg) ) )
  47. return hr;
  48. }
  49. else
  50. {
  51. if (FAILED( hr = m__dxj_DirectMusicSong->GetSegment(NULL, &lpOldSeg) ) )
  52. return hr;
  53. }
  54. hr = lpOldSeg->QueryInterface(IID_IDirectMusicSegment8, (void**) &lpSeg);
  55. lpOldSeg->Release();
  56. if (FAILED(hr))
  57. return hr;
  58. INTERNAL_CREATE(_dxj_DirectMusicSegment, lpSeg, ret)
  59. }
  60. __except(EXCEPTION_EXECUTE_HANDLER)
  61. {
  62. return E_FAIL;
  63. }
  64. return S_OK;
  65. }
  66. HRESULT C_dxj_DirectMusicSongObject::GetAudioPathConfig(IUnknown **ret)
  67. {
  68. HRESULT hr;
  69. __try {
  70. if (FAILED(hr = m__dxj_DirectMusicSong->GetAudioPathConfig(ret) ))
  71. return hr;
  72. }
  73. __except(EXCEPTION_EXECUTE_HANDLER)
  74. {
  75. return E_FAIL;
  76. }
  77. return S_OK;
  78. }
  79. HRESULT C_dxj_DirectMusicSongObject::Download(IUnknown *downloadpath)
  80. {
  81. if (!downloadpath) return E_INVALIDARG;
  82. HRESULT hr;
  83. I_dxj_DirectMusicSegment *lpSeg = NULL;
  84. I_dxj_DirectMusicAudioPath *lpPath = NULL;
  85. __try {
  86. hr = downloadpath->QueryInterface(IID_I_dxj_DirectMusicSegment, (void**)&lpSeg);
  87. if (SUCCEEDED(hr) )
  88. {
  89. DO_GETOBJECT_NOTNULL(IDirectMusicPerformance8*,pPer,lpSeg);
  90. hr=m__dxj_DirectMusicSong->Download(pPer);
  91. return hr;
  92. }
  93. else
  94. {
  95. hr = downloadpath->QueryInterface(IID_I_dxj_DirectMusicAudioPath, (void**)&lpPath);
  96. if (SUCCEEDED(hr) )
  97. {
  98. DO_GETOBJECT_NOTNULL(IDirectMusicAudioPath*,pPer,lpPath);
  99. hr=m__dxj_DirectMusicSong->Download(pPer);
  100. return hr;
  101. }
  102. else
  103. return E_INVALIDARG;
  104. }
  105. }
  106. __except(EXCEPTION_EXECUTE_HANDLER)
  107. {
  108. return E_FAIL;
  109. }
  110. return S_OK;
  111. }
  112. HRESULT C_dxj_DirectMusicSongObject::Unload(IUnknown *downloadpath)
  113. {
  114. if (!downloadpath) return E_INVALIDARG;
  115. HRESULT hr;
  116. I_dxj_DirectMusicSegment *lpSeg = NULL;
  117. I_dxj_DirectMusicAudioPath *lpPath = NULL;
  118. __try {
  119. hr = downloadpath->QueryInterface(IID_I_dxj_DirectMusicSegment, (void**)&lpSeg);
  120. if (SUCCEEDED(hr) )
  121. {
  122. DO_GETOBJECT_NOTNULL(IDirectMusicPerformance8*,pPer,lpSeg);
  123. hr=m__dxj_DirectMusicSong->Unload(pPer);
  124. return hr;
  125. }
  126. else
  127. {
  128. hr = downloadpath->QueryInterface(IID_I_dxj_DirectMusicAudioPath, (void**)&lpPath);
  129. if (SUCCEEDED(hr) )
  130. {
  131. DO_GETOBJECT_NOTNULL(IDirectMusicAudioPath*,pPer,lpPath);
  132. hr=m__dxj_DirectMusicSong->Unload(pPer);
  133. return hr;
  134. }
  135. else
  136. return E_INVALIDARG;
  137. }
  138. }
  139. __except(EXCEPTION_EXECUTE_HANDLER)
  140. {
  141. return E_FAIL;
  142. }
  143. return S_OK;
  144. }
  145. HRESULT C_dxj_DirectMusicSongObject::EnumSegment(long lSegmentID, [out,retval] I_dxj_DirectMusicSegment **ret)
  146. {
  147. HRESULT hr;
  148. IDirectMusicSegment *lpOldSeg = NULL;
  149. IDirectMusicSegment8 *lpSeg = NULL;
  150. __try {
  151. if (FAILED( hr = m__dxj_DirectMusicSong->EnumSegment((DWORD) lSegmentID, &lpOldSeg) ) )
  152. hr = lpOldSeg->QueryInterface(IID_IDirectMusicSegment8, (void**) &lpSeg);
  153. lpOldSeg->Release();
  154. if (FAILED(hr))
  155. return hr;
  156. INTERNAL_CREATE(_dxj_DirectMusicSegment, lpSeg, ret)
  157. }
  158. __except(EXCEPTION_EXECUTE_HANDLER)
  159. {
  160. return E_FAIL;
  161. }
  162. return S_OK;
  163. }