aboutsummaryrefslogtreecommitdiff
path: root/engines/pink/objects/actions
diff options
context:
space:
mode:
Diffstat (limited to 'engines/pink/objects/actions')
-rw-r--r--engines/pink/objects/actions/action_play_with_sfx.cpp23
-rw-r--r--engines/pink/objects/actions/action_play_with_sfx.h10
-rw-r--r--engines/pink/objects/actions/action_sound.cpp29
-rw-r--r--engines/pink/objects/actions/action_sound.h9
-rw-r--r--engines/pink/objects/actions/action_talk.cpp11
-rw-r--r--engines/pink/objects/actions/action_talk.h2
6 files changed, 22 insertions, 62 deletions
diff --git a/engines/pink/objects/actions/action_play_with_sfx.cpp b/engines/pink/objects/actions/action_play_with_sfx.cpp
index 056ce6e9b3..3805b8fe3c 100644
--- a/engines/pink/objects/actions/action_play_with_sfx.cpp
+++ b/engines/pink/objects/actions/action_play_with_sfx.cpp
@@ -78,13 +78,6 @@ void ActionPlayWithSfx::updateSound() {
}
}
-ActionSfx::ActionSfx()
- : _sound(nullptr) {}
-
-ActionSfx::~ActionSfx() {
- end();
-}
-
void ActionSfx::deserialize(Pink::Archive &archive) {
_frame = archive.readDWORD();
_volume = archive.readDWORD();
@@ -97,20 +90,8 @@ void ActionSfx::toConsole() {
}
void ActionSfx::play(Page *page) {
- if (!_sound)
- _sound = page->loadSound(_sfxName);
-
- if (!_sound->isPlaying())
- _sound->play(Audio::Mixer::kSFXSoundType, _volume, 0);
-}
-
-void ActionSfx::end() {
- delete _sound;
- _sound = nullptr;
-}
-
-uint32 ActionSfx::getFrame() {
- return _frame;
+ if (!_sound.isPlaying())
+ _sound.play(page->getResourceStream(_sfxName), Audio::Mixer::kSFXSoundType, _volume);
}
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_play_with_sfx.h b/engines/pink/objects/actions/action_play_with_sfx.h
index 7e8b0c8ed2..16a3cada99 100644
--- a/engines/pink/objects/actions/action_play_with_sfx.h
+++ b/engines/pink/objects/actions/action_play_with_sfx.h
@@ -24,6 +24,7 @@
#define PINK_ACTION_PLAY_WITH_SFX_H
#include "pink/objects/actions/action_play.h"
+#include "pink/sound.h"
namespace Pink {
@@ -49,26 +50,21 @@ private:
uint32 _isLoop;
};
-class Sound;
class Page;
class ActionSfx : public Object {
public:
- ActionSfx();
- ~ActionSfx() override;
-
void deserialize(Archive &archive) override;
void toConsole() override;
void play(Page *page);
- void end();
- uint32 getFrame();
+ uint32 getFrame() { return _frame; }
private:
- Sound *_sound;
Common::String _sfxName;
+ Sound _sound;
uint32 _volume;
uint32 _frame;
};
diff --git a/engines/pink/objects/actions/action_sound.cpp b/engines/pink/objects/actions/action_sound.cpp
index d63d57c7f3..e67717f04a 100644
--- a/engines/pink/objects/actions/action_sound.cpp
+++ b/engines/pink/objects/actions/action_sound.cpp
@@ -31,10 +31,7 @@
namespace Pink {
-ActionSound::ActionSound()
- : _sound(nullptr) {}
-
-ActionSound::~ActionSound(){
+ActionSound::~ActionSound() {
end();
}
@@ -52,16 +49,12 @@ void ActionSound::toConsole() {
}
void ActionSound::start() {
- assert(!_sound);
- _sound = _actor->getPage()->loadSound(_fileName);
-
- Audio::Mixer::SoundType soundType = _isBackground ? Audio::Mixer::kMusicSoundType
- : Audio::Mixer::kSpeechSoundType;
+ Audio::Mixer::SoundType soundType = _isBackground ? Audio::Mixer::kMusicSoundType : Audio::Mixer::kSFXSoundType;
Director *director = _actor->getPage()->getGame()->getDirector();
director->addSound(this);
- _sound->play(soundType, _volume, _isLoop);
+ _sound.play(_actor->getPage()->getResourceStream(_fileName), soundType, _volume, _isLoop);
if (_isLoop)
_actor->endAction();
@@ -69,25 +62,21 @@ void ActionSound::start() {
}
void ActionSound::end() {
- if (_sound) {
- debug("ActionSound %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str());
+ _sound.stop();
+ 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);
- delete _sound;
- _sound = nullptr;
- }
}
void ActionSound::update() {
- if (!_sound->isPlaying())
+ if (!_sound.isPlaying())
_actor->endAction();
}
void ActionSound::pause(bool paused) {
- if (_sound)
- _sound->pause(paused);
+ _sound.pause(paused);
}
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_sound.h b/engines/pink/objects/actions/action_sound.h
index c614951557..e502f34293 100644
--- a/engines/pink/objects/actions/action_sound.h
+++ b/engines/pink/objects/actions/action_sound.h
@@ -24,16 +24,13 @@
#define PINK_ACTION_SOUND_H
#include "pink/objects/actions/action.h"
+#include "pink/sound.h"
namespace Pink {
-class Sound;
-
class ActionSound : public Action {
public:
- ActionSound();
- ~ActionSound();
-
+ ~ActionSound() override;
void deserialize(Archive &archive) override;
void toConsole() override;
@@ -46,8 +43,8 @@ public:
void pause(bool paused) override;
private:
- Sound *_sound;
Common::String _fileName;
+ Sound _sound;
uint32 _volume;
bool _isLoop;
bool _isBackground;
diff --git a/engines/pink/objects/actions/action_talk.cpp b/engines/pink/objects/actions/action_talk.cpp
index c142dca0e6..f46afb312c 100644
--- a/engines/pink/objects/actions/action_talk.cpp
+++ b/engines/pink/objects/actions/action_talk.cpp
@@ -42,7 +42,7 @@ void ActionTalk::toConsole() {
void ActionTalk::update() {
ActionLoop::update();
- if (!_sound->isPlaying()) {
+ if (!_sound.isPlaying()) {
_decoder->stop();
_actor->endAction();
}
@@ -50,20 +50,17 @@ void ActionTalk::update() {
void ActionTalk::end() {
ActionPlay::end();
- delete _sound;
- _sound = nullptr;
+ _sound.stop();
}
void ActionTalk::pause(bool paused) {
ActionCEL::pause(paused);
- if (_sound)
- _sound->pause(paused);
+ _sound.pause(paused);
}
void ActionTalk::onStart() {
ActionPlay::onStart();
- _sound = _actor->getPage()->loadSound(_vox);
- _sound->play(Audio::Mixer::kSpeechSoundType, 100, 0);
+ _sound.play(_actor->getPage()->getResourceStream(_vox), Audio::Mixer::kSpeechSoundType);
}
} // End of namespace Pink
diff --git a/engines/pink/objects/actions/action_talk.h b/engines/pink/objects/actions/action_talk.h
index 672e0249a6..f29dc0f5fc 100644
--- a/engines/pink/objects/actions/action_talk.h
+++ b/engines/pink/objects/actions/action_talk.h
@@ -45,7 +45,7 @@ protected:
void onStart() override;
private:
- Sound *_sound;
+ Sound _sound;
Common::String _vox;
};