Source code of Windows XP (NT5)
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.

100 lines
3.4 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All rights reserved.
  2. //
  3. // Declaration of CSegTriggerTrack.
  4. //
  5. // This track type holds events that cause other segments to be cued at
  6. // specific points during playback of a segment.
  7. #pragma once
  8. #include "trackhelp.h"
  9. #include "tlist.h"
  10. #include "smartref.h"
  11. //////////////////////////////////////////////////////////////////////
  12. // Types
  13. // Items in list of events
  14. struct TriggerInfo
  15. {
  16. TriggerInfo() : lTriggerTime(0), lTimePhysical(0), dwPlayFlags(0), dwFlags(0), pIDMSegment(NULL) {}
  17. ~TriggerInfo() {
  18. RELEASE(pIDMSegment);
  19. }
  20. HRESULT Clone(const TriggerInfo &o, MUSIC_TIME mtStart)
  21. {
  22. lTriggerTime = o.lTriggerTime - mtStart;
  23. lTimePhysical = o.lTimePhysical - mtStart;
  24. dwPlayFlags = o.dwPlayFlags;
  25. dwFlags = o.dwFlags;
  26. pIDMSegment = o.pIDMSegment;
  27. pIDMSegment->AddRef();
  28. return S_OK;
  29. }
  30. // from event header chunk <scrh>
  31. MUSIC_TIME lTriggerTime; // Logical time
  32. MUSIC_TIME lTimePhysical;
  33. DWORD dwPlayFlags;
  34. DWORD dwFlags;
  35. // from reference <DMRF>
  36. IDirectMusicSegment *pIDMSegment;
  37. };
  38. // State data. This track needs to get the audio path that's currently playing so that it
  39. // can use it when playing triggered segments.
  40. struct CSegTriggerTrackState : public CStandardStateData<TriggerInfo>
  41. {
  42. CSegTriggerTrackState() : pAudioPath(NULL) {};
  43. ~CSegTriggerTrackState() { if (pAudioPath) pAudioPath->Release(); }
  44. IDirectMusicAudioPath *pAudioPath;
  45. };
  46. //////////////////////////////////////////////////////////////////////
  47. // CSegTriggerTrack
  48. class CSegTriggerTrack;
  49. typedef CPlayingTrack<CSegTriggerTrack, TriggerInfo, CSegTriggerTrackState> CSegTriggerTrackBase;
  50. class CSegTriggerTrack
  51. : public CSegTriggerTrackBase
  52. {
  53. public:
  54. // When the segment trigger track plays one of its items, it plays a segment. If an invalidation occurs, that Play operation
  55. // can't be retracted. Then the track is played again (with the FLUSH bit set). This was causing it to trigger the segment
  56. // a second time. To fix this, the last parameter to the CSegTriggerTrackBase is false, which instructs it not to call play
  57. // a second time when the FLUSH bit is set.
  58. CSegTriggerTrack(HRESULT *pHr) : CSegTriggerTrackBase(&g_cComponent, CLSID_DirectMusicSegmentTriggerTrack, true, false), m_dwFlags(NULL), m_dwRecursionCount(0) {}
  59. // Implement SetParam by calling SetParam in turn on all the child segments. This is needed, for example so that downloading a segment with a segment trigger track will download all the triggered segments as well.
  60. STDMETHOD(IsParamSupported)(REFGUID rguid) { return S_OK; } // Once or more of our child segments could potentially support any type of parameter.
  61. STDMETHOD(SetParam)(REFGUID rguid, MUSIC_TIME mtTime, void *pData);
  62. STDMETHOD(InitPlay)(
  63. IDirectMusicSegmentState *pSegmentState,
  64. IDirectMusicPerformance *pPerformance,
  65. void **ppStateData,
  66. DWORD dwTrackID,
  67. DWORD dwFlags);
  68. protected:
  69. HRESULT PlayItem(
  70. const TriggerInfo &item,
  71. statedata &state,
  72. IDirectMusicPerformance *pPerf,
  73. IDirectMusicSegmentState* pSegSt,
  74. DWORD dwVirtualID,
  75. MUSIC_TIME mtOffset,
  76. REFERENCE_TIME rtOffset,
  77. bool fClockTime);
  78. HRESULT LoadRiff(SmartRef::RiffIter &ri, IDirectMusicLoader *pIDMLoader);
  79. private:
  80. HRESULT LoadTrigger(SmartRef::RiffIter ri, IDirectMusicLoader *pIDMLoader);
  81. // Data
  82. DWORD m_dwFlags; // from track header (sgth chunk)
  83. BOOL m_dwRecursionCount; // Used to keep track of recursive calls to self.
  84. };