From caa34148331b177d309b125aa86b9e15b831eb29 Mon Sep 17 00:00:00 2001 From: Iliyas Jorio Date: Tue, 17 May 2022 22:56:40 +0200 Subject: [PATCH] SndChannelStatus: paused channels count as busy --- src/SoundMixer/SoundManager.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/SoundMixer/SoundManager.cpp b/src/SoundMixer/SoundManager.cpp index 6262d96..f06b9ed 100644 --- a/src/SoundMixer/SoundManager.cpp +++ b/src/SoundMixer/SoundManager.cpp @@ -106,14 +106,20 @@ OSErr SndDisposeChannel(SndChannelPtr macChanPtr, Boolean quietNow) OSErr SndChannelStatus(SndChannelPtr chan, short theLength, SCStatusPtr theStatus) { - (void) theLength; + // Must have room to write an entire SCStatus struct + if ((size_t) theLength < sizeof(SCStatus)) + { + return paramErr; + } *theStatus = {}; auto& source = GetChannelImpl(chan).source; - theStatus->scChannelPaused = source.GetState() == cmixer::CM_STATE_PAUSED; - theStatus->scChannelBusy = source.GetState() == cmixer::CM_STATE_PLAYING; + int state = source.GetState(); + + theStatus->scChannelPaused = state == cmixer::CM_STATE_PAUSED; + theStatus->scChannelBusy = state != cmixer::CM_STATE_STOPPED; return noErr; }