diff options
-rw-r--r-- | engines/agos/animation.cpp | 12 | ||||
-rw-r--r-- | engines/agos/animation.h | 5 | ||||
-rw-r--r-- | engines/sci/video/robot_decoder.cpp | 12 | ||||
-rw-r--r-- | engines/sci/video/robot_decoder.h | 5 | ||||
-rw-r--r-- | engines/sword25/fmv/theora_decoder.cpp | 12 | ||||
-rw-r--r-- | engines/sword25/fmv/theora_decoder.h | 3 | ||||
-rw-r--r-- | video/avi_decoder.cpp | 12 | ||||
-rw-r--r-- | video/avi_decoder.h | 5 | ||||
-rw-r--r-- | video/bink_decoder.cpp | 12 | ||||
-rw-r--r-- | video/bink_decoder.h | 5 | ||||
-rw-r--r-- | video/coktel_decoder.cpp | 24 | ||||
-rw-r--r-- | video/coktel_decoder.h | 10 | ||||
-rw-r--r-- | video/psx_decoder.cpp | 12 | ||||
-rw-r--r-- | video/psx_decoder.h | 5 | ||||
-rw-r--r-- | video/qt_decoder.cpp | 14 | ||||
-rw-r--r-- | video/qt_decoder.h | 4 | ||||
-rw-r--r-- | video/smk_decoder.cpp | 12 | ||||
-rw-r--r-- | video/smk_decoder.h | 8 | ||||
-rw-r--r-- | video/video_decoder.cpp | 14 | ||||
-rw-r--r-- | video/video_decoder.h | 46 |
20 files changed, 221 insertions, 11 deletions
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: diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index 28fa712d4f..2ea7e8d90e 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -262,7 +262,7 @@ bool AviDecoder::loadStream(Common::SeekableReadStream *stream) { // Initialize the video stuff too _audStream = createAudioStream(); if (_audStream) - _mixer->playStream(_soundType, _audHandle, _audStream); + _mixer->playStream(_soundType, _audHandle, _audStream, -1, getVolume(), getBalance()); debug (0, "Frames = %d, Dimensions = %d x %d", _header.totalFrames, _header.width, _header.height); debug (0, "Frame Rate = %d", _vidsHeader.rate / _vidsHeader.scale); @@ -451,4 +451,14 @@ void AviDecoder::queueAudioBuffer(uint32 chunkSize) { } } +void AviDecoder::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(*_audHandle)) + g_system->getMixer()->setChannelVolume(*_audHandle, getVolume()); +} + +void AviDecoder::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(*_audHandle)) + g_system->getMixer()->setChannelBalance(*_audHandle, getBalance()); +} + } // End of namespace Video diff --git a/video/avi_decoder.h b/video/avi_decoder.h index edd08c42a0..fb4dae6711 100644 --- a/video/avi_decoder.h +++ b/video/avi_decoder.h @@ -202,6 +202,11 @@ public: bool hasDirtyPalette() const { return _dirtyPalette; } protected: + // VideoDecoder API + void updateVolume(); + void updateBalance(); + + // FixedRateVideoDecoder API Common::Rational getFrameRate() const { return Common::Rational(_vidsHeader.rate, _vidsHeader.scale); } private: diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp index 4738c3c8c0..538487f067 100644 --- a/video/bink_decoder.cpp +++ b/video/bink_decoder.cpp @@ -120,7 +120,7 @@ void BinkDecoder::startAudio() { const AudioTrack &audio = _audioTracks[_audioTrack]; _audioStream = Audio::makeQueuingAudioStream(audio.outSampleRate, audio.outChannels == 2); - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_audioHandle, _audioStream); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_audioHandle, _audioStream, -1, getVolume(), getBalance()); } // else no audio } @@ -1647,4 +1647,14 @@ void BinkDecoder::IDCTPut(DecodeContext &ctx, int16 *block) { } } +void BinkDecoder::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelVolume(_audioHandle, getVolume()); +} + +void BinkDecoder::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelBalance(_audioHandle, getBalance()); +} + } // End of namespace Video diff --git a/video/bink_decoder.h b/video/bink_decoder.h index f1eadc6f17..a5e1b10270 100644 --- a/video/bink_decoder.h +++ b/video/bink_decoder.h @@ -78,7 +78,12 @@ public: // Bink specific bool loadStream(Common::SeekableReadStream *stream, const Graphics::PixelFormat &format); + protected: + // VideoDecoder API + void updateVolume(); + void updateBalance(); + static const int kAudioChannelsMax = 2; static const int kAudioBlockSizeMax = (kAudioChannelsMax << 11); diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp index ae0c35cd76..be36874db4 100644 --- a/video/coktel_decoder.cpp +++ b/video/coktel_decoder.cpp @@ -1292,7 +1292,7 @@ void IMDDecoder::processFrame() { // Start the audio stream if necessary if (startSound && _soundEnabled) { _mixer->playStream(_soundType, &_audioHandle, _audioStream, - -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + -1, getVolume(), getBalance(), DisposeAfterUse::NO); _soundStage = kSoundPlaying; } @@ -1474,6 +1474,16 @@ Graphics::PixelFormat IMDDecoder::getPixelFormat() const { return Graphics::PixelFormat::createFormatCLUT8(); } +void IMDDecoder::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelVolume(_audioHandle, getVolume()); +} + +void IMDDecoder::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelBalance(_audioHandle, getBalance()); +} + VMDDecoder::File::File() { offset = 0; @@ -2161,7 +2171,7 @@ void VMDDecoder::processFrame() { if (startSound && _soundEnabled) { if (_hasSound && _audioStream) { _mixer->playStream(_soundType, &_audioHandle, _audioStream, - -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + -1, getVolume(), getBalance(), DisposeAfterUse::NO); _soundStage = kSoundPlaying; } else _soundStage = kSoundNone; @@ -2687,6 +2697,16 @@ bool VMDDecoder::isPaletted() const { return _isPaletted; } +void VMDDecoder::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelVolume(_audioHandle, getVolume()); +} + +void VMDDecoder::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelBalance(_audioHandle, getBalance()); +} + } // End of namespace Video #endif // VIDEO_COKTELDECODER_H diff --git a/video/coktel_decoder.h b/video/coktel_decoder.h index b99a44f332..68696d5ff3 100644 --- a/video/coktel_decoder.h +++ b/video/coktel_decoder.h @@ -284,6 +284,11 @@ public: Graphics::PixelFormat getPixelFormat() const; +protected: + // VideoDecoder API + void updateVolume(); + void updateBalance(); + private: enum Command { kCommandNextSound = 0xFF00, @@ -388,6 +393,11 @@ public: Graphics::PixelFormat getPixelFormat() const; +protected: + // VideoDecoder API + void updateVolume(); + void updateBalance(); + private: enum PartType { kPartTypeSeparator = 0, diff --git a/video/psx_decoder.cpp b/video/psx_decoder.cpp index 74f740f614..df91a2badd 100644 --- a/video/psx_decoder.cpp +++ b/video/psx_decoder.cpp @@ -385,7 +385,7 @@ void PSXStreamDecoder::queueAudioFromSector(Common::SeekableReadStream *sector) uint rate = (format & (1 << 2)) ? 18900 : 37800; _audStream = Audio::makeQueuingAudioStream(rate, stereo); - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_audHandle, _audStream); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_audHandle, _audStream, -1, getVolume(), getBalance()); } sector->seek(24); @@ -694,4 +694,14 @@ void PSXStreamDecoder::decodeBlock(Common::BitStream *bits, byte *block, int pit } } +void PSXStreamDecoder::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(_audHandle)) + g_system->getMixer()->setChannelVolume(_audHandle, getVolume()); +} + +void PSXStreamDecoder::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(_audHandle)) + g_system->getMixer()->setChannelBalance(_audHandle, getBalance()); +} + } // End of namespace Video diff --git a/video/psx_decoder.h b/video/psx_decoder.h index 3695cb0f42..4364ec4bbb 100644 --- a/video/psx_decoder.h +++ b/video/psx_decoder.h @@ -81,6 +81,11 @@ public: Graphics::PixelFormat getPixelFormat() const { return _surface->format; } bool endOfVideo() const { return _stream->pos() >= _stream->size(); } +protected: + // VideoDecoder API + void updateVolume(); + void updateBalance(); + private: void initCommon(); Common::SeekableReadStream *_stream; diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp index 585f5927a1..aba545abc0 100644 --- a/video/qt_decoder.cpp +++ b/video/qt_decoder.cpp @@ -97,7 +97,7 @@ void QuickTimeDecoder::startAudio() { updateAudioBuffer(); for (uint32 i = 0; i < _audioTracks.size(); i++) { - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_audioHandles[i], _audioTracks[i], -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_audioHandles[i], _audioTracks[i], -1, getVolume(), getBalance(), DisposeAfterUse::NO); // Pause the audio again if we're still paused if (isPaused()) @@ -236,6 +236,18 @@ bool QuickTimeDecoder::loadStream(Common::SeekableReadStream *stream) { return true; } +void QuickTimeDecoder::updateVolume() { + for (uint32 i = 0; i < _audioHandles.size(); i++) + if (g_system->getMixer()->isSoundHandleActive(_audioHandles[i])) + g_system->getMixer()->setChannelVolume(_audioHandles[i], getVolume()); +} + +void QuickTimeDecoder::updateBalance() { + for (uint32 i = 0; i < _audioHandles.size(); i++) + if (g_system->getMixer()->isSoundHandleActive(_audioHandles[i])) + g_system->getMixer()->setChannelBalance(_audioHandles[i], getBalance()); +} + void QuickTimeDecoder::init() { Audio::QuickTimeAudioDecoder::init(); diff --git a/video/qt_decoder.h b/video/qt_decoder.h index 1f614df18b..ce32562d64 100644 --- a/video/qt_decoder.h +++ b/video/qt_decoder.h @@ -133,6 +133,10 @@ protected: Common::QuickTimeParser::SampleDesc *readSampleDesc(Track *track, uint32 format); + // VideoDecoder API + void updateVolume(); + void updateBalance(); + private: void init(); diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp index 439fe9027d..359f4cb9bd 100644 --- a/video/smk_decoder.cpp +++ b/video/smk_decoder.cpp @@ -667,7 +667,7 @@ void SmackerDecoder::handleAudioTrack(byte track, uint32 chunkSize, uint32 unpac } if (!_audioStarted) { - _mixer->playStream(_soundType, &_audioHandle, _audioStream, -1, 255); + _mixer->playStream(_soundType, &_audioHandle, _audioStream, -1, getVolume(), getBalance()); _audioStarted = true; } } else { @@ -819,4 +819,14 @@ void SmackerDecoder::unpackPalette() { free(chunk); } +void SmackerDecoder::updateVolume() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelVolume(_audioHandle, getVolume()); +} + +void SmackerDecoder::updateBalance() { + if (g_system->getMixer()->isSoundHandleActive(_audioHandle)) + g_system->getMixer()->setChannelBalance(_audioHandle, getBalance()); +} + } // End of namespace Video diff --git a/video/smk_decoder.h b/video/smk_decoder.h index fd5d658bdd..516882e7c8 100644 --- a/video/smk_decoder.h +++ b/video/smk_decoder.h @@ -77,9 +77,15 @@ public: virtual void handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize); protected: - Common::Rational getFrameRate() const { return _frameRate; } Common::SeekableReadStream *_fileStream; + // VideoDecoder API + void updateVolume(); + void updateBalance(); + + // FixedRateVideoDecoder API + Common::Rational getFrameRate() const { return _frameRate; } + protected: void unpackPalette(); // Possible runs of blocks diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index ae82a3374c..44d7917652 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -22,6 +22,8 @@ #include "video/video_decoder.h" +#include "audio/mixer.h" // for kMaxChannelVolume + #include "common/rational.h" #include "common/file.h" #include "common/system.h" @@ -61,6 +63,8 @@ void VideoDecoder::reset() { _curFrame = -1; _startTime = 0; _pauseLevel = 0; + _audioVolume = Audio::Mixer::kMaxChannelVolume; + _audioBalance = 0; } bool VideoDecoder::endOfVideo() const { @@ -94,6 +98,16 @@ void VideoDecoder::resetPauseStartTime() { _pauseStartTime = g_system->getMillis(); } +void VideoDecoder::setVolume(byte volume) { + _audioVolume = volume; + updateVolume(); +} + +void VideoDecoder::setBalance(int8 balance) { + _audioBalance = balance; + updateBalance(); +} + uint32 FixedRateVideoDecoder::getTimeToNextFrame() const { if (endOfVideo() || _curFrame < 0) return 0; diff --git a/video/video_decoder.h b/video/video_decoder.h index 2b99a2b1bf..3bb75ade09 100644 --- a/video/video_decoder.h +++ b/video/video_decoder.h @@ -185,6 +185,40 @@ public: */ bool isPaused() const { return _pauseLevel != 0; } + /** + * Get the current volume at which the audio in the video is being played + * @return the current volume at which the audio in the video is being played + */ + virtual byte getVolume() const { return _audioVolume; } + + /** + * Set the volume at which the audio in the video should be played. + * This setting remains until reset() is called (which may be called + * from loadStream() or close()). The default volume is the maximum. + * + * @note This function calls updateVolume() by default. + * + * @param volume The volume at which to play the audio in the video + */ + virtual void setVolume(byte volume); + + /** + * Get the current balance at which the audio in the video is being played + * @return the current balance at which the audio in the video is being played + */ + virtual int8 getBalance() const { return _audioBalance; } + + /** + * Set the balance at which the audio in the video should be played. + * This setting remains until reset() is called (which may be called + * from loadStream() or close()). The default balance is 0. + * + * @note This function calls updateBalance() by default. + * + * @param balance The balance at which to play the audio in the video + */ + virtual void setBalance(int8 balance); + protected: /** * Resets _curFrame and _startTime. Should be called from every close() function. @@ -207,12 +241,24 @@ protected: */ void resetPauseStartTime(); + /** + * Update currently playing audio tracks with the new volume setting + */ + virtual void updateVolume() {} + + /** + * Update currently playing audio tracks with the new balance setting + */ + virtual void updateBalance() {} + int32 _curFrame; int32 _startTime; private: uint32 _pauseLevel; uint32 _pauseStartTime; + byte _audioVolume; + int8 _audioBalance; }; /** |