GstEnginePipeline: Add missing end of stream
A bug was introduced when I added the mutex locker for the URLs, it did nothing when it was supposed to emit end of stream. Fixes #1568
This commit is contained in:
@@ -1305,22 +1305,18 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
|
|||||||
|
|
||||||
// Calculate the end time of this buffer so we can stop playback if it's after the end time of this song.
|
// Calculate the end time of this buffer so we can stop playback if it's after the end time of this song.
|
||||||
if (instance->end_offset_nanosec_.value() > 0 && end_time > instance->end_offset_nanosec_.value()) {
|
if (instance->end_offset_nanosec_.value() > 0 && end_time > instance->end_offset_nanosec_.value()) {
|
||||||
if (instance->HasNextUrl()) {
|
if (instance->HasMatchingNextUrl() && instance->next_beginning_offset_nanosec_.value() == instance->end_offset_nanosec_.value()) {
|
||||||
QMutexLocker mutex_locker_url(&instance->mutex_url_);
|
// The "next" song is actually the next segment of this file - so cheat and keep on playing, but just tell the Engine we've moved on.
|
||||||
QMutexLocker mutex_locker_next_url(&instance->mutex_next_url_);
|
instance->end_offset_nanosec_ = instance->next_end_offset_nanosec_;
|
||||||
if (instance->next_stream_url_ == instance->stream_url_ && instance->next_beginning_offset_nanosec_ == instance->end_offset_nanosec_) {
|
instance->next_media_url_.clear();
|
||||||
// The "next" song is actually the next segment of this file - so cheat and keep on playing, but just tell the Engine we've moved on.
|
instance->next_stream_url_.clear();
|
||||||
instance->end_offset_nanosec_ = instance->next_end_offset_nanosec_;
|
instance->next_gst_url_.clear();
|
||||||
instance->next_media_url_.clear();
|
instance->next_beginning_offset_nanosec_ = 0;
|
||||||
instance->next_stream_url_.clear();
|
instance->next_end_offset_nanosec_ = 0;
|
||||||
instance->next_gst_url_.clear();
|
|
||||||
instance->next_beginning_offset_nanosec_ = 0;
|
|
||||||
instance->next_end_offset_nanosec_ = 0;
|
|
||||||
|
|
||||||
// GstEngine will try to seek to the start of the new section, but we're already there so ignore it.
|
// GstEngine will try to seek to the start of the new section, but we're already there so ignore it.
|
||||||
instance->ignore_next_seek_ = true;
|
instance->ignore_next_seek_ = true;
|
||||||
Q_EMIT instance->EndOfStreamReached(instance->id(), true);
|
Q_EMIT instance->EndOfStreamReached(instance->id(), true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// There's no next song
|
// There's no next song
|
||||||
@@ -2070,6 +2066,14 @@ bool GstEnginePipeline::HasNextUrl() const {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GstEnginePipeline::HasMatchingNextUrl() const {
|
||||||
|
|
||||||
|
QMutexLocker mutex_locker_url(&mutex_url_);
|
||||||
|
QMutexLocker mutex_locker_next_url(&mutex_next_url_);
|
||||||
|
return next_stream_url_.isValid() && next_stream_url_ == stream_url_;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void GstEnginePipeline::PrepareNextUrl(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 beginning_nanosec, const qint64 end_nanosec) {
|
void GstEnginePipeline::PrepareNextUrl(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ class GstEnginePipeline : public QObject {
|
|||||||
|
|
||||||
// If this is set then it will be loaded automatically when playback finishes for gapless playback
|
// If this is set then it will be loaded automatically when playback finishes for gapless playback
|
||||||
bool HasNextUrl() const;
|
bool HasNextUrl() const;
|
||||||
|
bool HasMatchingNextUrl() const;
|
||||||
void PrepareNextUrl(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 beginning_nanosec, const qint64 end_nanosec);
|
void PrepareNextUrl(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 beginning_nanosec, const qint64 end_nanosec);
|
||||||
void SetNextUrl();
|
void SetNextUrl();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user