aboutsummaryrefslogtreecommitdiff
path: root/engines/pink/objects/actions/action_sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/pink/objects/actions/action_sound.cpp')
-rw-r--r--engines/pink/objects/actions/action_sound.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/engines/pink/objects/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp
index 42d279553b..44dfda45c7 100644
--- a/engines/pink/objects/actions/action_sound.cpp
+++ b/engines/pink/objects/actions/action_sound.cpp
@@ -35,6 +35,10 @@ ActionSound::ActionSound()
: _sound(nullptr), _isStopped(1)
{}
+ActionSound::~ActionSound(){
+ end();
+}
+
void ActionSound::deserialize(Archive &archive) {
Action::deserialize(archive);
archive >> _fileName;
@@ -66,14 +70,17 @@ void ActionSound::start(bool unk) {
}
void ActionSound::end() {
- debug("ActionSound %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
+ if (_sound) {
+ debug("ActionSound %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
- Director *director = _actor->getPage()->getGame()->getDirector();
- director->removeSound(this);
+ Director *director = _actor->getPage()->getGame()->getDirector();
+ director->removeSound(this);
+
+ _sound->stop();
- _sound->stop();
- delete _sound;
- _sound = nullptr;
+ delete _sound;
+ _sound = nullptr;
+ }
}
void ActionSound::update() {