Ticket #8902: queen-sound3.diff

File queen-sound3.diff, 2.7 KB (added by eriktorbjorn, 16 years ago)

Patch against current SVN

  • engines/queen/sound.cpp

     
    3535#include "queen/queen.h"
    3636#include "queen/resource.h"
    3737
     38#include "sound/audiostream.h"
    3839#include "sound/flac.h"
    3940#include "sound/mididrv.h"
    4041#include "sound/mp3.h"
     
    4546
    4647namespace Queen {
    4748
     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
     54class AudioStreamWrapper : public Audio::AudioStream {
     55protected:
     56        Audio::AudioStream *_stream;
     57
     58public:
     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
    4885class SilentSound : public PCSound {
    4986public:
    5087        SilentSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {}
     
    69106        void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
    70107                Common::MemoryReadStream *tmp = f->readStream(size);
    71108                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)));
    73110        }
    74111};
    75112#endif
     
    82119        void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
    83120                Common::MemoryReadStream *tmp = f->readStream(size);
    84121                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)));
    86123        }
    87124};
    88125#endif
     
    95132        void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
    96133                Common::MemoryReadStream *tmp = f->readStream(size);
    97134                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)));
    99136        }
    100137};
    101138#endif // #ifdef USE_FLAC