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.

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