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();
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()
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);
#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;
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 *);