Ticket #8902: queen-sound3.diff
File queen-sound3.diff, 2.7 KB (added by , 16 years ago) |
---|
-
engines/queen/sound.cpp
35 35 #include "queen/queen.h" 36 36 #include "queen/resource.h" 37 37 38 #include "sound/audiostream.h" 38 39 #include "sound/flac.h" 39 40 #include "sound/mididrv.h" 40 41 #include "sound/mp3.h" … … 45 46 46 47 namespace Queen { 47 48 49 // The sounds in the PC versions are all played at 11840 Hz. Unfortunately, we 50 // did not know that at the time, so there are plenty of compressed versions 51 // which claim that they should be played at 11025 Hz. This "wrapper" class 52 // works around that. 53 54 class AudioStreamWrapper : public Audio::AudioStream { 55 protected: 56 Audio::AudioStream *_stream; 57 58 public: 59 AudioStreamWrapper(Audio::AudioStream *stream) { 60 _stream = stream; 61 } 62 ~AudioStreamWrapper() { 63 delete _stream; 64 } 65 int readBuffer(int16 *buffer, const int numSamples) { 66 return _stream->readBuffer(buffer, numSamples); 67 } 68 bool isStereo() const { 69 return _stream->isStereo(); 70 } 71 bool endOfData() const { 72 return _stream->endOfData(); 73 } 74 bool endOfStream() { 75 return _stream->endOfStream(); 76 } 77 int getRate() const { 78 return 11840; 79 } 80 int32 getTotalPlayTime() { 81 return _stream->getTotalPlayTime(); 82 } 83 }; 84 48 85 class SilentSound : public PCSound { 49 86 public: 50 87 SilentSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {} … … 69 106 void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) { 70 107 Common::MemoryReadStream *tmp = f->readStream(size); 71 108 assert(tmp); 72 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeMP3Stream(tmp, true));109 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeMP3Stream(tmp, true))); 73 110 } 74 111 }; 75 112 #endif … … 82 119 void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) { 83 120 Common::MemoryReadStream *tmp = f->readStream(size); 84 121 assert(tmp); 85 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeVorbisStream(tmp, true));122 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeVorbisStream(tmp, true))); 86 123 } 87 124 }; 88 125 #endif … … 95 132 void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) { 96 133 Common::MemoryReadStream *tmp = f->readStream(size); 97 134 assert(tmp); 98 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeFlacStream(tmp, true));135 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeFlacStream(tmp, true))); 99 136 } 100 137 }; 101 138 #endif // #ifdef USE_FLAC