aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kiewitz2010-05-03 13:30:09 +0000
committerMartin Kiewitz2010-05-03 13:30:09 +0000
commitb4d35b327945830968b127aedaf34b6c3c976d4d (patch)
tree86c663e06c7e54d55e8c9eb2ac3a581d1f22328b
parent990f633b00a36af1ba797336441191d97b12fd0f (diff)
downloadscummvm-rg350-b4d35b327945830968b127aedaf34b6c3c976d4d.tar.gz
scummvm-rg350-b4d35b327945830968b127aedaf34b6c3c976d4d.tar.bz2
scummvm-rg350-b4d35b327945830968b127aedaf34b6c3c976d4d.zip
SCI: calculate sampleLen for WAVEs as well
svn-id: r48906
-rw-r--r--engines/sci/resource.cpp2
-rw-r--r--engines/sci/sound/audio.cpp17
2 files changed, 12 insertions, 7 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 9b9e56b6d7..20943c8f06 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -1263,6 +1263,8 @@ void ResourceManager::readWaveAudioPatches() {
ResourceSource *psrcPatch = new ResourceSource;
psrcPatch->source_type = kSourceWave;
psrcPatch->location_name = name;
+ psrcPatch->volume_number = 0;
+ psrcPatch->audioCompressionType = 0;
ResourceId resId = ResourceId(kResourceTypeAudio, number);
diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp
index c3be46e51a..bbbef0eaf1 100644
--- a/engines/sci/sound/audio.cpp
+++ b/engines/sci/sound/audio.cpp
@@ -212,6 +212,8 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
byte flags = 0;
Sci::Resource *audioRes;
+ *sampleLen = 0;
+
if (volume == 65535) {
audioRes = _resMan->findResource(ResourceId(kResourceTypeAudio, number), false);
if (!audioRes) {
@@ -251,10 +253,6 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
#endif
break;
}
-
- // Hopefully FLAC/OGG/MP3 are always 16-bit, otherwise we will get inaccuracies during sampleLen calculation
- // TODO: Check if this is true, otherwise implement support for getting 8-bit/16-bit from stream in common
- flags = Audio::FLAG_16BITS;
} else {
// Original source file
if (audioRes->_headerSize > 0) {
@@ -271,6 +269,14 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
if (memcmp(audioRes->data, "RIFF", 4) == 0) {
// WAVE detected
Common::MemoryReadStream *waveStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
+
+ // Calculate samplelen from WAVE header
+ int waveSize = 0, waveRate = 0;
+ byte waveFlags = 0;
+ Audio::loadWAVFromStream(*waveStream, waveSize, waveRate, waveFlags);
+ *sampleLen = (waveFlags & Audio::FLAG_16BITS ? waveSize >> 1 : waveSize) * 60 / waveRate;
+
+ waveStream->seek(0, SEEK_SET);
audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES);
}
}
@@ -293,9 +299,6 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
// 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;