Added looping
This commit is contained in:
@@ -23,7 +23,14 @@ namespace osgXine
|
||||
class XineImageStream : public osg::ImageStream
|
||||
{
|
||||
public:
|
||||
XineImageStream() {}
|
||||
XineImageStream():
|
||||
_xine(0),
|
||||
_vo(0),
|
||||
_ao(0),
|
||||
_visual(0),
|
||||
_stream(0),
|
||||
_event_queue(0),
|
||||
_ready(false) {}
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
||||
XineImageStream(const XineImageStream& image,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
||||
@@ -61,11 +68,11 @@ class XineImageStream : public osg::ImageStream
|
||||
// set up stream
|
||||
_stream = xine_stream_new(_xine, _ao, _vo);
|
||||
|
||||
// set up queue
|
||||
// xine_event_queue_t* queue = xine_event_new_queue(stream);
|
||||
_event_queue = xine_event_new_queue(_stream);
|
||||
xine_event_create_listener_thread(_event_queue, event_listener, this);
|
||||
|
||||
int result = xine_open(_stream, filename.c_str());
|
||||
osg::notify(osg::NOTICE)<<"XineImageStream::open - xine_open"<<result<<std::endl;
|
||||
osg::notify(osg::INFO)<<"XineImageStream::open - xine_open"<<result<<std::endl;
|
||||
|
||||
_ready = false;
|
||||
|
||||
@@ -85,11 +92,11 @@ class XineImageStream : public osg::ImageStream
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"XineImageStream::play()"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"XineImageStream::play()"<<std::endl;
|
||||
xine_play(_stream, 0, 0);
|
||||
while (!_ready)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"waiting..."<<std::endl;
|
||||
osg::notify(osg::INFO)<<" waiting..."<<std::endl;
|
||||
usleep(10000);
|
||||
}
|
||||
}
|
||||
@@ -166,7 +173,7 @@ class XineImageStream : public osg::ImageStream
|
||||
|
||||
rgbout_visual_info_t* _visual;
|
||||
xine_stream_t* _stream;
|
||||
|
||||
xine_event_queue_t* _event_queue;
|
||||
bool _ready;
|
||||
|
||||
protected:
|
||||
@@ -174,41 +181,70 @@ class XineImageStream : public osg::ImageStream
|
||||
|
||||
virtual ~XineImageStream()
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Killing XineImageStream"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"Killing XineImageStream"<<std::endl;
|
||||
close();
|
||||
osg::notify(osg::NOTICE)<<"Closed XineImageStream"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"Closed XineImageStream"<<std::endl;
|
||||
}
|
||||
|
||||
void close()
|
||||
{
|
||||
|
||||
osg::notify(osg::INFO)<<"XineImageStream::close()"<<std::endl;
|
||||
|
||||
if (_stream)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Closing stream"<<std::endl;
|
||||
osg::notify(osg::INFO)<<" Closing stream"<<std::endl;
|
||||
|
||||
xine_close(_stream);
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Disposing stream"<<std::endl;
|
||||
osg::notify(osg::INFO)<<" Disposing stream"<<std::endl;
|
||||
|
||||
xine_dispose(_stream);
|
||||
_stream = 0;
|
||||
}
|
||||
|
||||
|
||||
if (_event_queue)
|
||||
{
|
||||
_event_queue = 0;
|
||||
}
|
||||
|
||||
if (_ao)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Closing audio driver"<<std::endl;
|
||||
osg::notify(osg::INFO)<<" Closing audio driver"<<std::endl;
|
||||
|
||||
xine_close_audio_driver(_xine, _ao);
|
||||
|
||||
_ao = 0;
|
||||
}
|
||||
|
||||
if (_vo)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Closing video driver"<<std::endl;
|
||||
osg::notify(osg::INFO)<<" Closing video driver"<<std::endl;
|
||||
|
||||
xine_close_video_driver(_xine, _vo);
|
||||
|
||||
_vo = 0;
|
||||
}
|
||||
|
||||
osg::notify(osg::INFO)<<"closed XineImageStream "<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void event_listener(void *user_data, const xine_event_t *event)
|
||||
{
|
||||
XineImageStream* xis = reinterpret_cast<XineImageStream*>(user_data);
|
||||
switch(event->type)
|
||||
{
|
||||
case XINE_EVENT_UI_PLAYBACK_FINISHED:
|
||||
if (xis->getLoopingMode()==LOOPING)
|
||||
{
|
||||
//rewind();
|
||||
xine_play(xis->_stream, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
@@ -238,7 +274,7 @@ class ReaderWriterXine : public osgDB::ReaderWriter
|
||||
|
||||
virtual ~ReaderWriterXine()
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Killing Xine"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"~ReaderWriterXine()"<<std::endl;
|
||||
|
||||
if (_xine) xine_exit(_xine);
|
||||
_xine = NULL;
|
||||
@@ -271,7 +307,7 @@ class ReaderWriterXine : public osgDB::ReaderWriter
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
osg::notify(osg::NOTICE)<<"ReaderWriterXine::readImage "<< file<< std::endl;
|
||||
osg::notify(osg::INFO)<<"ReaderWriterXine::readImage "<< file<< std::endl;
|
||||
|
||||
osg::ref_ptr<osgXine::XineImageStream> imageStream = new osgXine::XineImageStream();
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
|
||||
#define THIS "video_out_rgb"
|
||||
|
||||
static int s_debugMessages = 0;
|
||||
|
||||
|
||||
#define EVAL(exp) \
|
||||
{\
|
||||
@@ -2290,7 +2292,7 @@ CHECK_FRAME:
|
||||
{
|
||||
if(!(told))
|
||||
{
|
||||
fprintf(stderr, THIS ": yuv format is YV12\n");
|
||||
if (s_debugMessages) fprintf(stderr, THIS ": yuv format is YV12\n");
|
||||
told = 1;
|
||||
}
|
||||
|
||||
@@ -2314,7 +2316,7 @@ CHECK_FRAME:
|
||||
{
|
||||
if(!(told))
|
||||
{
|
||||
fprintf(stderr, THIS ": yuv format is YUY2\n");
|
||||
if (s_debugMessages) fprintf(stderr, THIS ": yuv format is YUY2\n");
|
||||
told = 1;
|
||||
}
|
||||
|
||||
@@ -2334,7 +2336,7 @@ CHECK_FRAME:
|
||||
{
|
||||
if(!(told))
|
||||
{
|
||||
fprintf(stderr, THIS
|
||||
if (s_debugMessages) fprintf(stderr, THIS
|
||||
": unknown yuv format [%#x], assuming YV12\n",
|
||||
frame->format);
|
||||
told = 1;
|
||||
@@ -2415,7 +2417,7 @@ rgbout_update_visual(vo_driver_t* vo_driver,
|
||||
|
||||
if(!(found))
|
||||
{
|
||||
fprintf(stderr, THIS ": unknown pixel format [%i]\n",
|
||||
if (s_debugMessages) fprintf(stderr, THIS ": unknown pixel format [%i]\n",
|
||||
new_visual->format);
|
||||
goto FAILURE;
|
||||
}
|
||||
@@ -2600,8 +2602,6 @@ open_plugin(video_driver_class_t* vo_class, const void *vo_visual)
|
||||
rgbout_visual_info_t* visual = (rgbout_visual_info_t*) vo_visual;
|
||||
rgbout_driver_t* this = NULL;
|
||||
|
||||
fprintf(stderr, "RGBout output plugin (*Experimental*)\n");
|
||||
|
||||
EVAL(vo_class != NULL);
|
||||
EVAL(vo_visual != NULL);
|
||||
EVAL(visual->callback != NULL);
|
||||
@@ -2641,7 +2641,7 @@ open_plugin(video_driver_class_t* vo_class, const void *vo_visual)
|
||||
|
||||
if(convert_methods[i].name)
|
||||
{
|
||||
fprintf(stderr, THIS
|
||||
if (s_debugMessages) fprintf(stderr, THIS
|
||||
": using %s acceleration\n",
|
||||
convert_methods[i].name);
|
||||
}
|
||||
@@ -2658,7 +2658,7 @@ open_plugin(video_driver_class_t* vo_class, const void *vo_visual)
|
||||
|
||||
if(this->levels & ~(PXLEVEL_ALL))
|
||||
{
|
||||
fprintf(stderr, THIS ": wrong levels flag [%#x], assuming PXLEVEL_ALL\n",
|
||||
if (s_debugMessages) fprintf(stderr, THIS ": wrong levels flag [%#x], assuming PXLEVEL_ALL\n",
|
||||
visual->levels);
|
||||
this->levels = PXLEVEL_ALL;
|
||||
}
|
||||
@@ -2678,7 +2678,7 @@ open_plugin(video_driver_class_t* vo_class, const void *vo_visual)
|
||||
|
||||
if(pack_methods[i].name)
|
||||
{
|
||||
fprintf(stderr, THIS
|
||||
if (s_debugMessages) fprintf(stderr, THIS
|
||||
": packing pixels in %s format\n",
|
||||
pack_methods[i].name);
|
||||
}
|
||||
@@ -2689,7 +2689,7 @@ open_plugin(video_driver_class_t* vo_class, const void *vo_visual)
|
||||
|
||||
if(!(this->pack))
|
||||
{
|
||||
fprintf(stderr, THIS
|
||||
if (s_debugMessages) fprintf(stderr, THIS
|
||||
": unknown rgb pixel format [%i]\n", visual->format);
|
||||
goto FAILURE;
|
||||
}
|
||||
@@ -2734,8 +2734,6 @@ FAILURE:
|
||||
static void*
|
||||
init_class(xine_t* xine, void* vo_visual)
|
||||
{
|
||||
fprintf(stderr,"********------- init_class");
|
||||
|
||||
rgbout_class_t* rgb_class = NULL;
|
||||
|
||||
EVAL(xine != NULL);
|
||||
@@ -2752,8 +2750,6 @@ init_class(xine_t* xine, void* vo_visual)
|
||||
return(rgb_class);
|
||||
|
||||
FAILURE:
|
||||
fprintf(stderr,"******************** init_class");
|
||||
|
||||
release(rgb_class);
|
||||
return(NULL);
|
||||
}
|
||||
@@ -2776,8 +2772,6 @@ plugin_info_t xine_plugin_info[] =
|
||||
|
||||
void register_rgbout_plugin(xine_t *self)
|
||||
{
|
||||
fprintf(stderr,"register_rgbout_plugin...\n");
|
||||
xine_register_plugins(self, xine_plugin_info);
|
||||
fprintf(stderr,"done register_rgbout_plugin\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user