mirror of
https://github.com/jorio/Pomme.git
synced 2025-01-13 12:31:44 +00:00
Sound: Add extension commands to pause/resume audio playback
These commands supersede Pomme_PauseAllChannels().
This commit is contained in:
parent
70acda5ce4
commit
db3b81e97f
@ -492,9 +492,6 @@ NumVersion SndSoundManagerVersion();
|
||||
// Pomme extension
|
||||
Boolean Pomme_DecompressSoundResource(SndListHandle* sndHandlePtr, long* offsetToHeader);
|
||||
|
||||
// Pomme extension
|
||||
void Pomme_PauseAllChannels(Boolean pause);
|
||||
|
||||
// Pomme extension
|
||||
SndListHandle Pomme_SndLoadFileAsResource(short fRefNum);
|
||||
|
||||
|
@ -285,6 +285,8 @@ enum ESndCmds
|
||||
sizeCmd = 90, // obsolete command
|
||||
convertCmd = 91, // obsolete MACE command
|
||||
pommeSetLoopCmd = 0x7001,
|
||||
pommePausePlaybackCmd = 0x7002, // pause playback ('pauseCmd' locks the channel, it doesn't pause playback)
|
||||
pommeResumePlaybackCmd = 0x7003, // resume playback ('resumeCmd' unlocks the channel, it doesn't unpause playback)
|
||||
// Do not define commands above 0x7FFF -- the high bit means a 'snd ' resource has associated sound data
|
||||
};
|
||||
|
||||
|
@ -34,8 +34,6 @@ public:
|
||||
bool loop;
|
||||
bool interpolate;
|
||||
|
||||
bool temporaryPause = false;
|
||||
|
||||
ChannelImpl(SndChannelPtr _macChannel, bool transferMacChannelOwnership);
|
||||
|
||||
~ChannelImpl();
|
||||
|
@ -181,9 +181,6 @@ static void InstallSoundInChannel(SndChannelPtr chan, const Ptr sampledSoundHead
|
||||
// issue pommeSetLoopCmd *after* bufferCmd/soundCmd.
|
||||
impl.ApplyParametersToSource(kApplyParameters_All & ~kApplyParameters_Loop);
|
||||
|
||||
// Override systemwide audio pause.
|
||||
impl.temporaryPause = false;
|
||||
|
||||
// Get it going!
|
||||
impl.source.Play();
|
||||
}
|
||||
@ -266,6 +263,20 @@ OSErr SndDoImmediate(SndChannelPtr chan, const SndCommand* cmd)
|
||||
impl.ApplyParametersToSource(kApplyParameters_Loop);
|
||||
break;
|
||||
|
||||
case pommePausePlaybackCmd:
|
||||
if (impl.source.state == cmixer::CM_STATE_PLAYING)
|
||||
{
|
||||
impl.source.Pause();
|
||||
}
|
||||
break;
|
||||
|
||||
case pommeResumePlaybackCmd:
|
||||
if (impl.source.state == cmixer::CM_STATE_PAUSED) // only resume paused channels -- don't resurrect stopped channels
|
||||
{
|
||||
impl.source.Play();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
TODOMINOR2(cmd->cmd << "(" << cmd->param1 << "," << cmd->param2 << ")");
|
||||
}
|
||||
@ -369,27 +380,6 @@ NumVersion SndSoundManagerVersion()
|
||||
return v;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Extension: pause/unpause channels that are currently playing
|
||||
|
||||
void Pomme_PauseAllChannels(Boolean pause)
|
||||
{
|
||||
for (auto* chan = Pomme::Sound::gHeadChan; chan; chan = chan->GetNext())
|
||||
{
|
||||
auto& source = chan->source;
|
||||
if (pause && source.state == cmixer::CM_STATE_PLAYING && !chan->temporaryPause)
|
||||
{
|
||||
source.Pause();
|
||||
chan->temporaryPause = true;
|
||||
}
|
||||
else if (!pause && source.state == cmixer::CM_STATE_PAUSED && chan->temporaryPause)
|
||||
{
|
||||
source.Play();
|
||||
chan->temporaryPause = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Init Sound Manager
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user