]> git.tdb.fi Git - xinema.git/commitdiff
Use filename as a fallback title if the stream doesn't have one
authorMikko Rasa <tdb@tdb.fi>
Sat, 17 Oct 2015 14:09:34 +0000 (17:09 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 17 Oct 2015 14:09:34 +0000 (17:09 +0300)
source/xinestream.cpp
source/xinestream.h

index 7317f7c8838449e8e901676ea4b8ebce4799760a..4fc2e88fa1f569bcf2ef811117d2a02eb8bbef11 100644 (file)
@@ -7,7 +7,9 @@ using namespace Msp;
 
 XineStream::XineStream(XineEngine &e, const string &mrl):
        engine(e),
+       filename(mrl.substr(mrl.rfind('/')+1)),
        state(STOPPED),
+       title(filename),
        current_audio(0),
        current_spu(OFF),
        channels_changed(false)
@@ -22,6 +24,11 @@ XineStream::XineStream(XineEngine &e, const string &mrl):
        engine.add_stream(*this);
 }
 
+const string &XineStream::get_title() const
+{
+       return title.empty() ? filename : title;
+}
+
 XineStream::~XineStream()
 {
        engine.remove_stream(*this);
@@ -120,7 +127,7 @@ void XineStream::update_info()
        {
                MutexLock lock(mutex);
                title = (xt ? xt : string());
-               signal_title_changed.emit(title);
+               signal_title_changed.emit(get_title());
        }
 
        int dur_msec, pos_msec;
index 254b84d66ec5030d922a975f1cdbd186c11a5623..554b448aac489ff7ab5b899b7cec8181ac63249a 100644 (file)
@@ -36,6 +36,7 @@ public:
 
 private:
        XineEngine &engine;
+       std::string filename;
        xine_stream_t *stream;
        xine_event_queue_t *queue;
        Msp::Mutex mutex;
@@ -57,7 +58,7 @@ public:
        State get_state() const { return state; }
        const Msp::Time::TimeDelta &get_duration() const { return duration; }
        const Msp::Time::TimeDelta &get_position() const { return position; }
-       const std::string &get_title() const { return title; }
+       const std::string &get_title() const;
 
        void play();
        void seek(const Msp::Time::TimeDelta &);