]> git.tdb.fi Git - xinema.git/commitdiff
Re-display the logo after the stream finishes
authorMikko Rasa <tdb@tdb.fi>
Fri, 16 Oct 2015 21:28:48 +0000 (00:28 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 16 Oct 2015 21:28:48 +0000 (00:28 +0300)
Also don't present it as a playing file.

source/client.cpp
source/client.h
source/xinema.cpp
source/xinema.h

index ba0be5b44da51b11af152c59e1c6255c584ac958..835dbbd91597f234ad794571dd3e14d56b2ec1d8 100644 (file)
@@ -16,6 +16,7 @@ Client::Client(Xinema &x, Net::StreamSocket *s):
        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);
@@ -142,6 +143,11 @@ void Client::stream_created(XineStream &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));
index f8aeb8238a440f133e9ccfee357449f73edbfab5..f1f4dc15ed319c6312cfef6fc3bbbd0de1ef2892 100644 (file)
@@ -34,6 +34,7 @@ private:
        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 &);
index bc70c4154c04bec4aa63f49bd3cfe6855a73cd1e..499154387e67eef838531e017ca944afe03007ea 100644 (file)
@@ -19,7 +19,9 @@ Xinema::Xinema(int, char **):
        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));
 }
@@ -30,7 +32,7 @@ int Xinema::main()
        display.tick();
 
        engine = new XineEngine(window);
-       play_file(FS::get_sys_data_dir()/"xinema.png");
+       show_logo();
 
        Application::main();
 
@@ -43,22 +45,35 @@ int Xinema::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();
@@ -73,4 +88,12 @@ void Xinema::play_file(const FS::Path &fn)
 {
        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;
 }
index e82f26faaa48a038e4d670e4f17f37f7454fa60e..cdb1db8e0c3c52079869e2c537d29f556f010b0a 100644 (file)
@@ -20,6 +20,7 @@ private:
 
 public:
        sigc::signal<void, XineStream &> signal_stream_created;
+       sigc::signal<void> signal_stream_destroyed;
 
 private:
        EarlyInit early_init;
@@ -28,9 +29,11 @@ private:
        NetworkInterface network;
        XineEngine *engine;
        XineStream *stream;
+       bool logo_mode;
 
        Msp::Mutex command_mutex;
        std::string pending_mrl;
+       bool pending_logo;
 
 public:
        Xinema(int, char **);
@@ -41,7 +44,10 @@ private:
 
 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