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.

155 lines
8.7 KiB

  1. // Copyright (c) 1998-1999 Microsoft Corporation
  2. // DMSStObj.h : Declaration of the CSegState
  3. #ifndef __DIRECTMUSICSEGMENTSTATEOBJECT_H_
  4. #define __DIRECTMUSICSEGMENTSTATEOBJECT_H_
  5. #include "dmusici.h"
  6. #include "TrkList.h"
  7. #include "alist.h"
  8. #include "audpath.h"
  9. class CPerformance;
  10. class CSegState;
  11. class CGraph;
  12. // Control flags, placed in track->m_dwInternalFlags by ManageControllingTracks().
  13. #define CONTROL_PLAY_IS_DISABLED 0x1 // Indicates the track is already disabled.
  14. #define CONTROL_PLAY_WAS_DISABLED 0x2 // Indicates the track was previously disabled.
  15. #define CONTROL_PLAY_REFRESH 0x4 // Indicates it has been reenabled and needs to be refreshed.
  16. #define CONTROL_PLAY_DEFAULT_DISABLED 0x8 // Indicates it was disabled for playback anyway.
  17. #define CONTROL_PLAY_DEFAULT_ENABLED 0x10 // Indicates it was enabled for playback.
  18. #define CONTROL_NTFY_IS_DISABLED 0x20 // Indicates the track is already disabled for notifications.
  19. #define CONTROL_NTFY_DEFAULT_DISABLED 0x40 // Indicates it was disabled for notifications anyway.
  20. #define CONTROL_NTFY_DEFAULT_ENABLED 0x80 // Indicates it was enabled for notifications.
  21. DEFINE_GUID(IID_CSegState,0xb06c0c26, 0xd3c7, 0x11d3, 0x9b, 0xd1, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CSegState
  24. class CSegState :
  25. public IDirectMusicSegmentState8,
  26. public IDirectMusicGraph,
  27. public AListItem
  28. {
  29. friend class CSegment;
  30. friend class CAudioPath;
  31. friend class CPerformance;
  32. public:
  33. CSegState();
  34. ~CSegState();
  35. // IUnknown
  36. virtual STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  37. virtual STDMETHODIMP_(ULONG) AddRef();
  38. virtual STDMETHODIMP_(ULONG) Release();
  39. // IDirectMusicSegmentState
  40. STDMETHODIMP GetRepeats(DWORD *pdwRepeats);
  41. STDMETHODIMP GetSegment(IDirectMusicSegment **ppSegment);
  42. STDMETHODIMP GetStartTime(MUSIC_TIME __RPC_FAR *);
  43. STDMETHODIMP Play(MUSIC_TIME mtAmount,MUSIC_TIME *pmtPlayed); // No longer supported.
  44. STDMETHODIMP GetSeek(MUSIC_TIME *pmtSeek);
  45. STDMETHODIMP GetStartPoint(MUSIC_TIME *pmtStart);
  46. STDMETHODIMP Flush(MUSIC_TIME mtTime);
  47. // IDirectMusicSegmentState8
  48. STDMETHODIMP SetTrackConfig( REFGUID rguidTrackClassID,DWORD dwGroup, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff) ;
  49. STDMETHODIMP GetObjectInPath( DWORD dwPChannel,DWORD dwStage,DWORD dwBuffer, REFGUID guidObject,
  50. DWORD dwIndex,REFGUID iidInterface, void ** ppObject);
  51. // IDirectMusicGraph
  52. STDMETHODIMP Shutdown();
  53. STDMETHODIMP InsertTool(IDirectMusicTool *pTool,DWORD *pdwPChannels,DWORD cPChannels,LONG lIndex);
  54. STDMETHODIMP GetTool(DWORD,IDirectMusicTool**);
  55. STDMETHODIMP RemoveTool(IDirectMusicTool*);
  56. STDMETHODIMP StampPMsg(DMUS_PMSG* pEvent);
  57. // Methods used by performance to access SegmentState.
  58. HRESULT PrivateInit(CSegment *pParentSegment,CPerformance *pPerformance);
  59. HRESULT InitRoute(IDirectMusicAudioPath *pAudioPath);
  60. HRESULT ShutDown(void); // called from ~SEGSTNODE in dmperf.h
  61. HRESULT GetTrackList(void** ppTrackList);
  62. HRESULT SetSeek(MUSIC_TIME mtSeek,DWORD dwPlayFlags);
  63. HRESULT SetInvalidate(MUSIC_TIME mtTime);
  64. MUSIC_TIME GetEndTime(MUSIC_TIME mtStartTime);
  65. HRESULT ConvertToSegTime(MUSIC_TIME* pmtTime, MUSIC_TIME* pmtOffset, DWORD* pdwRepeat);
  66. HRESULT AbortPlay( MUSIC_TIME mtTime, BOOL fLeaveNotesOn ); // called when the segstate is stopped prematurely
  67. HRESULT CheckPlay( MUSIC_TIME mtAmount, MUSIC_TIME* pmtResult );
  68. HRESULT Play(MUSIC_TIME mtAmount);
  69. HRESULT GetParam( CPerformance *pPerf,REFGUID rguidType,DWORD dwGroupBits,
  70. DWORD dwIndex,MUSIC_TIME mtTime,MUSIC_TIME* pmtNext,void* pParam);
  71. CSegState* GetNext() { return (CSegState*)AListItem::GetNext();}
  72. private:
  73. CTrack *GetTrackByParam(CTrack * pCTrack,REFGUID rguidType,DWORD dwGroupBits,DWORD dwIndex);
  74. CTrack *GetTrack(REFCLSID rType,DWORD dwGroupBits,DWORD dwIndex);
  75. void GenerateNotification( DWORD dwNotification, MUSIC_TIME mtTime );
  76. void SendDirtyPMsg( MUSIC_TIME mtTime );
  77. public:
  78. // Attributes
  79. CRITICAL_SECTION m_CriticalSection;
  80. IUnknown* m_pUnkDispatch; // holds the controlling unknown of the scripting object that implements IDispatch
  81. CPerformance* m_pPerformance;
  82. CSegment* m_pSegment; // Holds the parent segment pointer, weak reference, for convenience
  83. CAudioPath* m_pAudioPath; // Maps vchannels to pchannels, if requested.
  84. CGraph* m_pGraph; // Temp graph is a copy of the segment's graph.
  85. CTrackList m_TrackList; // list of Tracks held in this SegmentState
  86. MUSIC_TIME m_mtLoopStart; // Loop start point.
  87. MUSIC_TIME m_mtLoopEnd; // Loop end point.
  88. DWORD m_dwRepeats; // The original repeat setting (before countdown)
  89. MUSIC_TIME m_mtLength; // Length of segment.
  90. DWORD m_dwPlayTrackFlags;// Track playback controlflags.
  91. DWORD m_dwPlaySegFlags;// Segment playback control flags.
  92. DWORD m_dwSegFlags; // New Segment Flags from file.
  93. MUSIC_TIME m_mtResolvedStart;// Start time resolved to desired resolution
  94. MUSIC_TIME m_mtEndTime; // End time that the segment should play to if not stopped.
  95. MUSIC_TIME m_mtOffset; // Start time of the segment in absolute time, as if it were started from the beginning.
  96. MUSIC_TIME m_mtLastPlayed; // the last played absolute time
  97. MUSIC_TIME m_mtStopTime; // Used to stop play at a specific time. Ignored when 0.
  98. MUSIC_TIME m_mtSeek; // How far into the segment we are.
  99. MUSIC_TIME m_mtStartPoint; // Point in the segment where playback started
  100. MUSIC_TIME m_mtAbortTime; // Time a sudden stop occured.
  101. REFERENCE_TIME m_rtGivenStart; // Start time given in PlaySegment, unquantized
  102. REFERENCE_TIME m_rtLastPlayed; // Clock time version of the last played absolute time
  103. REFERENCE_TIME m_rtStartPoint; // Clock time version of point in the segment where playback started
  104. REFERENCE_TIME m_rtOffset; // Clock time version of start time of the segment in absolute time, as if it were started from the beginning.
  105. REFERENCE_TIME m_rtEndTime; // Clock time version of full length.
  106. REFERENCE_TIME m_rtSeek; // Clock time version of how far into the segment we are.
  107. REFERENCE_TIME m_rtLength; // Clock time length, read from file. If 0, ignore.
  108. REFERENCE_TIME m_rtFirstLoopStart; // The clock time for the loop start when it starts looping the VERY FIRST time
  109. REFERENCE_TIME m_rtCurLoopStart;// The clock time for the loop start for the current loop repetition
  110. REFERENCE_TIME m_rtCurLoopEnd; // The clock time for the loop end in the current loop repetition
  111. DWORD m_dwRepeatsLeft;// Current repeats left.
  112. BOOL m_fStartedPlay; // indicates if the segstate has started to play yet
  113. DWORD m_dwVersion; // Which release does the app think it is using - 6, 7, or 8..
  114. DWORD m_dwFirstTrackID;// Virtual ID of first track in segstate.
  115. DWORD m_dwLastTrackID;// Last track's virtual id.
  116. BOOL m_fPrepped; // Used to track whether PrepSegToPlay has been called.
  117. BOOL m_fSongMode; // True if part of a playing song. If so, this should queue the next segment when done.
  118. BOOL m_fCanStop; // If false, Stop() should ignore this segment (it was just queued to play by PlaySegmentEx().)
  119. BOOL m_fInPlay; // Segmentstate is currently playing.
  120. BOOL m_fDelayShutDown;
  121. CSegState * m_pSongSegState;// Used to track the starting segstate in a song.
  122. long m_cRef; // COM reference counter.
  123. };
  124. class CSegStateList : public AList
  125. {
  126. public:
  127. void AddHead(CSegState* pSegState) { AList::AddHead((AListItem*)pSegState);}
  128. void Insert(CSegState* pSegState);
  129. CSegState* GetHead(){return (CSegState*)AList::GetHead();}
  130. CSegState* GetItem(LONG lIndex){return (CSegState*)AList::GetItem(lIndex);}
  131. CSegState* RemoveHead() {return (CSegState *) AList::RemoveHead();}
  132. void Remove(CSegState* pSegState){AList::Remove((AListItem*)pSegState);}
  133. void AddTail(CSegState* pSegState){AList::AddTail((AListItem*)pSegState);}
  134. CSegState* GetTail(){ return (CSegState*)AList::GetTail();}
  135. void SetID(DWORD dwID) { m_dwID = dwID; }
  136. DWORD GetID() { return m_dwID; }
  137. private:
  138. DWORD m_dwID; // Identifies which segstate list this is.
  139. };
  140. #endif //__DIRECTMUSICSEGMENTSTATEOBJECT_H_