aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/sound.cpp
diff options
context:
space:
mode:
authorRobert Špalek2010-07-03 05:05:28 +0000
committerRobert Špalek2010-07-03 05:05:28 +0000
commit0fd3558986e7c0a0c08f3df18d6c8ce59da79110 (patch)
treedd18d8144545f10f3b7869130fc12a3adfada67f /engines/draci/sound.cpp
parent8d26e7c2d26c0a7c6521631bf861f8613a307dce (diff)
downloadscummvm-rg350-0fd3558986e7c0a0c08f3df18d6c8ce59da79110.tar.gz
scummvm-rg350-0fd3558986e7c0a0c08f3df18d6c8ce59da79110.tar.bz2
scummvm-rg350-0fd3558986e7c0a0c08f3df18d6c8ce59da79110.zip
Finish support of compressed dubbing
Now even the length of a compressed stream is measured precisely and the dubbing sounds exactly like the original. svn-id: r50618
Diffstat (limited to 'engines/draci/sound.cpp')
-rw-r--r--engines/draci/sound.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp
index 5000ceac74..c9244d7eac 100644
--- a/engines/draci/sound.cpp
+++ b/engines/draci/sound.cpp
@@ -285,11 +285,11 @@ SndHandle *Sound::getHandle() {
return NULL; // for compilers that don't support NORETURN
}
-void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
+uint Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
sndHandleType handleType, bool loop) {
if (!buffer._stream && !buffer._data) {
warning("Empty stream");
- return;
+ return 0;
}
// Create a new SeekableReadStream which will be automatically disposed
// after the sample stops playing. Do not dispose the original
@@ -335,22 +335,24 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffe
default:
error("Unsupported compression format %d", static_cast<int> (buffer._format));
delete stream;
- return;
+ return 0;
}
+ const uint length = reader->getLength().msecs();
const Audio::Mixer::SoundType soundType = (handleType == kVoiceHandle) ?
Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType;
Audio::AudioStream *audio_stream = Audio::makeLoopingAudioStream(reader, loop ? 0 : 1);
_mixer->playStream(soundType, handle, audio_stream, -1, volume);
+ return length;
}
-void Sound::playSound(const SoundSample *buffer, int volume, bool loop) {
+uint Sound::playSound(const SoundSample *buffer, int volume, bool loop) {
if (!buffer || _muteSound)
- return;
+ return 0;
SndHandle *handle = getHandle();
handle->type = kEffectHandle;
- playSoundBuffer(&handle->handle, *buffer, 2 * volume, handle->type, loop);
+ return playSoundBuffer(&handle->handle, *buffer, 2 * volume, handle->type, loop);
}
void Sound::pauseSound() {
@@ -374,13 +376,13 @@ void Sound::stopSound() {
}
}
-void Sound::playVoice(const SoundSample *buffer) {
+uint Sound::playVoice(const SoundSample *buffer) {
if (!buffer || _muteVoice)
- return;
+ return 0;
SndHandle *handle = getHandle();
handle->type = kVoiceHandle;
- playSoundBuffer(&handle->handle, *buffer, Audio::Mixer::kMaxChannelVolume, handle->type, false);
+ return playSoundBuffer(&handle->handle, *buffer, Audio::Mixer::kMaxChannelVolume, handle->type, false);
}
void Sound::pauseVoice() {