X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fxineengine.cpp;h=3da036b33934a76ad20a6ac2a3e18e330865027d;hb=649ced5849086abe7711d588f95a48677936515a;hp=656990e012ecbfafa7da5c0873ac9d350e35ecdb;hpb=2204af390e6fe6db98c5d2f6e5317f841dc31198;p=xinema.git diff --git a/source/xineengine.cpp b/source/xineengine.cpp index 656990e..3da036b 100644 --- a/source/xineengine.cpp +++ b/source/xineengine.cpp @@ -1,17 +1,16 @@ +#include #include #include #include #include #include "xineengine.h" +#include "xinestream.h" using namespace std; using namespace Msp; -XineEngine::XineEngine(Graphics::Window &w, Mutex *m): +XineEngine::XineEngine(Graphics::Window &w): window(w), - display_mutex(m), - locked_thread(0), - lock_count(0), pending_expose(0) { engine = xine_new(); @@ -31,18 +30,10 @@ XineEngine::XineEngine(Graphics::Window &w, Mutex *m): visual.user_data = this; visual.dest_size_cb = &dest_size_cb; visual.frame_output_cb = &frame_output_cb; - if(display_mutex) - { - visual.lock_display = &lock_cb; - visual.unlock_display = &unlock_cb; - } - else - { - visual.lock_display = 0; - visual.unlock_display = 0; - } + visual.lock_display = 0; + visual.unlock_display = 0; - video_driver = xine_open_video_driver(engine, "auto", XINE_VISUAL_TYPE_X11_2, &visual); + video_driver = xine_open_video_driver(engine, "auto", XINE_VISUAL_TYPE_X11, &visual); if(!video_driver) throw runtime_error("Could not open video driver"); @@ -56,6 +47,18 @@ XineEngine::~XineEngine() xine_exit(engine); } +void XineEngine::add_stream(XineStream &stream) +{ + streams.push_back(&stream); +} + +void XineEngine::remove_stream(XineStream &stream) +{ + list::iterator i = find(streams.begin(), streams.end(), &stream); + if(i!=streams.end()) + streams.erase(i); +} + void XineEngine::tick() { if(pending_expose) @@ -64,6 +67,9 @@ void XineEngine::tick() delete pending_expose; pending_expose = 0; } + + for(list::const_iterator i=streams.begin(); i!=streams.end(); ++i) + (*i)->tick(); } void XineEngine::window_exposed(unsigned, unsigned, unsigned, unsigned, const Graphics::Window::Event &event) @@ -91,30 +97,3 @@ void XineEngine::frame_output_cb(void *user_data, int, int, double, int *dest_x, *win_x = 0; *win_y = 0; } - -void XineEngine::lock_cb(void *user_data) -{ - XineEngine &engine = *reinterpret_cast(user_data); - pthread_t tid = pthread_self(); - if(tid==engine.locked_thread) - ++engine.lock_count; - else - { - engine.display_mutex->lock(); - engine.locked_thread = tid; - engine.lock_count = 1; - } -} - -void XineEngine::unlock_cb(void *user_data) -{ - XineEngine &engine = *reinterpret_cast(user_data); - pthread_t tid = pthread_self(); - if(tid!=engine.locked_thread) - throw logic_error("Unlock from non-locked thread"); - if(!--engine.lock_count) - { - engine.locked_thread = 0; - engine.display_mutex->unlock(); - } -}