Skip to content

Commit

Permalink
ILLUSIONS: Implement voice pausing/unpausing
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoe123 committed May 16, 2018
1 parent 87869cb commit a70cf1d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
26 changes: 25 additions & 1 deletion engines/illusions/sound.cpp
Expand Up @@ -228,7 +228,7 @@ void MidiPlayer::endOfTrack() {

// VoicePlayer

VoicePlayer::VoicePlayer() {
VoicePlayer::VoicePlayer() : _wasPlaying(false), _isPaused(false) {
}

VoicePlayer::~VoicePlayer() {
Expand Down Expand Up @@ -266,6 +266,22 @@ void VoicePlayer::stop() {
_voiceName.clear();
}

void VoicePlayer::pause() {
if (!_isPaused) {
_isPaused = true;
_wasPlaying = isPlaying();
g_system->getMixer()->pauseHandle(_soundHandle, true);
}
}

void VoicePlayer::unpause() {
if (_isPaused) {
_isPaused = false;
if (_wasPlaying)
g_system->getMixer()->pauseHandle(_soundHandle, false);
}
}

bool VoicePlayer::isPlaying() {
return g_system->getMixer()->isSoundHandleActive(_soundHandle);
}
Expand Down Expand Up @@ -387,6 +403,14 @@ void SoundMan::stopVoice() {
_voicePlayer->stop();
}

void SoundMan::pauseVoice() {
_voicePlayer->pause();
}

void SoundMan::unpauseVoice() {
_voicePlayer->unpause();
}

bool SoundMan::isVoicePlaying() {
return _voicePlayer->isPlaying();
}
Expand Down
6 changes: 6 additions & 0 deletions engines/illusions/sound.h
Expand Up @@ -81,13 +81,17 @@ class VoicePlayer {
void stopCueing();
void start(int16 volume, int16 pan);
void stop();
void pause();
void unpause();
bool isPlaying();
bool isEnabled();
bool isCued();
protected:
Audio::SoundHandle _soundHandle;
Common::String _voiceName;
uint _voiceStatus;
bool _wasPlaying;
bool _isPaused;
};

class Sound {
Expand Down Expand Up @@ -125,6 +129,8 @@ class SoundMan {
void stopCueingVoice();
void startVoice(int16 volume, int16 pan);
void stopVoice();
void pauseVoice();
void unpauseVoice();
bool isVoicePlaying();
bool isVoiceEnabled();
bool isVoiceCued();
Expand Down
4 changes: 2 additions & 2 deletions engines/illusions/threads/talkthread.cpp
Expand Up @@ -282,7 +282,7 @@ void TalkThread::onPause() {
case 6:
case 7:
if (!(_flags & 4)) {
// TODO audvocPauseVoice();
_vm->_soundMan->pauseVoice();
}
if (!(_flags & 8)) {
_textDurationElapsed = getDurationElapsed(_textStartTime, _textEndTime);
Expand Down Expand Up @@ -313,7 +313,7 @@ void TalkThread::onUnpause() {
break;
case 6:
if (!(_flags & 4)) {
// TODO audvocUnpauseVoice();
_vm->_soundMan->unpauseVoice();
}
if (!(_flags & 8)) {
_textStartTime = getCurrentTime();
Expand Down
4 changes: 2 additions & 2 deletions engines/illusions/threads/talkthread_duckman.cpp
Expand Up @@ -206,7 +206,7 @@ int TalkThread_Duckman::onUpdate() {
void TalkThread_Duckman::onPause() {
if (_status == 5) {
if (!(_flags & 4)) {
// TODO audvocPauseVoice();
_vm->_soundMan->pauseVoice();
}
if (!(_flags & 8))
_textDurationElapsed = getDurationElapsed(_textStartTime, _textEndTime);
Expand All @@ -220,7 +220,7 @@ void TalkThread_Duckman::onUnpause() {
_vm->_soundMan->cueVoice((char*)talkEntry->_voiceName);
} else if (_status == 5) {
if (!(_flags & 4)) {
// TODO audvocUnpauseVoice();
_vm->_soundMan->unpauseVoice();
}
if (!(_flags & 8)) {
_textStartTime = getCurrentTime();
Expand Down

0 comments on commit a70cf1d

Please sign in to comment.