From: Mikko Rasa Date: Fri, 16 Oct 2015 16:30:59 +0000 (+0300) Subject: Revert to using XLockDisplay/XUnlockDisplay X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=649ced5849086abe7711d588f95a48677936515a;p=xinema.git Revert to using XLockDisplay/XUnlockDisplay Not all Xine output plugins support custom lock callbacks. In particular, vdpau doesn't. --- diff --git a/source/xineengine.cpp b/source/xineengine.cpp index 5dadc93..3da036b 100644 --- a/source/xineengine.cpp +++ b/source/xineengine.cpp @@ -9,11 +9,8 @@ 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(); @@ -33,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"); @@ -108,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(); - } -} diff --git a/source/xineengine.h b/source/xineengine.h index eb26406..50b0927 100644 --- a/source/xineengine.h +++ b/source/xineengine.h @@ -4,7 +4,6 @@ #include #include #include -#include #include class XineStream; @@ -13,9 +12,6 @@ class XineEngine: public sigc::trackable { private: Msp::Graphics::Window &window; - Msp::Mutex *display_mutex; - pthread_t locked_thread; - unsigned lock_count; xine_t *engine; xine_audio_port_t *audio_driver; x11_visual_t visual; @@ -24,7 +20,7 @@ private: std::list streams; public: - XineEngine(Msp::Graphics::Window &, Msp::Mutex * = 0); + XineEngine(Msp::Graphics::Window &); ~XineEngine(); xine_t *get_engine() { return engine; } @@ -41,8 +37,6 @@ private: static void dest_size_cb(void *, int, int, double, int *, int *, double *); static void frame_output_cb(void *, int, int, double, int *, int *, int *, int *, double *, int *, int *); - static void lock_cb(void *); - static void unlock_cb(void *); }; #endif diff --git a/source/xinema.cpp b/source/xinema.cpp index 267f6a4..bc70c41 100644 --- a/source/xinema.cpp +++ b/source/xinema.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "xineengine.h" #include "xinema.h" @@ -8,6 +9,12 @@ using namespace std; using namespace Msp; +Xinema::EarlyInit::EarlyInit() +{ + XInitThreads(); +} + + Xinema::Xinema(int, char **): window(display, 1920, 1080), network(*this), @@ -22,7 +29,7 @@ int Xinema::main() window.show(); display.tick(); - engine = new XineEngine(window, &display_mutex); + engine = new XineEngine(window); play_file(FS::get_sys_data_dir()/"xinema.png"); Application::main(); @@ -53,10 +60,9 @@ void Xinema::tick() if(new_stream) signal_stream_created.emit(*stream); - { - MutexLock lock(display_mutex); - display.tick(); - } + XLockDisplay(display.get_private().display); + display.tick(); + XUnlockDisplay(display.get_private().display); engine->tick(); diff --git a/source/xinema.h b/source/xinema.h index ce0345d..e82f26f 100644 --- a/source/xinema.h +++ b/source/xinema.h @@ -2,7 +2,6 @@ #define XINEMA_H_ #include -#include #include #include #include @@ -13,12 +12,18 @@ class XineStream; class Xinema: public Msp::RegisteredApplication { +private: + struct EarlyInit + { + EarlyInit(); + }; + public: sigc::signal signal_stream_created; private: + EarlyInit early_init; Msp::Graphics::Display display; - Msp::Mutex display_mutex; Msp::Graphics::Window window; NetworkInterface network; XineEngine *engine;