diff options
author | Alyssa Milburn | 2010-11-30 15:35:22 +0000 |
---|---|---|
committer | Alyssa Milburn | 2010-11-30 15:35:22 +0000 |
commit | 6041fe117d28e065dd03c34fd71cef687319737b (patch) | |
tree | fa97a1fa1b9cb08f1b5e360a66b156688263e2ae | |
parent | b065e94d2cc5f3e19714209eae2d983d8ae26fb6 (diff) | |
download | scummvm-rg350-6041fe117d28e065dd03c34fd71cef687319737b.tar.gz scummvm-rg350-6041fe117d28e065dd03c34fd71cef687319737b.tar.bz2 scummvm-rg350-6041fe117d28e065dd03c34fd71cef687319737b.zip |
MOHAWK: some LBSoundItem fixes
svn-id: r54680
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 24 | ||||
-rw-r--r-- | engines/mohawk/livingbooks.h | 4 |
2 files changed, 25 insertions, 3 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index d51e06890e..fadc518e8d 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -1869,27 +1869,45 @@ void LBItem::setNextTime(uint16 min, uint16 max, uint32 start) { LBSoundItem::LBSoundItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) { debug(3, "new LBSoundItem"); + _running = false; } LBSoundItem::~LBSoundItem() { - _vm->_sound->stopSound(_resourceId); + if (_running) + _vm->_sound->stopSound(_resourceId); +} + +void LBSoundItem::update() { + if (_running && !_vm->_sound->isPlaying(_resourceId)) { + _running = false; + done(true); + } + + LBItem::update(); } bool LBSoundItem::togglePlaying(bool playing, bool restart) { if (!playing) return LBItem::togglePlaying(playing, restart); - _vm->_sound->stopSound(_resourceId); + if (_running) { + _running = false; + _vm->_sound->stopSound(_resourceId); + } if (_neverEnabled || !_enabled) return false; + _running = true; _vm->_sound->playSound(_resourceId, Audio::Mixer::kMaxChannelVolume, false); return true; } void LBSoundItem::stop() { - _vm->_sound->stopSound(_resourceId); + if (_running) { + _running = false; + _vm->_sound->stopSound(_resourceId); + } LBItem::stop(); } diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h index 288cee9b2b..ffdc3c14be 100644 --- a/engines/mohawk/livingbooks.h +++ b/engines/mohawk/livingbooks.h @@ -259,8 +259,12 @@ public: LBSoundItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect); ~LBSoundItem(); + void update(); bool togglePlaying(bool playing, bool restart); void stop(); + +protected: + bool _running; }; struct GroupEntry { |