@@ -13,15 +13,16 @@ ASSERTNAME
1313
1414#define AssertDoMix (x ) AssertDo(x >= 0 , Mix_GetError());
1515
16- typedef int SDLChannelId;
17-
1816// Maximum number of SDL channels that will be allocated
1917const SDLChannelId kSDLChannelIdMac = 32 ;
2018const SDLChannelId kSDLChannelIdInvalid = -1 ;
2119
2220const int32_t klwFrequency = 44100 ;
2321const int32_t klwChunkSize = 1024 ;
2422
23+ // Channel ID reserved for MIDI playback
24+ const SDLChannelId kSDLChannelIdMidi = 0 ;
25+
2526// Number of milliseconds after playing a new sound that pause will be ignored.
2627// This is a hack to work around a difference in behaviour in AudioMan.
2728// When AudioMan plays a sound it will mix and write a chunk of the sound to the
@@ -492,6 +493,9 @@ PSNQUE SDLSoundDevice::_PsnqueNew(void)
492493 bool rgfAllocated[kSDLChannelIdMac ];
493494 ClearPb (rgfAllocated, SIZEOF (rgfAllocated));
494495
496+ // Reserve channel for MIDI playback
497+ rgfAllocated[kSDLChannelIdMidi ] = fTrue ;
498+
495499 for (int32_t iqueue = 0 ; iqueue < _pglsnqd->IvMac (); iqueue++)
496500 {
497501 SNQD snqd;
@@ -505,6 +509,7 @@ PSNQUE SDLSoundDevice::_PsnqueNew(void)
505509
506510 if (ichannel >= 0 && ichannel < CvFromRgv (rgfAllocated))
507511 {
512+ Assert (!rgfAllocated[ichannel], " Mixer channel used by multiple sound queues" );
508513 rgfAllocated[ichannel] = fTrue ;
509514 }
510515 else
0 commit comments