Ticket #3590: queen-sound2.diff

File queen-sound2.diff, 2.4 KB (added by eriktorbjorn, 12 years ago)

Alternative 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
     49class AudioStreamWrapper : public Audio::AudioStream {
     50protected:
     51        Audio::AudioStream *_stream;
     52
     53public:
     54        AudioStreamWrapper(Audio::AudioStream *stream) {
     55                _stream = stream;
     56        }
     57        ~AudioStreamWrapper() {
     58                delete _stream;
     59        }
     60        int readBuffer(int16 *buffer, const int numSamples) {
     61                return _stream->readBuffer(buffer, numSamples);
     62        }
     63        bool isStereo() const {
     64                return _stream->isStereo();
     65        }
     66        bool endOfData() const {
     67                return _stream->endOfData();
     68        }
     69        bool endOfStream() {
     70                return _stream->endOfStream();
     71        }
     72        int getRate() const {
     73                return 11840;
     74        }
     75        int32 getTotalPlayTime() {
     76                return _stream->getTotalPlayTime();
     77        }
     78};
     79
    4880class SilentSound : public PCSound {
    4981public:
    5082        SilentSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {}
     
    69101        void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
    70102                Common::MemoryReadStream *tmp = f->readStream(size);
    71103                assert(tmp);
    72                 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeMP3Stream(tmp, true));
     104                _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeMP3Stream(tmp, false)));
    73105        }
    74106};
    75107#endif
     
    82114        void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
    83115                Common::MemoryReadStream *tmp = f->readStream(size);
    84116                assert(tmp);
    85                 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeVorbisStream(tmp, true));
     117                _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeVorbisStream(tmp, false)));
    86118        }
    87119};
    88120#endif
     
    95127        void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
    96128                Common::MemoryReadStream *tmp = f->readStream(size);
    97129                assert(tmp);
    98                 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeFlacStream(tmp, true));
     130                _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeFlacStream(tmp, false)));
    99131        }
    100132};
    101133#endif // #ifdef USE_FLAC