From 10f7e805c20c164a7b3a20832237341136165e28 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 27 May 2012 21:18:32 -0400 Subject: VIDEO: Add volume/balance control to VideoDecoder --- engines/agos/animation.cpp | 12 +++++++++++- engines/agos/animation.h | 5 +++++ engines/sci/video/robot_decoder.cpp | 12 +++++++++++- engines/sci/video/robot_decoder.h | 5 +++++ engines/sword25/fmv/theora_decoder.cpp | 12 +++++++++++- engines/sword25/fmv/theora_decoder.h | 3 +++ 6 files changed, 46 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index 29d1b36e19..10c01741ae 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -333,7 +333,7 @@ void MoviePlayerDXA::startSound() { if (_bgSoundStream != NULL) { _vm->_mixer->stopHandle(_bgSound); - _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream); + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream, -1, getVolume(), getBalance()); } } @@ -399,6 +399,16 @@ bool MoviePlayerDXA::processFrame() { return false; } +void MoviePlayerDXA::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(_bgSound)) + g_system->getMixer()->setChannelVolume(_bgSound, getVolume()); +} + +void MoviePlayerDXA::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(_bgSound)) + g_system->getMixer()->setChannelBalance(_bgSound, getBalance()); +} + /////////////////////////////////////////////////////////////////////////////// // Movie player for Smacker movies /////////////////////////////////////////////////////////////////////////////// diff --git a/engines/agos/animation.h b/engines/agos/animation.h index 11936aa338..d1ff074b03 100644 --- a/engines/agos/animation.h +++ b/engines/agos/animation.h @@ -83,6 +83,11 @@ public: void nextFrame(); virtual void stopVideo(); +protected: + // VideoDecoder API + void updateVolume(); + void updateBalance(); + private: void handleNextFrame(); bool processFrame(); diff --git a/engines/sci/video/robot_decoder.cpp b/engines/sci/video/robot_decoder.cpp index 77f45e0788..95b3c2abc1 100644 --- a/engines/sci/video/robot_decoder.cpp +++ b/engines/sci/video/robot_decoder.cpp @@ -116,7 +116,7 @@ bool RobotDecoder::loadStream(Common::SeekableReadStream *stream) { if (_header.hasSound) { _audioStream = Audio::makeQueuingAudioStream(11025, false); - _mixer->playStream(Audio::Mixer::kMusicSoundType, &_audioHandle, _audioStream); + _mixer->playStream(Audio::Mixer::kMusicSoundType, &_audioHandle, _audioStream, -1, getVolume(), getBalance()); } readPaletteChunk(_header.paletteDataSize); @@ -361,6 +361,16 @@ void RobotDecoder::close() { reset(); } +void RobotDecoder::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelVolume(_audioHandle, getVolume()); +} + +void RobotDecoder::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelBalance(_audioHandle, getBalance()); +} + #endif } // End of namespace Sci diff --git a/engines/sci/video/robot_decoder.h b/engines/sci/video/robot_decoder.h index 3f93582418..e9cefe7d91 100644 --- a/engines/sci/video/robot_decoder.h +++ b/engines/sci/video/robot_decoder.h @@ -71,6 +71,11 @@ public: Common::Point getPos() const { return _pos; } protected: + // VideoDecoder API + void updateVolume(); + void updateBalance(); + + // FixedRateVideoDecoder API Common::Rational getFrameRate() const { return Common::Rational(60, 10); } private: diff --git a/engines/sword25/fmv/theora_decoder.cpp b/engines/sword25/fmv/theora_decoder.cpp index 082c569fda..d38f5a26cf 100644 --- a/engines/sword25/fmv/theora_decoder.cpp +++ b/engines/sword25/fmv/theora_decoder.cpp @@ -289,7 +289,7 @@ bool TheoraDecoder::loadStream(Common::SeekableReadStream *stream) { } if (_audStream) - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _audHandle, _audStream); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _audHandle, _audStream, -1, getVolume(), getBalance()); } else { // tear down the partial vorbis setup vorbis_info_clear(&_vorbisInfo); @@ -550,6 +550,16 @@ void TheoraDecoder::translateYUVtoRGBA(th_ycbcr_buffer &YUVBuffer) { Graphics::convertYUV420ToRGB(&_surface, YUVBuffer[kBufferY].data, YUVBuffer[kBufferU].data, YUVBuffer[kBufferV].data, YUVBuffer[kBufferY].width, YUVBuffer[kBufferY].height, YUVBuffer[kBufferY].stride, YUVBuffer[kBufferU].stride); } +void TheoraDecoder::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(*_audHandle)) + g_system->getMixer()->setChannelVolume(*_audHandle, getVolume()); +} + +void TheoraDecoder::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(*_audHandle)) + g_system->getMixer()->setChannelBalance(*_audHandle, getBalance()); +} + } // End of namespace Sword25 #endif diff --git a/engines/sword25/fmv/theora_decoder.h b/engines/sword25/fmv/theora_decoder.h index 4fd7cc0f03..739040024f 100644 --- a/engines/sword25/fmv/theora_decoder.h +++ b/engines/sword25/fmv/theora_decoder.h @@ -87,6 +87,9 @@ public: bool endOfVideo() const; protected: + // VideoDecoder API + void updateVolume(); + void updateBalance(); void pauseVideoIntern(bool pause); private: -- cgit v1.2.3