Added support for setting volume in xine plugin, manual adjustment of volume
in osgmove example, and clamping to 0 to 1.0 range in quicktime plugin
This commit is contained in:
parent
6f47d924d6
commit
2e2ddba49e
@ -54,7 +54,7 @@ public:
|
||||
|
||||
virtual void getUsage(osg::ApplicationUsage& usage) const;
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::ImageStream> > ImageStreamList;
|
||||
typedef std::vector< osg::observer_ptr<osg::ImageStream> > ImageStreamList;
|
||||
|
||||
protected:
|
||||
|
||||
@ -203,7 +203,7 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
++itr)
|
||||
{
|
||||
std::cout<<"Play"<<std::endl;
|
||||
(*itr)->play();
|
||||
(*itr)->play();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -218,6 +218,28 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='+')
|
||||
{
|
||||
for(ImageStreamList::iterator itr=_imageStreamList.begin();
|
||||
itr!=_imageStreamList.end();
|
||||
++itr)
|
||||
{
|
||||
osg::ImageStream* movie = itr->get();
|
||||
movie->setVolume(movie->getVolume()+0.1f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='-')
|
||||
{
|
||||
for(ImageStreamList::iterator itr=_imageStreamList.begin();
|
||||
itr!=_imageStreamList.end();
|
||||
++itr)
|
||||
{
|
||||
osg::ImageStream* movie = itr->get();
|
||||
movie->setVolume(movie->getVolume()-0.1f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='r')
|
||||
{
|
||||
for(ImageStreamList::iterator itr=_imageStreamList.begin();
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "QuicktimeImageStream.h"
|
||||
#include <osg/Notify>
|
||||
#include <osg/Timer>
|
||||
#include <osg/Math>
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Thread>
|
||||
@ -132,7 +133,7 @@ void QuicktimeImageStream::quit(bool wiatForThreadToExit)
|
||||
|
||||
void QuicktimeImageStream::setVolume(float volume)
|
||||
{
|
||||
_movieData->setVolume(volume);
|
||||
_movieData->setVolume(osg::minimum(osg::maximum(volume,0.0f),1.0f));
|
||||
}
|
||||
|
||||
// Get and Set the playback volume of the stream.
|
||||
|
@ -30,7 +30,8 @@ class XineImageStream : public osg::ImageStream
|
||||
_visual(0),
|
||||
_stream(0),
|
||||
_event_queue(0),
|
||||
_ready(false)
|
||||
_ready(false),
|
||||
_volume(-1.0)
|
||||
{
|
||||
setOrigin(osg::Image::TOP_LEFT);
|
||||
}
|
||||
@ -41,6 +42,21 @@ class XineImageStream : public osg::ImageStream
|
||||
|
||||
META_Object(osgXine,XineImageStream);
|
||||
|
||||
void setVolume(float volume)
|
||||
{
|
||||
_volume = osg::minimum(osg::maximum(volume,0.0f),1.0f);
|
||||
if (_stream)
|
||||
{
|
||||
xine_set_param(_stream, XINE_PARAM_AUDIO_VOLUME, static_cast<int>(_volume*100.0f));
|
||||
osg::notify(osg::NOTICE)<<"Setting volume "<<_volume<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
float getVolume() const
|
||||
{
|
||||
return _volume;
|
||||
}
|
||||
|
||||
bool open(xine_t* xine, const std::string& filename)
|
||||
{
|
||||
if (filename==getFileName()) return true;
|
||||
@ -70,6 +86,18 @@ class XineImageStream : public osg::ImageStream
|
||||
|
||||
// set up stream
|
||||
_stream = xine_stream_new(_xine, _ao, _vo);
|
||||
|
||||
if (_stream)
|
||||
{
|
||||
if (_volume < 0.0)
|
||||
{
|
||||
_volume = static_cast<float>(xine_get_param(_stream, XINE_PARAM_AUDIO_VOLUME))/100.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
setVolume(_volume);
|
||||
}
|
||||
}
|
||||
|
||||
_event_queue = xine_event_new_queue(_stream);
|
||||
xine_event_create_listener_thread(_event_queue, event_listener, this);
|
||||
@ -200,6 +228,7 @@ class XineImageStream : public osg::ImageStream
|
||||
xine_stream_t* _stream;
|
||||
xine_event_queue_t* _event_queue;
|
||||
bool _ready;
|
||||
float _volume;
|
||||
|
||||
protected:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user