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.

179 lines
5.9 KiB

  1. // Copyright (c) 1998-1999 Microsoft Corporation
  2. // SeqTrack.h : Declaration of the CSeqTrack
  3. #ifndef __SEQTRACK_H_
  4. #define __SEQTRACK_H_
  5. #include "dmusici.h"
  6. #include "dmusicf.h"
  7. #include "..\dmstyle\tlist.h"
  8. #include "PChMap.h"
  9. struct SeqStateData
  10. {
  11. DWORD dwPChannelsUsed; // number of PChannels
  12. // the following two arrays are allocated to the size of dwNumPChannels, which
  13. // must match the SeqTrack's m_dwPChannelsUsed. The arrays match one-for-one with
  14. // the parts inside the SeqTrack.
  15. TListItem<DMUS_IO_SEQ_ITEM>** apCurrentSeq; // array of size dwNumPChannels
  16. TListItem<DMUS_IO_CURVE_ITEM>** apCurrentCurve; // array of size dwNumPChannels
  17. DWORD dwValidate;
  18. MUSIC_TIME mtCurTimeSig; // time the current timesig started
  19. MUSIC_TIME mtNextTimeSig; // time for the next timesig
  20. DWORD dwMeasure; // starting measure # of the timesig
  21. DWORD dwlnBeat; // length of a beat
  22. DWORD dwlnMeasure; // length of a measure
  23. DWORD dwlnGrid; // length of a grid
  24. DWORD dwGroupBits; // the group bits of this track
  25. SeqStateData()
  26. {
  27. mtCurTimeSig = 0;
  28. mtNextTimeSig = 0;
  29. dwMeasure = 0;
  30. dwlnBeat = DMUS_PPQ;
  31. dwlnMeasure = DMUS_PPQ * 4;
  32. dwlnGrid = DMUS_PPQ / 4;
  33. apCurrentSeq = NULL;
  34. apCurrentCurve = NULL;
  35. }
  36. ~SeqStateData()
  37. {
  38. if( apCurrentSeq )
  39. {
  40. delete [] apCurrentSeq;
  41. }
  42. if( apCurrentCurve )
  43. {
  44. delete [] apCurrentCurve;
  45. }
  46. }
  47. };
  48. // SEQ_PART represents all of the DMUS_PMSG's inside the SeqTrack for one PChannel
  49. struct SEQ_PART
  50. {
  51. SEQ_PART* pNext;
  52. DWORD dwPChannel;
  53. TList<DMUS_IO_SEQ_ITEM> seqList;
  54. TList<DMUS_IO_CURVE_ITEM> curveList;
  55. SEQ_PART() : pNext(NULL) {}; // always initialize pNext to NULL
  56. };
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CSeqTrack
  59. class CSeqTrack :
  60. public IPersistStream,
  61. public IDirectMusicTrack8
  62. {
  63. public:
  64. CSeqTrack();
  65. CSeqTrack(
  66. const CSeqTrack& rTrack, MUSIC_TIME mtStart, MUSIC_TIME mtEnd);
  67. ~CSeqTrack();
  68. public:
  69. // IUnknown
  70. STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  71. STDMETHODIMP_(ULONG) AddRef();
  72. STDMETHODIMP_(ULONG) Release();
  73. // IDirectMusicTrack methods
  74. STDMETHODIMP IsParamSupported(REFGUID rguid);
  75. STDMETHODIMP Init(IDirectMusicSegment *pSegment);
  76. STDMETHODIMP InitPlay(IDirectMusicSegmentState *pSegmentState,
  77. IDirectMusicPerformance *pPerformance,
  78. void **ppStateData,
  79. DWORD dwTrackID,
  80. DWORD dwFlags);
  81. STDMETHODIMP EndPlay(void *pStateData);
  82. STDMETHODIMP Play(void *pStateData,MUSIC_TIME mtStart,
  83. MUSIC_TIME mtEnd,MUSIC_TIME mtOffset,
  84. DWORD dwFlags,IDirectMusicPerformance* pPerf,
  85. IDirectMusicSegmentState* pSegSt,DWORD dwVirtualID);
  86. STDMETHODIMP GetParam(REFGUID rguid,MUSIC_TIME mtTime,MUSIC_TIME* pmtNext,void *pData);
  87. STDMETHODIMP SetParam(REFGUID rguid,MUSIC_TIME mtTime,void *pData);
  88. STDMETHODIMP AddNotificationType(REFGUID rguidNotification);
  89. STDMETHODIMP RemoveNotificationType(REFGUID rguidNotification);
  90. STDMETHODIMP Clone(MUSIC_TIME mtStart,MUSIC_TIME mtEnd,IDirectMusicTrack** ppTrack);
  91. // IDirectMusicTrack8
  92. STDMETHODIMP PlayEx(void* pStateData,REFERENCE_TIME rtStart,
  93. REFERENCE_TIME rtEnd,REFERENCE_TIME rtOffset,
  94. DWORD dwFlags,IDirectMusicPerformance* pPerf,
  95. IDirectMusicSegmentState* pSegSt,DWORD dwVirtualID) ;
  96. STDMETHODIMP GetParamEx(REFGUID rguidType,REFERENCE_TIME rtTime,
  97. REFERENCE_TIME* prtNext,void* pParam,void * pStateData, DWORD dwFlags) ;
  98. STDMETHODIMP SetParamEx(REFGUID rguidType,REFERENCE_TIME rtTime,void* pParam, void * pStateData, DWORD dwFlags) ;
  99. STDMETHODIMP Compose(IUnknown* pContext,
  100. DWORD dwTrackGroup,
  101. IDirectMusicTrack** ppResultTrack) ;
  102. STDMETHODIMP Join(IDirectMusicTrack* pNewTrack,
  103. MUSIC_TIME mtJoin,
  104. IUnknown* pContext,
  105. DWORD dwTrackGroup,
  106. IDirectMusicTrack** ppResultTrack) ;
  107. // IPersist functions
  108. STDMETHODIMP GetClassID( CLSID* pClsId );
  109. // IPersistStream functions
  110. STDMETHODIMP IsDirty();
  111. STDMETHODIMP Load( IStream* pIStream );
  112. STDMETHODIMP Save( IStream* pIStream, BOOL fClearDirty );
  113. STDMETHODIMP GetSizeMax( ULARGE_INTEGER FAR* pcbSize );
  114. protected:
  115. HRESULT STDMETHODCALLTYPE Seek(
  116. IDirectMusicSegmentState*,
  117. IDirectMusicPerformance*,
  118. DWORD dwVirtualID,
  119. SeqStateData*,
  120. MUSIC_TIME mtTime,
  121. BOOL fGetPrevious,
  122. MUSIC_TIME mtOffset,
  123. REFERENCE_TIME rtOffset,
  124. BOOL fClockTime);
  125. void SendSeekItem(
  126. IDirectMusicPerformance*,
  127. IDirectMusicGraph*,
  128. IDirectMusicSegmentState*,
  129. SeqStateData* pSD,
  130. DWORD dwVirtualID,
  131. MUSIC_TIME mtTime,
  132. MUSIC_TIME mtOffset,
  133. REFERENCE_TIME rtOffset,
  134. TListItem<DMUS_IO_SEQ_ITEM>*,
  135. TListItem<DMUS_IO_CURVE_ITEM>*,
  136. BOOL fClockTime);
  137. HRESULT Play(
  138. void *pStateData,
  139. MUSIC_TIME mtStart,
  140. MUSIC_TIME mtEnd,
  141. MUSIC_TIME mtOffset,
  142. REFERENCE_TIME rtOffset,
  143. DWORD dwFlags,
  144. IDirectMusicPerformance* pPerf,
  145. IDirectMusicSegmentState* pSegSt,
  146. DWORD dwVirtualID,
  147. BOOL fClockTime);
  148. void Construct(void);
  149. HRESULT LoadCurve( IStream* pIStream, long lSize );
  150. HRESULT LoadSeq( IStream* pIStream, long lSize );
  151. void UpdateTimeSig(IDirectMusicSegmentState*, SeqStateData* pSD, MUSIC_TIME mt);
  152. TListItem<SEQ_PART>* FindPart( DWORD dwPChannel );
  153. void DeleteSeqPartList(void);
  154. void SetUpStateCurrentPointers(SeqStateData* pStateData);
  155. // member variables
  156. private:
  157. TList<SEQ_PART> m_SeqPartList;
  158. TListItem<SEQ_PART>* m_pSeqPartCache; // used to time-optimize FindPart()
  159. DWORD m_dwPChannelsUsed;
  160. DWORD* m_aPChannels;
  161. long m_cRef;
  162. DWORD m_dwValidate; // used to validate state data
  163. CRITICAL_SECTION m_CrSec;
  164. BOOL m_fCSInitialized;
  165. CPChMap m_PChMap;
  166. };
  167. #endif //__SEQTRACK_H_