From Serge Lages, "Here is a patch to allow setting an audio volume with the AudioSink interface, I've also modified the ffmpeg plugin code to implement the ImageStream's setVolume method with its AudioSink."

This commit is contained in:
Robert Osfield
2010-01-18 12:43:02 +00:00
parent 5a37ed8a9f
commit 6f3966038f
5 changed files with 33 additions and 0 deletions

View File

@@ -112,6 +112,22 @@ void FFmpegDecoderAudio::close(bool waitForThreadToExit)
}
}
void FFmpegDecoderAudio::setVolume(float volume)
{
if (m_audio_sink.valid())
{
m_audio_sink->setVolume(volume);
}
}
float FFmpegDecoderAudio::getVolume() const
{
if (m_audio_sink.valid())
{
return m_audio_sink->getVolume();
}
return 0.0f;
}
void FFmpegDecoderAudio::run()
{

View File

@@ -34,6 +34,9 @@ public:
void pause(bool pause);
void close(bool waitForThreadToExit);
void setVolume(float volume);
float getVolume() const;
virtual void run();
void setAudioSink(osg::ref_ptr<osg::AudioSink> audio_sink);

View File

@@ -152,6 +152,15 @@ void FFmpegImageStream::quit(bool waitForThreadToExit)
m_decoder->close(waitForThreadToExit);
}
void FFmpegImageStream::setVolume(float volume)
{
m_decoder->audio_decoder().setVolume(volume);
}
float FFmpegImageStream::getVolume() const
{
return m_decoder->audio_decoder().getVolume();
}
double FFmpegImageStream::getLength() const
{

View File

@@ -33,6 +33,9 @@ namespace osgFFmpeg
virtual void seek(double time);
virtual void quit(bool waitForThreadToExit = true);
virtual void setVolume(float volume);
virtual float getVolume() const;
virtual double getLength() const;
virtual double getReferenceTime () const;
virtual double getFrameRate() const;