socket->signal_end_of_file.connect(sigc::mem_fun(this, &Client::end_of_stream));
xinema.signal_stream_created.connect(sigc::mem_fun(this, &Client::stream_created));
+ xinema.signal_stream_destroyed.connect(sigc::mem_fun(this, &Client::stream_destroyed));
XineStream *stream = xinema.get_stream();
if(stream)
stream_created(*stream);
stream_duration_changed(dur);
}
+void Client::stream_destroyed()
+{
+ send_reply("ejected");
+}
+
void Client::stream_state_changed(XineStream::State state)
{
send_reply(format("state %s", state));
void list_directory(const Msp::FS::Path &);
void stream_created(XineStream &);
+ void stream_destroyed();
void stream_state_changed(XineStream::State);
void stream_title_changed(const std::string &);
void stream_duration_changed(const Msp::Time::TimeDelta &);
window(display, 1920, 1080),
network(*this),
engine(0),
- stream(0)
+ stream(0),
+ logo_mode(false),
+ pending_logo(false)
{
window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &Xinema::exit), 0));
}
display.tick();
engine = new XineEngine(window);
- play_file(FS::get_sys_data_dir()/"xinema.png");
+ show_logo();
Application::main();
void Xinema::tick()
{
- bool new_stream = false;
-
+ string mrl;
+ bool logo;
{
MutexLock lock(command_mutex);
- if(!pending_mrl.empty())
- {
- delete stream;
- stream = new XineStream(*engine, pending_mrl);
- stream->play();
- pending_mrl.clear();
- new_stream = true;
- }
+ mrl = pending_mrl;
+ logo = pending_logo;
+ pending_mrl.clear();
+ pending_logo = false;
}
- if(new_stream)
- signal_stream_created.emit(*stream);
+ if(!mrl.empty())
+ {
+ bool had_stream = stream;
+
+ delete stream;
+ stream = 0;
+
+ if(had_stream && !logo_mode)
+ signal_stream_destroyed.emit();
+
+ logo_mode = logo;
+ stream = new XineStream(*engine, mrl);
+ if(!logo_mode)
+ stream->signal_finished.connect(sigc::mem_fun(this, &Xinema::show_logo));
+ stream->play();
+
+ if(!logo_mode)
+ signal_stream_created.emit(*stream);
+ }
XLockDisplay(display.get_private().display);
display.tick();
{
MutexLock lock(command_mutex);
pending_mrl = "file://"+fn.str();
+ pending_logo = false;
+}
+
+void Xinema::show_logo()
+{
+ MutexLock lock(command_mutex);
+ pending_mrl = "file://"+(FS::get_sys_data_dir()/"xinema.png").str();
+ pending_logo = true;
}
public:
sigc::signal<void, XineStream &> signal_stream_created;
+ sigc::signal<void> signal_stream_destroyed;
private:
EarlyInit early_init;
NetworkInterface network;
XineEngine *engine;
XineStream *stream;
+ bool logo_mode;
Msp::Mutex command_mutex;
std::string pending_mrl;
+ bool pending_logo;
public:
Xinema(int, char **);
public:
void play_file(const Msp::FS::Path &);
- XineStream *get_stream() const { return stream; }
+ XineStream *get_stream() const { return logo_mode ? 0 : stream; }
+
+private:
+ void show_logo();
};
#endif