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:
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user