aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sound
diff options
context:
space:
mode:
authorMartin Kiewitz2010-05-03 11:58:45 +0000
committerMartin Kiewitz2010-05-03 11:58:45 +0000
commitdf679afe19901500a5e704d2b11df5a7b25c5436 (patch)
tree02abca519d049839f5c7e7525ddcb8cc281726b8 /engines/sci/sound
parent84cb07e98514bbe7ec8c3cc2c624fab92ccce2e4 (diff)
downloadscummvm-rg350-df679afe19901500a5e704d2b11df5a7b25c5436.tar.gz
scummvm-rg350-df679afe19901500a5e704d2b11df5a7b25c5436.tar.bz2
scummvm-rg350-df679afe19901500a5e704d2b11df5a7b25c5436.zip
SCI: calculate sampleLen for compressed audio (mp3/ogg/flac) as well
svn-id: r48903
Diffstat (limited to 'engines/sci/sound')
-rw-r--r--engines/sci/sound/audio.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp
index 40e6f2e03e..c3be46e51a 100644
--- a/engines/sci/sound/audio.cpp
+++ b/engines/sci/sound/audio.cpp
@@ -205,6 +205,7 @@ static byte *readSOLAudio(Common::SeekableReadStream *audioStream, uint32 &size,
}
Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32 volume, int *sampleLen) {
+ Audio::SeekableAudioStream *audioSeekStream = 0;
Audio::RewindableAudioStream *audioStream = 0;
uint32 size = 0;
byte *data = 0;
@@ -236,17 +237,17 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
switch (audioCompressionType) {
case MKID_BE('MP3 '):
#ifdef USE_MAD
- audioStream = Audio::makeMP3Stream(compressedStream, DisposeAfterUse::NO);
+ audioSeekStream = Audio::makeMP3Stream(compressedStream, DisposeAfterUse::NO);
#endif
break;
case MKID_BE('OGG '):
#ifdef USE_VORBIS
- audioStream = Audio::makeVorbisStream(compressedStream, DisposeAfterUse::NO);
+ audioSeekStream = Audio::makeVorbisStream(compressedStream, DisposeAfterUse::NO);
#endif
break;
case MKID_BE('FLAC'):
#ifdef USE_FLAC
- audioStream = Audio::makeFLACStream(compressedStream, DisposeAfterUse::NO);
+ audioSeekStream = Audio::makeFLACStream(compressedStream, DisposeAfterUse::NO);
#endif
break;
}
@@ -284,13 +285,20 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
}
if (data)
- audioStream = Audio::makeRawStream(data, size, _audioRate, flags);
+ audioSeekStream = Audio::makeRawStream(data, size, _audioRate, flags);
}
- if (audioStream) {
- *sampleLen = (flags & Audio::FLAG_16BITS ? size >> 1 : size) * 60 / _audioRate;
- return audioStream;
+ if (audioSeekStream) {
+ *sampleLen = (audioSeekStream->getLength().msecs() * 10000) / 166666; // we translate msecs to ticks
+ // Original code
+ //*sampleLen = (flags & Audio::FLAG_16BITS ? size >> 1 : size) * 60 / _audioRate;
+ audioStream = audioSeekStream;
+ } else {
+ // TODO: if possible make makeWAVStream() return seekableAudioStream as well, so we will be able to calculate sampleLen
+ *sampleLen = 0;
}
+ if (audioStream)
+ return audioStream;
return NULL;
}