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.

108 lines
3.2 KiB

  1. // Copyright (c) 1998-1999 Microsoft Corporation
  2. /* This is a class to manage tracking mutes for the SeqTrack and BandTrack. */
  3. #include "PChMap.h"
  4. #include "dmusicf.h"
  5. CPChMap::CPChMap()
  6. {
  7. }
  8. CPChMap::~CPChMap()
  9. {
  10. }
  11. // Reset sets all item's mtNext time values to -1, so they are gotten again.
  12. void CPChMap::Reset(void)
  13. {
  14. TListItem<PCHMAP_ITEM>* pItem;
  15. for( pItem = m_PChMapList.GetHead(); pItem; pItem = pItem->GetNext() )
  16. {
  17. PCHMAP_ITEM& rItem = pItem->GetItemValue();
  18. rItem.mtNext = -1;
  19. rItem.dwPChMap = rItem.dwPChannel;
  20. rItem.fMute = 0;
  21. }
  22. }
  23. // GetInfo calls the performance's GetData to get the current Mute Track information.
  24. // Reset() will be called upon any invalidation or seek, which will set the
  25. // internal times to -1 so this will be accurate in case of a new controlling segment.
  26. // You must provide the pfMute and pdwNewPCh parameters to this function, or
  27. // it will crash.
  28. void CPChMap::GetInfo( DWORD dwPCh, MUSIC_TIME mtTime, MUSIC_TIME mtOffset, DWORD dwGroupBits,
  29. IDirectMusicPerformance* pPerf, BOOL* pfMute, DWORD* pdwNewPCh, BOOL fClockTime )
  30. {
  31. TListItem<PCHMAP_ITEM>* pItem;
  32. for( pItem = m_PChMapList.GetHead(); pItem; pItem = pItem->GetNext() )
  33. {
  34. PCHMAP_ITEM& rCheck = pItem->GetItemValue();
  35. if( rCheck.dwPChannel == dwPCh ) break;
  36. }
  37. if( NULL == pItem )
  38. {
  39. PCHMAP_ITEM item;
  40. item.mtNext = -1;
  41. item.dwPChannel = item.dwPChMap = dwPCh;
  42. item.fMute = FALSE;
  43. pItem = new TListItem<PCHMAP_ITEM>(item);
  44. if( NULL == pItem )
  45. {
  46. // error, out of memory.
  47. *pfMute = FALSE;
  48. *pdwNewPCh = dwPCh;
  49. return;
  50. }
  51. m_PChMapList.AddHead(pItem);
  52. }
  53. PCHMAP_ITEM& rItem = pItem->GetItemValue();
  54. if( mtTime >= rItem.mtNext )
  55. {
  56. DMUS_MUTE_PARAM muteParam;
  57. MUSIC_TIME mtNext;
  58. muteParam.dwPChannel = dwPCh;
  59. if (fClockTime)
  60. {
  61. MUSIC_TIME mtMusic;
  62. REFERENCE_TIME rtTime = (mtTime + mtOffset) * 10000;
  63. pPerf->ReferenceToMusicTime(rtTime,&mtMusic);
  64. if( SUCCEEDED(pPerf->GetParam( GUID_MuteParam, dwGroupBits, 0, mtMusic,
  65. &mtNext, (void*)&muteParam )))
  66. {
  67. REFERENCE_TIME rtNext;
  68. // Convert to absolute reference time.
  69. pPerf->MusicToReferenceTime(mtNext + mtMusic,&rtNext);
  70. rtNext -= rtTime; // Subtract out to get the delta.
  71. rItem.mtNext = (MUSIC_TIME)(rtNext / 10000); // Convert to delta in milliseconds. BUGBUG What if there's a tempo change?
  72. rItem.dwPChMap = muteParam.dwPChannelMap;
  73. rItem.fMute = muteParam.fMute;
  74. }
  75. else
  76. {
  77. // no mute track, or no mute on this pchannel.
  78. // keep the current mapping.
  79. rItem.mtNext = 0x7fffffff;
  80. }
  81. }
  82. else
  83. {
  84. if( SUCCEEDED(pPerf->GetParam( GUID_MuteParam, dwGroupBits, 0, mtTime + mtOffset,
  85. &mtNext, (void*)&muteParam )))
  86. {
  87. rItem.mtNext = mtNext;
  88. rItem.dwPChMap = muteParam.dwPChannelMap;
  89. rItem.fMute = muteParam.fMute;
  90. }
  91. else
  92. {
  93. // no mute track, or no mute on this pchannel.
  94. // keep the current mapping.
  95. rItem.mtNext = 0x7fffffff;
  96. }
  97. }
  98. }
  99. *pfMute = rItem.fMute;
  100. *pdwNewPCh = rItem.dwPChMap;
  101. }