1
0
Fork 0

Simplify Pause and Stop CD states

This commit is contained in:
krcroft 2020-02-05 23:28:24 -08:00
parent 7cac8e4c4f
commit 1cc88953de
No known key found for this signature in database
GPG key ID: 4AD3678F4A2C291C

View file

@ -573,45 +573,25 @@ bool CDROM_Interface_Image::PlayAudioSector(uint64_t start, uint64_t len)
bool CDROM_Interface_Image::PauseAudio(bool resume)
{
// Guard: Bail if our mixer channel hasn't been allocated
if (player.channel == nullptr) {
#ifdef DEBUG
LOG_MSG("CDROM: PauseAudio => game toggled before playing audio");
#endif
return false;
}
// Only switch states if needed
if (player.isPaused == resume) {
player.isPaused = !resume;
if (player.channel)
player.channel->Enable(resume);
player.isPaused = !resume;
#ifdef DEBUG
LOG_MSG("CDROM: PauseAudio => audio is now %s",
resume ? "unpaused" : "paused");
LOG_MSG("CDROM: PauseAudio => audio is now %s",
resume ? "unpaused" : "paused");
#endif
}
return true;
}
bool CDROM_Interface_Image::StopAudio(void)
{
// Guard: Bail if our mixer channel hasn't been allocated
if (player.channel == nullptr) {
#ifdef DEBUG
LOG_MSG("CDROM: StopAudio => game tried stopping the CD before playing audio");
#endif
return false;
}
// Only switch states if needed
if (player.isPlaying) {
player.isPlaying = false;
player.isPaused = false;
if (player.channel)
player.channel->Enable(false);
player.isPlaying = false;
player.isPaused = false;
#ifdef DEBUG
LOG_MSG("CDROM: StopAudio => stopped playback and halted the mixer");
#endif
}
return true;
}