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();
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");
*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();
- }
-}
#include <pthread.h>
#include <sigc++/trackable.h>
#include <xine.h>
-#include <msp/core/mutex.h>
#include <msp/graphics/window.h>
class XineStream;
{
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;
std::list<XineStream *> streams;
public:
- XineEngine(Msp::Graphics::Window &, Msp::Mutex * = 0);
+ XineEngine(Msp::Graphics::Window &);
~XineEngine();
xine_t *get_engine() { return engine; }
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
#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"
using namespace std;
using namespace Msp;
+Xinema::EarlyInit::EarlyInit()
+{
+ XInitThreads();
+}
+
+
Xinema::Xinema(int, char **):
window(display, 1920, 1080),
network(*this),
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();
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();
#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>
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;