From 19f69a037e98b6b510fca0f270a5a0cf05de522d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 17 Oct 2015 17:09:34 +0300 Subject: [PATCH] Use filename as a fallback title if the stream doesn't have one --- source/xinestream.cpp | 9 ++++++++- source/xinestream.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/xinestream.cpp b/source/xinestream.cpp index 7317f7c..4fc2e88 100644 --- a/source/xinestream.cpp +++ b/source/xinestream.cpp @@ -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; diff --git a/source/xinestream.h b/source/xinestream.h index 254b84d..554b448 100644 --- a/source/xinestream.h +++ b/source/xinestream.h @@ -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 &); -- 2.45.2