]> git.tdb.fi Git - xinema.git/blob - source/xinema.cpp
Pass expose events to Xine
[xinema.git] / source / xinema.cpp
1 #include <sigc++/bind.h>
2 #include <msp/time/utils.h>
3 #include "xineengine.h"
4 #include "xinema.h"
5 #include "xinestream.h"
6
7 using namespace std;
8 using namespace Msp;
9
10 Xinema::Xinema(int, char **):
11         window(display, 1920, 1080),
12         network(*this),
13         engine(0),
14         stream(0)
15 {
16         window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &Xinema::exit), 0));
17 }
18
19 int Xinema::main()
20 {
21         window.show();
22         display.tick();
23
24         engine = new XineEngine(window, &display_mutex);
25
26         Application::main();
27
28         if(stream)
29                 delete stream;
30         delete engine;
31
32         return exit_code;
33 }
34
35 void Xinema::tick()
36 {
37         {
38                 MutexLock lock(command_mutex);
39                 if(!pending_mrl.empty())
40                 {
41                         delete stream;
42                         stream = new XineStream(*engine, pending_mrl);
43                         stream->play();
44                         pending_mrl.clear();
45                 }
46         }
47
48         {
49                 MutexLock lock(display_mutex);
50                 display.tick();
51         }
52
53         engine->tick();
54         if(stream)
55                 stream->tick();
56
57         Time::sleep(10*Time::msec);
58 }
59
60 void Xinema::play_file(const FS::Path &fn)
61 {
62         MutexLock lock(command_mutex);
63         pending_mrl = "file://"+fn.str();
64 }