]> git.tdb.fi Git - xinema.git/commitdiff
Revert to using XLockDisplay/XUnlockDisplay
authorMikko Rasa <tdb@tdb.fi>
Fri, 16 Oct 2015 16:30:59 +0000 (19:30 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 16 Oct 2015 16:30:59 +0000 (19:30 +0300)
Not all Xine output plugins support custom lock callbacks.  In particular,
vdpau doesn't.

source/xineengine.cpp
source/xineengine.h
source/xinema.cpp
source/xinema.h

index 5dadc93a5c7cfb35c23ffba992d871d23a166290..3da036b33934a76ad20a6ac2a3e18e330865027d 100644 (file)
@@ -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<XineEngine *>(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<XineEngine *>(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();
-       }
-}
index eb26406379350a575f552430f23a345ab68fe7dc..50b0927659089d0c417c480daf5316066e9dfca4 100644 (file)
@@ -4,7 +4,6 @@
 #include <pthread.h>
 #include <sigc++/trackable.h>
 #include <xine.h>
-#include <msp/core/mutex.h>
 #include <msp/graphics/window.h>
 
 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<XineStream *> 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
index 267f6a4eeb42b1dbebce1d71e67fc106133fe397..bc70c4154c04bec4aa63f49bd3cfe6855a73cd1e 100644 (file)
@@ -1,5 +1,6 @@
 #include <sigc++/bind.h>
 #include <msp/fs/dir.h>
+#include <msp/graphics/display_private.h>
 #include <msp/time/utils.h>
 #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();
 
index ce0345dfeb43850bac27721e75f45e4152f7cff2..e82f26faaa48a038e4d670e4f17f37f7454fa60e 100644 (file)
@@ -2,7 +2,6 @@
 #define XINEMA_H_
 
 #include <msp/core/application.h>
-#include <msp/core/mutex.h>
 #include <msp/fs/path.h>
 #include <msp/graphics/display.h>
 #include <msp/graphics/window.h>
@@ -13,12 +12,18 @@ class XineStream;
 
 class Xinema: public Msp::RegisteredApplication<Xinema>
 {
+private:
+       struct EarlyInit
+       {
+               EarlyInit();
+       };
+
 public:
        sigc::signal<void, XineStream &> signal_stream_created;
 
 private:
+       EarlyInit early_init;
        Msp::Graphics::Display display;
-       Msp::Mutex display_mutex;
        Msp::Graphics::Window window;
        NetworkInterface network;
        XineEngine *engine;