]> git.tdb.fi Git - xinema.git/commitdiff
Pass expose events to Xine
authorMikko Rasa <tdb@tdb.fi>
Thu, 15 Oct 2015 23:19:57 +0000 (02:19 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 15 Oct 2015 23:19:57 +0000 (02:19 +0300)
source/xineengine.cpp
source/xineengine.h
source/xinema.cpp

index 4175381b8d3a0a4b9f1782f9df00967a1b7121b4..656990e012ecbfafa7da5c0873ac9d350e35ecdb 100644 (file)
@@ -7,11 +7,12 @@
 using namespace std;
 using namespace Msp;
 
-XineEngine::XineEngine(const Graphics::Window &w, Mutex *m):
+XineEngine::XineEngine(Graphics::Window &w, Mutex *m):
        window(w),
        display_mutex(m),
        locked_thread(0),
-       lock_count(0)
+       lock_count(0),
+       pending_expose(0)
 {
        engine = xine_new();
 
@@ -44,6 +45,8 @@ XineEngine::XineEngine(const Graphics::Window &w, Mutex *m):
        video_driver = xine_open_video_driver(engine, "auto", XINE_VISUAL_TYPE_X11_2, &visual);
        if(!video_driver)
                throw runtime_error("Could not open video driver");
+
+       window.signal_expose.connect(sigc::mem_fun(this, &XineEngine::window_exposed));
 }
 
 XineEngine::~XineEngine()
@@ -53,6 +56,22 @@ XineEngine::~XineEngine()
        xine_exit(engine);
 }
 
+void XineEngine::tick()
+{
+       if(pending_expose)
+       {
+               xine_port_send_gui_data(video_driver, XINE_GUI_SEND_EXPOSE_EVENT, &pending_expose->xevent);
+               delete pending_expose;
+               pending_expose = 0;
+       }
+}
+
+void XineEngine::window_exposed(unsigned, unsigned, unsigned, unsigned, const Graphics::Window::Event &event)
+{
+       delete pending_expose;
+       pending_expose = new Graphics::Window::Event(event);
+}
+
 void XineEngine::dest_size_cb(void *user_data, int, int, double, int *dest_width, int *dest_height, double *dest_pixel_aspect)
 {
        XineEngine &engine = *reinterpret_cast<XineEngine *>(user_data);
index 8acb1a5975cb8acb87930453393cbfbaba5df960..2949734714419697813e3f3a62ad0da0f0aa72ef 100644 (file)
@@ -2,16 +2,17 @@
 #define XINEENGINE_H_
 
 #include <pthread.h>
+#include <sigc++/trackable.h>
 #include <xine.h>
 #include <msp/core/mutex.h>
 #include <msp/graphics/window.h>
 
 class XineStream;
 
-class XineEngine
+class XineEngine: public sigc::trackable
 {
 private:
-       const Msp::Graphics::Window &window;
+       Msp::Graphics::Window &window;
        Msp::Mutex *display_mutex;
        pthread_t locked_thread;
        unsigned lock_count;
@@ -19,16 +20,21 @@ private:
        xine_audio_port_t *audio_driver;
        x11_visual_t visual;
        xine_video_port_t *video_driver;
+       Msp::Graphics::Window::Event *pending_expose;
 
 public:
-       XineEngine(const Msp::Graphics::Window &, Msp::Mutex * = 0);
+       XineEngine(Msp::Graphics::Window &, Msp::Mutex * = 0);
        ~XineEngine();
 
        xine_t *get_engine() { return engine; }
        xine_audio_port_t *get_audio_driver() { return audio_driver; }
        xine_video_port_t *get_video_driver() { return video_driver; }
 
+       void tick();
+
 private:
+       void window_exposed(unsigned, unsigned, unsigned, unsigned, const Msp::Graphics::Window::Event &);
+
        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 *);
index fc042e1ebd78e6487de3c516caa91db8bee65230..feab3272fcc2a85034ef043f3fb471d93ba45d10 100644 (file)
@@ -50,6 +50,7 @@ void Xinema::tick()
                display.tick();
        }
 
+       engine->tick();
        if(stream)
                stream->tick();