mirror of https://github.com/jorio/Pomme.git
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
|
// Pomme extension
|
||||||
Boolean Pomme_DecompressSoundResource(SndListHandle* sndHandlePtr, long* offsetToHeader);
|
Boolean Pomme_DecompressSoundResource(SndListHandle* sndHandlePtr, long* offsetToHeader);
|
||||||
|
|
||||||
// Pomme extension
|
|
||||||
void Pomme_PauseAllChannels(Boolean pause);
|
|
||||||
|
|
||||||
// Pomme extension
|
// Pomme extension
|
||||||
SndListHandle Pomme_SndLoadFileAsResource(short fRefNum);
|
SndListHandle Pomme_SndLoadFileAsResource(short fRefNum);
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,8 @@ enum ESndCmds
|
||||||
sizeCmd = 90, // obsolete command
|
sizeCmd = 90, // obsolete command
|
||||||
convertCmd = 91, // obsolete MACE command
|
convertCmd = 91, // obsolete MACE command
|
||||||
pommeSetLoopCmd = 0x7001,
|
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
|
// 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 loop;
|
||||||
bool interpolate;
|
bool interpolate;
|
||||||
|
|
||||||
bool temporaryPause = false;
|
|
||||||
|
|
||||||
ChannelImpl(SndChannelPtr _macChannel, bool transferMacChannelOwnership);
|
ChannelImpl(SndChannelPtr _macChannel, bool transferMacChannelOwnership);
|
||||||
|
|
||||||
~ChannelImpl();
|
~ChannelImpl();
|
||||||
|
|
|
@ -181,9 +181,6 @@ static void InstallSoundInChannel(SndChannelPtr chan, const Ptr sampledSoundHead
|
||||||
// issue pommeSetLoopCmd *after* bufferCmd/soundCmd.
|
// issue pommeSetLoopCmd *after* bufferCmd/soundCmd.
|
||||||
impl.ApplyParametersToSource(kApplyParameters_All & ~kApplyParameters_Loop);
|
impl.ApplyParametersToSource(kApplyParameters_All & ~kApplyParameters_Loop);
|
||||||
|
|
||||||
// Override systemwide audio pause.
|
|
||||||
impl.temporaryPause = false;
|
|
||||||
|
|
||||||
// Get it going!
|
// Get it going!
|
||||||
impl.source.Play();
|
impl.source.Play();
|
||||||
}
|
}
|
||||||
|
@ -266,6 +263,20 @@ OSErr SndDoImmediate(SndChannelPtr chan, const SndCommand* cmd)
|
||||||
impl.ApplyParametersToSource(kApplyParameters_Loop);
|
impl.ApplyParametersToSource(kApplyParameters_Loop);
|
||||||
break;
|
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:
|
default:
|
||||||
TODOMINOR2(cmd->cmd << "(" << cmd->param1 << "," << cmd->param2 << ")");
|
TODOMINOR2(cmd->cmd << "(" << cmd->param1 << "," << cmd->param2 << ")");
|
||||||
}
|
}
|
||||||
|
@ -369,27 +380,6 @@ NumVersion SndSoundManagerVersion()
|
||||||
return v;
|
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
|
// Init Sound Manager
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue