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.

189 lines
4.9 KiB

  1. // Copyright (c) 1998-1999 Microsoft Corporation
  2. // SysExTrk.h : Declaration of the CSysExTrk
  3. #ifndef __SYSEXTRK_H_
  4. #define __SYSEXTRK_H_
  5. #include "dmusici.h"
  6. #include "dmusicf.h"
  7. #include "alist.h"
  8. // FullSysexEvent is DMUS_IO_SYSEX_ITEM plus data pointer
  9. struct FullSysexEvent : DMUS_IO_SYSEX_ITEM
  10. {
  11. BYTE* pbSysExData;
  12. };
  13. class SysExListItem : public AListItem
  14. {
  15. public:
  16. SysExListItem()
  17. {
  18. m_pItem = NULL;
  19. };
  20. HRESULT SetItem( FullSysexEvent item )
  21. {
  22. if( m_pItem )
  23. {
  24. delete [] m_pItem->pbSysExData;
  25. }
  26. else
  27. {
  28. m_pItem = new FullSysexEvent;
  29. }
  30. if( m_pItem )
  31. {
  32. m_pItem->mtTime = item.mtTime;
  33. m_pItem->dwSysExLength = item.dwSysExLength;
  34. m_pItem->pbSysExData = item.pbSysExData;
  35. return S_OK;
  36. }
  37. else
  38. {
  39. return E_OUTOFMEMORY;
  40. }
  41. };
  42. ~SysExListItem()
  43. {
  44. if( m_pItem )
  45. {
  46. if( m_pItem->pbSysExData )
  47. {
  48. delete [] m_pItem->pbSysExData;
  49. }
  50. delete m_pItem;
  51. }
  52. };
  53. SysExListItem* GetNext()
  54. {
  55. return (SysExListItem*)AListItem::GetNext();
  56. };
  57. public:
  58. FullSysexEvent* m_pItem;
  59. };
  60. class SysExList : public AList
  61. {
  62. public:
  63. ~SysExList()
  64. {
  65. SysExListItem* pItem;
  66. while( pItem = (SysExListItem*)AList::RemoveHead() )
  67. {
  68. delete pItem;
  69. }
  70. };
  71. void DeleteAll()
  72. {
  73. SysExListItem* pItem;
  74. while( pItem = (SysExListItem*)AList::RemoveHead() )
  75. {
  76. delete pItem;
  77. }
  78. };
  79. SysExListItem* GetHead()
  80. {
  81. return (SysExListItem*)AList::GetHead();
  82. };
  83. };
  84. struct SysExStateData
  85. {
  86. SysExListItem* pCurrentSysEx;
  87. IDirectMusicPerformance* pPerformance;
  88. IDirectMusicSegmentState* pSegState;
  89. DWORD dwVirtualTrackID;
  90. DWORD dwValidate;
  91. MUSIC_TIME mtPrevEnd;
  92. SysExStateData()
  93. {
  94. mtPrevEnd = 0;
  95. }
  96. };
  97. /////////////////////////////////////////////////////////////////////////////
  98. // CSysExTrk
  99. class CSysExTrack :
  100. public IPersistStream,
  101. public IDirectMusicTrack8
  102. {
  103. public:
  104. CSysExTrack();
  105. CSysExTrack::CSysExTrack(
  106. CSysExTrack& rTrack, MUSIC_TIME mtStart, MUSIC_TIME mtEnd);
  107. ~CSysExTrack();
  108. // ISysExTrk
  109. public:
  110. // IUnknown
  111. STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  112. STDMETHODIMP_(ULONG) AddRef();
  113. STDMETHODIMP_(ULONG) Release();
  114. // IDirectMusicTrack methods
  115. STDMETHODIMP IsParamSupported(REFGUID rguid);
  116. STDMETHODIMP Init(IDirectMusicSegment *pSegment);
  117. STDMETHODIMP InitPlay(IDirectMusicSegmentState *pSegmentState,
  118. IDirectMusicPerformance *pPerformance,
  119. void **ppStateData,
  120. DWORD dwTrackID,
  121. DWORD dwFlags);
  122. STDMETHODIMP EndPlay(void *pStateData);
  123. STDMETHODIMP Play(void *pStateData,MUSIC_TIME mtStart,
  124. MUSIC_TIME mtEnd,MUSIC_TIME mtOffset,
  125. DWORD dwFlags,IDirectMusicPerformance* pPerf,
  126. IDirectMusicSegmentState* pSegSt,DWORD dwVirtualID);
  127. STDMETHODIMP GetParam(REFGUID rguid,MUSIC_TIME mtTime,MUSIC_TIME* pmtNext,void *pData);
  128. STDMETHODIMP SetParam(REFGUID rguid,MUSIC_TIME mtTime,void *pData);
  129. STDMETHODIMP AddNotificationType(REFGUID rguidNotification);
  130. STDMETHODIMP RemoveNotificationType(REFGUID rguidNotification);
  131. STDMETHODIMP Clone(MUSIC_TIME mtStart,MUSIC_TIME mtEnd,IDirectMusicTrack** ppTrack);
  132. // IDirectMusicTrack8
  133. STDMETHODIMP PlayEx(void* pStateData,REFERENCE_TIME rtStart,
  134. REFERENCE_TIME rtEnd,REFERENCE_TIME rtOffset,
  135. DWORD dwFlags,IDirectMusicPerformance* pPerf,
  136. IDirectMusicSegmentState* pSegSt,DWORD dwVirtualID) ;
  137. STDMETHODIMP GetParamEx(REFGUID rguidType,REFERENCE_TIME rtTime,
  138. REFERENCE_TIME* prtNext,void* pParam,void * pStateData, DWORD dwFlags) ;
  139. STDMETHODIMP SetParamEx(REFGUID rguidType,REFERENCE_TIME rtTime,void* pParam, void * pStateData, DWORD dwFlags) ;
  140. STDMETHODIMP Compose(IUnknown* pContext,
  141. DWORD dwTrackGroup,
  142. IDirectMusicTrack** ppResultTrack) ;
  143. STDMETHODIMP Join(IDirectMusicTrack* pNewTrack,
  144. MUSIC_TIME mtJoin,
  145. IUnknown* pContext,
  146. DWORD dwTrackGroup,
  147. IDirectMusicTrack** ppResultTrack) ;
  148. // IPersist functions
  149. STDMETHODIMP GetClassID( CLSID* pClsId );
  150. // IPersistStream functions
  151. STDMETHODIMP IsDirty();
  152. STDMETHODIMP Load( IStream* pIStream );
  153. STDMETHODIMP Save( IStream* pIStream, BOOL fClearDirty );
  154. STDMETHODIMP GetSizeMax( ULARGE_INTEGER FAR* pcbSize );
  155. protected:
  156. HRESULT Seek(void *pStateData,MUSIC_TIME mtTime);
  157. HRESULT Play(void *pStateData,MUSIC_TIME mtStart,MUSIC_TIME mtEnd,
  158. MUSIC_TIME mtOffset,REFERENCE_TIME rtOffset,DWORD dwFlags,
  159. IDirectMusicPerformance* pPerf,IDirectMusicSegmentState* pSegSt,
  160. DWORD dwVirtualID,BOOL fClockTime);
  161. void Construct(void);
  162. // private member variables
  163. protected:
  164. SysExList m_SysExEventList;
  165. long m_cRef;
  166. DWORD m_dwValidate;
  167. CRITICAL_SECTION m_CrSec;
  168. BOOL m_fCSInitialized;
  169. };
  170. #endif //__SYSEXTRK_H_