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.

485 lines
11 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: dmsegmentobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // dmSegmentObj.cpp
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dmusici.h"
  14. #include "dmusicc.h"
  15. #include "dmusicf.h"
  16. #include "dms.h"
  17. #include "dmSegmentObj.h"
  18. #include "dmStyleObj.h"
  19. #include "dmChordMapObj.h"
  20. extern void *g_dxj_DirectMusicSegment;
  21. extern void *g_dxj_DirectMusicStyle;
  22. extern void *g_dxj_DirectMusicChordMap;
  23. //CONSTRUCTOR(_dxj_DirectMusicSegment, {});
  24. C_dxj_DirectMusicSegmentObject::C_dxj_DirectMusicSegmentObject()
  25. {
  26. m__dxj_DirectMusicSegment = NULL;
  27. parent = NULL;
  28. pinterface = NULL;
  29. nextobj = (void*)g_dxj_DirectMusicSegment;
  30. creationid = ++g_creationcount;
  31. g_dxj_DirectMusicSegment = (void*)this;
  32. }
  33. DESTRUCTOR(_dxj_DirectMusicSegment, {});
  34. GETSET_OBJECT(_dxj_DirectMusicSegment);
  35. HRESULT C_dxj_DirectMusicSegmentObject::clone(
  36. /* [in] */ long mtStart,
  37. /* [in] */ long mtEnd,
  38. /* [retval][out] */ I_dxj_DirectMusicSegment __RPC_FAR *__RPC_FAR *ppSegment)
  39. {
  40. HRESULT hr;
  41. IDirectMusicSegment *pOut=NULL;
  42. IDirectMusicSegment8 *pReal=NULL;
  43. __try {
  44. if (FAILED (hr=m__dxj_DirectMusicSegment->Clone((MUSIC_TIME)mtStart,(MUSIC_TIME)mtEnd,&pOut) ) )
  45. return hr;
  46. if (!pOut)return E_OUTOFMEMORY;
  47. hr = pOut->QueryInterface(IID_IDirectMusicSegment8, (void**) &pReal);
  48. pOut->Release();
  49. if FAILED(hr) return hr;
  50. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicSegment,pReal,ppSegment);
  51. if (!*ppSegment)return E_OUTOFMEMORY;
  52. }
  53. __except(EXCEPTION_EXECUTE_HANDLER)
  54. {
  55. return E_FAIL;
  56. }
  57. return hr;
  58. }
  59. HRESULT C_dxj_DirectMusicSegmentObject::setStartPoint( /* [in] */ long mtStart)
  60. {
  61. HRESULT hr;
  62. __try {
  63. hr=m__dxj_DirectMusicSegment->SetStartPoint((MUSIC_TIME)mtStart);
  64. }
  65. __except(EXCEPTION_EXECUTE_HANDLER)
  66. {
  67. return E_FAIL;
  68. }
  69. return hr;
  70. }
  71. HRESULT C_dxj_DirectMusicSegmentObject::getStartPoint( /* [in] */ long *mtStart)
  72. {
  73. HRESULT hr;
  74. __try {
  75. hr=m__dxj_DirectMusicSegment->GetStartPoint((MUSIC_TIME*)mtStart);
  76. }
  77. __except(EXCEPTION_EXECUTE_HANDLER)
  78. {
  79. return E_FAIL;
  80. }
  81. return hr;
  82. }
  83. HRESULT C_dxj_DirectMusicSegmentObject::setLoopPoints( /* [in] */ long mtStart, /* [in] */ long mtEnd)
  84. {
  85. HRESULT hr;
  86. __try {
  87. hr=m__dxj_DirectMusicSegment->SetLoopPoints((MUSIC_TIME)mtStart,(MUSIC_TIME)mtEnd);
  88. }
  89. __except(EXCEPTION_EXECUTE_HANDLER)
  90. {
  91. return E_FAIL;
  92. }
  93. return hr;
  94. }
  95. HRESULT C_dxj_DirectMusicSegmentObject::getLoopPointStart( long *mtOut)
  96. {
  97. HRESULT hr;
  98. MUSIC_TIME mtStart =0;
  99. MUSIC_TIME mtEnd =0;
  100. __try {
  101. hr=m__dxj_DirectMusicSegment->GetLoopPoints((MUSIC_TIME*)&mtStart,(MUSIC_TIME*)&mtEnd);
  102. *mtOut=(long)mtStart;
  103. }
  104. __except(EXCEPTION_EXECUTE_HANDLER)
  105. {
  106. return E_FAIL;
  107. }
  108. return hr;
  109. }
  110. HRESULT C_dxj_DirectMusicSegmentObject::getLoopPointEnd( long *mtOut)
  111. {
  112. HRESULT hr;
  113. MUSIC_TIME mtStart =0;
  114. MUSIC_TIME mtEnd =0;
  115. __try {
  116. hr=m__dxj_DirectMusicSegment->GetLoopPoints((MUSIC_TIME*)&mtStart,(MUSIC_TIME*)&mtEnd);
  117. *mtOut=(long)mtEnd;
  118. }
  119. __except(EXCEPTION_EXECUTE_HANDLER)
  120. {
  121. return E_FAIL;
  122. }
  123. return hr;
  124. }
  125. HRESULT C_dxj_DirectMusicSegmentObject::setLength( /* [in] */ long mtLength)
  126. {
  127. HRESULT hr;
  128. __try {
  129. hr=m__dxj_DirectMusicSegment->SetLength((MUSIC_TIME)mtLength);
  130. }
  131. __except(EXCEPTION_EXECUTE_HANDLER)
  132. {
  133. return E_FAIL;
  134. }
  135. return hr;
  136. }
  137. HRESULT C_dxj_DirectMusicSegmentObject::getLength( /* [in] */ long *mtLength)
  138. {
  139. HRESULT hr;
  140. __try {
  141. hr=m__dxj_DirectMusicSegment->GetLength((MUSIC_TIME*)mtLength);
  142. }
  143. __except(EXCEPTION_EXECUTE_HANDLER)
  144. {
  145. return E_FAIL;
  146. }
  147. return hr;
  148. }
  149. HRESULT C_dxj_DirectMusicSegmentObject::setRepeats( /* [in] */ long lrep)
  150. {
  151. HRESULT hr;
  152. __try {
  153. hr=m__dxj_DirectMusicSegment->SetRepeats((DWORD)lrep);
  154. }
  155. __except(EXCEPTION_EXECUTE_HANDLER)
  156. {
  157. return E_FAIL;
  158. }
  159. return hr;
  160. }
  161. HRESULT C_dxj_DirectMusicSegmentObject::getRepeats( /* [in] */ long *lrep)
  162. {
  163. HRESULT hr;
  164. __try {
  165. hr=m__dxj_DirectMusicSegment->GetRepeats((DWORD*)lrep);
  166. }
  167. __except(EXCEPTION_EXECUTE_HANDLER)
  168. {
  169. return E_FAIL;
  170. }
  171. return hr;
  172. }
  173. HRESULT C_dxj_DirectMusicSegmentObject::download(
  174. /* [in] */ IUnknown __RPC_FAR *downloadpath)
  175. {
  176. if (!downloadpath) return E_INVALIDARG;
  177. HRESULT hr;
  178. __try {
  179. I_dxj_DirectMusicSegment *lpSeg = NULL;
  180. I_dxj_DirectMusicAudioPath *lpPath = NULL;
  181. hr = downloadpath->QueryInterface(IID_I_dxj_DirectMusicPerformance, (void**)&lpSeg);
  182. if (SUCCEEDED(hr) )
  183. {
  184. DO_GETOBJECT_NOTNULL(IDirectMusicPerformance8*,pPer,lpSeg);
  185. hr=m__dxj_DirectMusicSegment->Download(pPer);
  186. return hr;
  187. }
  188. else
  189. {
  190. hr = downloadpath->QueryInterface(IID_I_dxj_DirectMusicAudioPath, (void**)&lpPath);
  191. if (SUCCEEDED(hr) )
  192. {
  193. DO_GETOBJECT_NOTNULL(IDirectMusicAudioPath*,pPer,lpPath);
  194. hr=m__dxj_DirectMusicSegment->Download(pPer);
  195. return hr;
  196. }
  197. else
  198. return E_INVALIDARG;
  199. }
  200. }
  201. __except(EXCEPTION_EXECUTE_HANDLER)
  202. {
  203. return E_FAIL;
  204. }
  205. return S_OK;
  206. }
  207. HRESULT C_dxj_DirectMusicSegmentObject::unload(
  208. /* [in] */ IUnknown __RPC_FAR *downloadpath)
  209. {
  210. if (!downloadpath) return E_INVALIDARG;
  211. HRESULT hr;
  212. I_dxj_DirectMusicSegment *lpSeg = NULL;
  213. I_dxj_DirectMusicAudioPath *lpPath = NULL;
  214. __try {
  215. hr = downloadpath->QueryInterface(IID_I_dxj_DirectMusicPerformance, (void**)&lpSeg);
  216. if (SUCCEEDED(hr) )
  217. {
  218. DO_GETOBJECT_NOTNULL(IDirectMusicPerformance8*,pPer,lpSeg);
  219. hr=m__dxj_DirectMusicSegment->Unload(pPer);
  220. return hr;
  221. }
  222. else
  223. {
  224. hr = downloadpath->QueryInterface(IID_I_dxj_DirectMusicAudioPath, (void**)&lpPath);
  225. if (SUCCEEDED(hr) )
  226. {
  227. DO_GETOBJECT_NOTNULL(IDirectMusicAudioPath*,pPer,lpPath);
  228. hr=m__dxj_DirectMusicSegment->Unload(pPer);
  229. return hr;
  230. }
  231. else
  232. return E_INVALIDARG;
  233. }
  234. }
  235. __except(EXCEPTION_EXECUTE_HANDLER)
  236. {
  237. return E_FAIL;
  238. }
  239. return S_OK;
  240. }
  241. HRESULT C_dxj_DirectMusicSegmentObject::setAutoDownloadEnable(
  242. /* [retval][out] */ VARIANT_BOOL b)
  243. {
  244. HRESULT hr;
  245. __try {
  246. if (b==VARIANT_FALSE){
  247. hr=m__dxj_DirectMusicSegment->SetParam(GUID_Disable_Auto_Download,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)0,NULL);
  248. }
  249. else {
  250. hr=m__dxj_DirectMusicSegment->SetParam(GUID_Enable_Auto_Download,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)0,NULL);
  251. }
  252. }
  253. __except(EXCEPTION_EXECUTE_HANDLER)
  254. {
  255. return E_FAIL;
  256. }
  257. return hr;
  258. }
  259. HRESULT C_dxj_DirectMusicSegmentObject::setTempoEnable(
  260. /* [retval][out] */ VARIANT_BOOL b)
  261. {
  262. HRESULT hr;
  263. DWORD trackIndex=0;
  264. __try {
  265. if (b==VARIANT_FALSE){
  266. hr=m__dxj_DirectMusicSegment->SetParam(GUID_DisableTempo,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  267. }
  268. else {
  269. hr=m__dxj_DirectMusicSegment->SetParam(GUID_EnableTempo,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  270. }
  271. }
  272. __except(EXCEPTION_EXECUTE_HANDLER)
  273. {
  274. return E_FAIL;
  275. }
  276. return hr;
  277. }
  278. HRESULT C_dxj_DirectMusicSegmentObject::setTimeSigEnable(
  279. /* [retval][out] */ VARIANT_BOOL b)
  280. {
  281. HRESULT hr;
  282. DWORD trackIndex=0;
  283. __try {
  284. if (b==VARIANT_FALSE){
  285. hr=m__dxj_DirectMusicSegment->SetParam(GUID_DisableTimeSig,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  286. }
  287. else {
  288. hr=m__dxj_DirectMusicSegment->SetParam(GUID_EnableTimeSig,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  289. }
  290. }
  291. __except(EXCEPTION_EXECUTE_HANDLER)
  292. {
  293. return E_FAIL;
  294. }
  295. return hr;
  296. }
  297. HRESULT C_dxj_DirectMusicSegmentObject::setStandardMidiFile()
  298. {
  299. HRESULT hr;
  300. __try {
  301. hr=m__dxj_DirectMusicSegment->SetParam(GUID_StandardMIDIFile,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)0,NULL);
  302. }
  303. __except(EXCEPTION_EXECUTE_HANDLER)
  304. {
  305. return E_FAIL;
  306. }
  307. return hr;
  308. }
  309. HRESULT C_dxj_DirectMusicSegmentObject:: connectToCollection(
  310. /* [in] */ I_dxj_DirectMusicCollection __RPC_FAR *c)
  311. {
  312. HRESULT hr;
  313. __try {
  314. DO_GETOBJECT_NOTNULL(IDirectMusicCollection8*,pCol,c);
  315. hr=m__dxj_DirectMusicSegment->SetParam(GUID_ConnectToDLSCollection,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)0,(void*)pCol);
  316. }
  317. __except(EXCEPTION_EXECUTE_HANDLER)
  318. {
  319. return E_FAIL;
  320. }
  321. return hr;
  322. }
  323. HRESULT C_dxj_DirectMusicSegmentObject:: GetAudioPathConfig(IUnknown **ret)
  324. {
  325. HRESULT hr;
  326. __try {
  327. if (FAILED(hr = m__dxj_DirectMusicSegment->GetAudioPathConfig(ret) ))
  328. return hr;
  329. }
  330. __except(EXCEPTION_EXECUTE_HANDLER)
  331. {
  332. return E_FAIL;
  333. }
  334. return S_OK;
  335. }
  336. HRESULT C_dxj_DirectMusicSegmentObject::getStyle(
  337. /* [in] */ long lTrack,
  338. /* [retval][out] */ I_dxj_DirectMusicStyle __RPC_FAR *__RPC_FAR *ret)
  339. {
  340. HRESULT hr;
  341. IDirectMusicStyle *pStyle=NULL;
  342. __try {
  343. if (!ret) return E_INVALIDARG;
  344. *ret=NULL;
  345. hr=m__dxj_DirectMusicSegment->GetParam( GUID_IDirectMusicStyle, 0xffffffff, (DWORD)lTrack,
  346. 0, NULL, (VOID*)&pStyle );
  347. if FAILED(hr) return hr;
  348. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicStyle,pStyle,ret);
  349. if (*ret==NULL) return E_OUTOFMEMORY;
  350. }
  351. __except(EXCEPTION_EXECUTE_HANDLER)
  352. {
  353. return E_FAIL;
  354. }
  355. return hr;
  356. }
  357. HRESULT C_dxj_DirectMusicSegmentObject::getChordMap(
  358. /* [in] */ long lTrack,
  359. /* [in] */ long mtTime,
  360. /* [in] */ long *mtUntil,
  361. /* [retval][out] */ I_dxj_DirectMusicChordMap __RPC_FAR *__RPC_FAR *ret)
  362. {
  363. HRESULT hr;
  364. IDirectMusicChordMap *pMap=NULL;
  365. __try {
  366. if (!ret) return E_INVALIDARG;
  367. *ret=NULL;
  368. hr=m__dxj_DirectMusicSegment->GetParam(GUID_IDirectMusicChordMap,0xFFFFFFFF,(DWORD)lTrack,(MUSIC_TIME)mtTime,(MUSIC_TIME*)mtUntil,&pMap );
  369. if FAILED(hr) return hr;
  370. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicChordMap,pMap,ret);
  371. if (*ret==NULL) return E_OUTOFMEMORY;
  372. }
  373. __except(EXCEPTION_EXECUTE_HANDLER)
  374. {
  375. return E_FAIL;
  376. }
  377. return hr;
  378. }
  379. HRESULT C_dxj_DirectMusicSegmentObject::GetName(BSTR *ret)
  380. {
  381. HRESULT hr;
  382. IDirectMusicObject8 *pObj = NULL;
  383. DMUS_OBJECTDESC objDesc;
  384. __try {
  385. *ret=NULL;
  386. hr=m__dxj_DirectMusicSegment->QueryInterface(IID_IDirectMusicObject8, (void**) &pObj);
  387. if FAILED(hr) return hr;
  388. ZeroMemory(&objDesc, sizeof(DMUS_OBJECTDESC));
  389. objDesc.dwSize = sizeof(DMUS_OBJECTDESC);
  390. pObj->GetDescriptor(&objDesc);
  391. if ((objDesc.dwValidData & DMUS_OBJ_NAME) == DMUS_OBJ_NAME)
  392. {
  393. //Return this name
  394. *ret = SysAllocString(objDesc.wszName);
  395. }
  396. else if ((objDesc.dwValidData & DMUS_OBJ_FILENAME) == DMUS_OBJ_FILENAME)
  397. {
  398. //Return this filename
  399. *ret = SysAllocString(objDesc.wszFileName);
  400. }
  401. }
  402. __except(EXCEPTION_EXECUTE_HANDLER)
  403. {
  404. return E_FAIL;
  405. }
  406. return S_OK;
  407. }