aboutsummaryrefslogtreecommitdiff
path: root/engines/pink/sound.cpp
diff options
context:
space:
mode:
authorwhiterandrek2018-04-02 08:57:56 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commit49d5ea28c023a43f7d1444b55ac8c06df9966128 (patch)
tree37db0a106b33970b934243f8c48adcb12c12255e /engines/pink/sound.cpp
parente48ac17f68ccd1b4432d9d6e15e811a88ea8daf4 (diff)
downloadscummvm-rg350-49d5ea28c023a43f7d1444b55ac8c06df9966128.tar.gz
scummvm-rg350-49d5ea28c023a43f7d1444b55ac8c06df9966128.tar.bz2
scummvm-rg350-49d5ea28c023a43f7d1444b55ac8c06df9966128.zip
PINK: added basic cursor implementation, fixed sequenceAudio restarting and skipping, fixed various mem leaks, hopefully fixed finding of transparent color index.
Diffstat (limited to 'engines/pink/sound.cpp')
-rw-r--r--engines/pink/sound.cpp35
1 files changed, 13 insertions, 22 deletions
diff --git a/engines/pink/sound.cpp b/engines/pink/sound.cpp
index b02275181e..fda91e548a 100644
--- a/engines/pink/sound.cpp
+++ b/engines/pink/sound.cpp
@@ -23,24 +23,24 @@
#include <audio/audiostream.h>
#include <audio/decoders/wave.h>
#include <audio/decoders/adpcm.h>
+#include <common/substream.h>
#include "sound.h"
namespace Pink {
-Sound::Sound(Audio::Mixer *mixer, Common::SeekableReadStream *stream)
- : _mixer(mixer)
+Sound::Sound(Audio::Mixer *mixer, Common::SafeSeekableSubReadStream *stream)
+ : _mixer(mixer), _fileStream(stream)
{
- load(stream);
+
}
Sound::~Sound() {
stop();
- delete _stream;
+ delete _fileStream;
}
bool Sound::isPlaying() {
return _mixer->isSoundHandleActive(_handle);
-
}
void Sound::pause() {
@@ -56,28 +56,19 @@ void Sound::stop() {
}
void Sound::play(Audio::Mixer::SoundType type, int volume, bool isLoop) {
+ // Vox files in pink have wave format.
+ // RIFF (little-endian) data, WAVE audio, Microsoft PCM, 8 bit, mono 22050 Hz
_mixer->stopHandle(_handle);
+ _fileStream->seek(0);
+ Audio::AudioStream *audioStream ;
+ Audio::SeekableAudioStream *wavStream = Audio::makeWAVStream(_fileStream, DisposeAfterUse::NO);
if (isLoop) {
- //bad impl?
- Audio::SeekableAudioStream *seekableStream = dynamic_cast<Audio::SeekableAudioStream*>(_stream);
- _stream = Audio::makeLoopingAudioStream(seekableStream, 0, 0, 0);
+ audioStream = Audio::makeLoopingAudioStream(wavStream, 0, 0, 0);
}
+ else audioStream = wavStream;
- _mixer->playStream(type, &_handle ,_stream, -1 , Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
-}
-
-bool Sound::load(Common::SeekableReadStream *stream) {
- // Vox files in pink have wave format.
- // RIFF (little-endian) data, WAVE audio, Microsoft PCM, 8 bit, mono 22050 Hz
-
- _stream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
-
- return isLoaded();
-}
-
-bool Sound::isLoaded() {
- return _stream != nullptr;
+ _mixer->playStream(type, &_handle , audioStream, -1 , Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES);
}
void Sound::setBalance(int8 balance) {