Fix and improve gapless playback

If "about-to-finish" was emitted before the preload time was reached, we never set the next uri, so gapless playback was broken.
Make sure to always set the next uri, and increase preload gap from 5 to 8 seconds.
This commit is contained in:
Jonas Kvinge
2023-04-22 03:54:09 +02:00
parent f4600bd8eb
commit c96498758f
6 changed files with 56 additions and 28 deletions

View File

@@ -95,7 +95,8 @@ class GstEnginePipeline : public QObject {
void StartFader(const qint64 duration_nanosec, const QTimeLine::Direction direction = QTimeLine::Forward, const QEasingCurve::Type shape = QEasingCurve::Linear, const bool use_fudge_timer = true);
// If this is set then it will be loaded automatically when playback finishes for gapless playback
void SetNextUrl(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();
bool has_next_valid_url() const { return next_stream_url_.isValid(); }
void SetSourceDevice(const QString &device) { source_device_ = device; }
@@ -140,6 +141,8 @@ class GstEnginePipeline : public QObject {
void BufferingProgress(const int percent);
void BufferingFinished();
void AboutToFinish();
protected:
void timerEvent(QTimerEvent*) override;
@@ -317,6 +320,8 @@ class GstEnginePipeline : public QObject {
bool logged_unsupported_analyzer_format_;
bool about_to_finish_;
};
#endif // GSTENGINEPIPELINE_H