aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/livingbooks.cpp24
-rw-r--r--engines/mohawk/livingbooks.h4
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 {