From 235ab94ef3b964ddae6a817aa64706f362fc7c9b Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 25 Aug 2008 18:47:27 +0000 Subject: Refined the workaround for wrongly compressed audio. If the sample rate is given as 11025 Hz, it should be 11840 Hz. However, a fixed version of compress_queen won't necessarily produce files with that sample rate, since LAME will resample the sounds to 12000 Hz. I.e. we can only override the rate if it's exactly 11025. svn-id: r34169 --- engines/queen/sound.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'engines/queen/sound.cpp') diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp index 27cf1bf6a2..d4fed86bb7 100644 --- a/engines/queen/sound.cpp +++ b/engines/queen/sound.cpp @@ -54,10 +54,27 @@ namespace Queen { class AudioStreamWrapper : public Audio::AudioStream { protected: Audio::AudioStream *_stream; + int _rate; public: AudioStreamWrapper(Audio::AudioStream *stream) { _stream = stream; + + int rate = _stream->getRate(); + + // A file where the sample rate claims to be 11025 Hz is + // probably compressed with the old tool. We force the real + // sample rate, which is 11840 Hz. + // + // However, a file compressed with the newer tool is not + // guaranteed to have a sample rate of 11840 Hz. LAME will + // automatically resample it to 12000 Hz. So in all other + // cases, we use the rate from the file. + + if (rate == 11025) + _rate = 11840; + else + _rate = rate; } ~AudioStreamWrapper() { delete _stream; @@ -75,7 +92,7 @@ public: return _stream->endOfStream(); } int getRate() const { - return 11840; + return _rate; } int32 getTotalPlayTime() { return _stream->getTotalPlayTime(); -- cgit v1.2.3