diff options
author | Filippos Karapetis | 2016-09-26 22:58:32 +0300 |
---|---|---|
committer | Filippos Karapetis | 2016-10-03 00:34:14 +0300 |
commit | 93a83a6b86116dabc058c4d799615d7e6c496a0c (patch) | |
tree | 44bace74fcc1a94bab2986c16954466906809995 /engines/chewy/video | |
parent | 8767b44fe0e216145e6f4218966b604e158f912e (diff) | |
download | scummvm-rg350-93a83a6b86116dabc058c4d799615d7e6c496a0c.tar.gz scummvm-rg350-93a83a6b86116dabc058c4d799615d7e6c496a0c.tar.bz2 scummvm-rg350-93a83a6b86116dabc058c4d799615d7e6c496a0c.zip |
CHEWY: Add an event manager, and get rid of g_engine
Diffstat (limited to 'engines/chewy/video')
-rw-r--r-- | engines/chewy/video/cfo_decoder.cpp | 24 | ||||
-rw-r--r-- | engines/chewy/video/cfo_decoder.h | 7 |
2 files changed, 18 insertions, 13 deletions
diff --git a/engines/chewy/video/cfo_decoder.cpp b/engines/chewy/video/cfo_decoder.cpp index 9ec11cc4a1..09d264afb1 100644 --- a/engines/chewy/video/cfo_decoder.cpp +++ b/engines/chewy/video/cfo_decoder.cpp @@ -69,11 +69,11 @@ bool CfoDecoder::loadStream(Common::SeekableReadStream *stream) { uint16 width = stream->readUint16LE(); uint16 height = stream->readUint16LE(); - addTrack(new CfoVideoTrack(stream, frameCount, width, height)); + addTrack(new CfoVideoTrack(stream, frameCount, width, height, _mixer)); return true; } -CfoDecoder::CfoVideoTrack::CfoVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height) : +CfoDecoder::CfoVideoTrack::CfoVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height, Audio::Mixer *mixer) : Video::FlicDecoder::FlicVideoTrack(stream, frameCount, width, height, true) { readHeader(); @@ -81,10 +81,12 @@ CfoDecoder::CfoVideoTrack::CfoVideoTrack(Common::SeekableReadStream *stream, uin _soundEffects[i] = nullptr; _soundEffectSize[i] = 0; } + + _mixer = mixer; } CfoDecoder::CfoVideoTrack::~CfoVideoTrack() { - g_engine->_mixer->stopAll(); + _mixer->stopAll(); for (int i = 0; i < MAX_SOUND_EFFECTS; i++) { delete[] _soundEffects[i]; @@ -222,17 +224,17 @@ void CfoDecoder::CfoVideoTrack::handleCustomFrame() { error("Unused chunk kChunkPlayPattern found"); break; case kChunkStopMusic: - g_engine->_mixer->stopHandle(_musicHandle); + _mixer->stopHandle(_musicHandle); break; case kChunkWaitMusicEnd: do { g_system->delayMillis(10); - } while (g_engine->_mixer->isSoundHandleActive(_musicHandle)); + } while (_mixer->isSoundHandleActive(_musicHandle)); break; case kChunkSetMusicVolume: volume = _fileStream->readUint16LE() * Audio::Mixer::kMaxChannelVolume / 63; - g_engine->_mixer->setVolumeForSoundType(Audio::Mixer::SoundType::kMusicSoundType, volume); + _mixer->setVolumeForSoundType(Audio::Mixer::SoundType::kMusicSoundType, volume); break; case kChunkSetLoopMode: error("Unused chunk kChunkSetLoopMode found"); @@ -254,20 +256,20 @@ void CfoDecoder::CfoVideoTrack::handleCustomFrame() { DisposeAfterUse::NO), (repeat == 0) ? 1 : repeat); - g_engine->_mixer->setVolumeForSoundType(Audio::Mixer::SoundType::kSFXSoundType, volume); - g_engine->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle[channel], stream); + _mixer->setVolumeForSoundType(Audio::Mixer::SoundType::kSFXSoundType, volume); + _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle[channel], stream); break; case kChunkSetSoundVolume: volume = _fileStream->readUint16LE() * Audio::Mixer::kMaxChannelVolume / 63; - g_engine->_mixer->setVolumeForSoundType(Audio::Mixer::SoundType::kSFXSoundType, volume); + _mixer->setVolumeForSoundType(Audio::Mixer::SoundType::kSFXSoundType, volume); break; case kChunkSetChannelVolume: channel = _fileStream->readUint16LE(); volume = _fileStream->readUint16LE() * Audio::Mixer::kMaxChannelVolume / 63; assert(channel < MAX_SOUND_EFFECTS); - g_engine->_mixer->setChannelVolume(_soundHandle[channel], volume); + _mixer->setChannelVolume(_soundHandle[channel], volume); break; case kChunkFreeSoundEffect: number = _fileStream->readUint16LE(); @@ -290,7 +292,7 @@ void CfoDecoder::CfoVideoTrack::handleCustomFrame() { balance = (_fileStream->readUint16LE() * 2) - 127; assert(channel < MAX_SOUND_EFFECTS); - g_engine->_mixer->setChannelBalance(_soundHandle[channel], balance); + _mixer->setChannelBalance(_soundHandle[channel], balance); break; case kChunkSetSpeed: error("Unused chunk kChunkSetSpeed found"); diff --git a/engines/chewy/video/cfo_decoder.h b/engines/chewy/video/cfo_decoder.h index 4396205607..b15b00e0b2 100644 --- a/engines/chewy/video/cfo_decoder.h +++ b/engines/chewy/video/cfo_decoder.h @@ -34,15 +34,17 @@ namespace Chewy { // A FLIC decoder, with a modified header and additional custom frames class CfoDecoder : public Video::FlicDecoder { public: - CfoDecoder() : Video::FlicDecoder() {} + CfoDecoder(Audio::Mixer *mixer) : Video::FlicDecoder() { _mixer = mixer; } virtual ~CfoDecoder() {} bool loadStream(Common::SeekableReadStream *stream); private: + Audio::Mixer *_mixer; + class CfoVideoTrack : public Video::FlicDecoder::FlicVideoTrack { public: - CfoVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height); + CfoVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height, Audio::Mixer *mixer); virtual ~CfoVideoTrack(); void readHeader(); @@ -56,6 +58,7 @@ private: void handleFrame(); void handleCustomFrame(); + Audio::Mixer *_mixer; Audio::SoundHandle _musicHandle; Audio::SoundHandle _soundHandle[MAX_SOUND_EFFECTS]; byte *_soundEffects[MAX_SOUND_EFFECTS]; |