1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-18 20:40:43 +01:00

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.

This commit is contained in:
David Sansome 2011-03-28 22:11:07 +00:00
parent 7eb8e9b54d
commit 7d6eee590a
5 changed files with 23 additions and 10 deletions

View File

@ -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());
}

View File

@ -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);

View File

@ -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);

View File

@ -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<GstEnginePipeline> pipeline = CreatePipeline(gst_url, end_nanosec);
shared_ptr<GstEnginePipeline> pipeline = CreatePipeline(gst_url,
force_stop_at_end ? end_nanosec : 0);
if (!pipeline)
return false;

View File

@ -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();