From 7d6eee590a16c980ef65cc1772d975947e869f27 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Mon, 28 Mar 2011 22:11:07 +0000 Subject: [PATCH] Don't force the track to stop at the end of a section unless it's part of a cue sheet. Fixes issue 1610. Fixes issue 1636. --- src/core/player.cpp | 5 ++++- src/engines/enginebase.cpp | 6 +++++- src/engines/enginebase.h | 4 +++- src/engines/gstengine.cpp | 13 ++++++++----- src/engines/gstengine.h | 5 +++-- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/core/player.cpp b/src/core/player.cpp index d45230b1c..e318e6ebd 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -94,6 +94,7 @@ void Player::HandleSpecialLoad(const PlaylistItem::SpecialLoadResult &result) { return; engine_->Play(result.media_url_, stream_change_type_, + item->Metadata().has_cue(), item->Metadata().beginning_nanosec(), item->Metadata().end_nanosec()); @@ -269,6 +270,7 @@ void Player::PlayAt(int index, Engine::TrackChangeFlags change, bool reshuffle) else { loading_async_ = QUrl(); engine_->Play(current_item_->Url(), change, + current_item_->Metadata().has_cue(), current_item_->Metadata().beginning_nanosec(), current_item_->Metadata().end_nanosec()); @@ -446,7 +448,8 @@ void Player::TrackAboutToEnd() { break; } } - engine_->StartPreloading(url, next_item->Metadata().beginning_nanosec(), + engine_->StartPreloading(url, next_item->Metadata().has_cue(), + next_item->Metadata().beginning_nanosec(), next_item->Metadata().end_nanosec()); } diff --git a/src/engines/enginebase.cpp b/src/engines/enginebase.cpp index 5a7169aff..4be99acd8 100644 --- a/src/engines/enginebase.cpp +++ b/src/engines/enginebase.cpp @@ -47,7 +47,10 @@ Engine::Base::~Base() { } bool Engine::Base::Load(const QUrl& url, TrackChangeFlags, + bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec) { + Q_UNUSED(force_stop_at_end); + url_ = url; beginning_nanosec_ = beginning_nanosec; end_nanosec_ = end_nanosec; @@ -91,8 +94,9 @@ int Engine::Base::AddBackgroundStream(const QUrl& url) { } bool Engine::Base::Play(const QUrl& u, TrackChangeFlags c, + bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec) { - if (!Load(u, c, beginning_nanosec, end_nanosec)) + if (!Load(u, c, force_stop_at_end, beginning_nanosec, end_nanosec)) return false; return Play(0); diff --git a/src/engines/enginebase.h b/src/engines/enginebase.h index b9accc84f..2faee25d2 100644 --- a/src/engines/enginebase.h +++ b/src/engines/enginebase.h @@ -44,7 +44,7 @@ class Base : public QObject, boost::noncopyable { virtual bool Init() = 0; - virtual void StartPreloading(const QUrl&, qint64, qint64) {} + virtual void StartPreloading(const QUrl&, bool, qint64, qint64) {} virtual bool Play(quint64 offset_nanosec) = 0; virtual void Stop() = 0; virtual void Pause() = 0; @@ -62,6 +62,7 @@ class Base : public QObject, boost::noncopyable { // Subclasses should respect given markers (beginning and end) which are // in miliseconds. virtual bool Load(const QUrl& url, TrackChangeFlags change, + bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec); // Sets new values for the beginning and end markers of the currently playing // song. @@ -76,6 +77,7 @@ class Base : public QObject, boost::noncopyable { // should be passed in nanoseconds. 'end' can be negative, indicating that the // real length of 'u' stream is unknown. bool Play(const QUrl& u, TrackChangeFlags c, + bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec); void SetVolume(uint value); diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index c0f9d5bf4..4e74b0d1e 100644 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -307,8 +307,8 @@ void GstEngine::UpdateScope() { } } -void GstEngine::StartPreloading(const QUrl& url, qint64 beginning_nanosec, - qint64 end_nanosec) { +void GstEngine::StartPreloading(const QUrl& url, bool force_stop_at_end, + qint64 beginning_nanosec, qint64 end_nanosec) { EnsureInitialised(); QUrl gst_url = FixupUrl(url); @@ -316,7 +316,8 @@ void GstEngine::StartPreloading(const QUrl& url, qint64 beginning_nanosec, // No crossfading, so we can just queue the new URL in the existing // pipeline and get gapless playback (hopefully) if (current_pipeline_) - current_pipeline_->SetNextUrl(gst_url, beginning_nanosec, end_nanosec); + current_pipeline_->SetNextUrl(gst_url, beginning_nanosec, + force_stop_at_end ? end_nanosec : 0); } QUrl GstEngine::FixupUrl(const QUrl& url) { @@ -334,10 +335,11 @@ QUrl GstEngine::FixupUrl(const QUrl& url) { } bool GstEngine::Load(const QUrl& url, Engine::TrackChangeFlags change, + bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec) { EnsureInitialised(); - Engine::Base::Load(url, change, beginning_nanosec, end_nanosec); + Engine::Base::Load(url, change, force_stop_at_end, beginning_nanosec, end_nanosec); QUrl gst_url = FixupUrl(url); @@ -355,7 +357,8 @@ bool GstEngine::Load(const QUrl& url, Engine::TrackChangeFlags change, return true; } - shared_ptr pipeline = CreatePipeline(gst_url, end_nanosec); + shared_ptr pipeline = CreatePipeline(gst_url, + force_stop_at_end ? end_nanosec : 0); if (!pipeline) return false; diff --git a/src/engines/gstengine.h b/src/engines/gstengine.h index e4f419e8d..de656200c 100644 --- a/src/engines/gstengine.h +++ b/src/engines/gstengine.h @@ -86,9 +86,10 @@ class GstEngine : public Engine::Base, public BufferConsumer { void ConsumeBuffer(GstBuffer *buffer, int pipeline_id); public slots: - void StartPreloading(const QUrl& url, qint64 beginning_nanosec, - qint64 end_nanosec); + void StartPreloading(const QUrl& url, bool force_stop_at_end, + qint64 beginning_nanosec, qint64 end_nanosec); bool Load(const QUrl&, Engine::TrackChangeFlags change, + bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec); bool Play(quint64 offset_nanosec); void Stop();