Permalink
Browse files

VIDEO: Add volume/balance control to VideoDecoder

  • Loading branch information...
1 parent 792d1e6 commit 10f7e805c20c164a7b3a20832237341136165e28 @clone2727 clone2727 committed May 28, 2012
View
@@ -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
///////////////////////////////////////////////////////////////////////////////
View
@@ -83,6 +83,11 @@ class MoviePlayerDXA : public MoviePlayer, Video::DXADecoder {
void nextFrame();
virtual void stopVideo();
+protected:
+ // VideoDecoder API
+ void updateVolume();
+ void updateBalance();
+
private:
void handleNextFrame();
bool processFrame();
@@ -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
@@ -71,6 +71,11 @@ class RobotDecoder : public Video::FixedRateVideoDecoder {
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:
@@ -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
@@ -87,6 +87,9 @@ class TheoraDecoder : public Video::VideoDecoder {
bool endOfVideo() const;
protected:
+ // VideoDecoder API
+ void updateVolume();
+ void updateBalance();
void pauseVideoIntern(bool pause);
private:
View
@@ -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
View
@@ -202,6 +202,11 @@ class AviDecoder : public FixedRateVideoDecoder {
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:
View
@@ -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
View
@@ -78,7 +78,12 @@ class BinkDecoder : public FixedRateVideoDecoder {
// 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);
View
@@ -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
View
@@ -284,6 +284,11 @@ class IMDDecoder : public CoktelDecoder {
Graphics::PixelFormat getPixelFormat() const;
+protected:
+ // VideoDecoder API
+ void updateVolume();
+ void updateBalance();
+
private:
enum Command {
kCommandNextSound = 0xFF00,
@@ -388,6 +393,11 @@ class VMDDecoder : public CoktelDecoder {
Graphics::PixelFormat getPixelFormat() const;
+protected:
+ // VideoDecoder API
+ void updateVolume();
+ void updateBalance();
+
private:
enum PartType {
kPartTypeSeparator = 0,
View
@@ -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
View
@@ -81,6 +81,11 @@ class PSXStreamDecoder : public VideoDecoder {
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;
View
@@ -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();
View
@@ -133,6 +133,10 @@ class QuickTimeDecoder : public SeekableVideoDecoder, public Audio::QuickTimeAud
Common::QuickTimeParser::SampleDesc *readSampleDesc(Track *track, uint32 format);
+ // VideoDecoder API
+ void updateVolume();
+ void updateBalance();
+
private:
void init();
View
@@ -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
View
@@ -77,9 +77,15 @@ class SmackerDecoder : public FixedRateVideoDecoder {
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
Oops, something went wrong.

0 comments on commit 10f7e80

Please sign in to comment.