From fbd6b46e2083592e50949b1d8776305beebfce79 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Mon, 12 Jul 2010 19:09:59 +0000 Subject: [PATCH] Only take notice of the first segment start event, to fix seeking --- src/engines/gstenginepipeline.cpp | 6 +++++- src/engines/gstenginepipeline.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engines/gstenginepipeline.cpp b/src/engines/gstenginepipeline.cpp index 274720dfb..e36315a40 100644 --- a/src/engines/gstenginepipeline.cpp +++ b/src/engines/gstenginepipeline.cpp @@ -30,6 +30,7 @@ GstEnginePipeline::GstEnginePipeline(GstEngine* engine) valid_(false), sink_(GstEngine::kAutoSink), segment_start_(0), + segment_start_received_(false), rg_enabled_(false), rg_mode_(0), rg_preamp_(0.0), @@ -82,6 +83,8 @@ bool GstEnginePipeline::ReplaceDecodeBin(const QUrl& url) { } uridecodebin_ = new_bin; + segment_start_ = 0; + segment_start_received_ = false; gst_bin_add(GST_BIN(pipeline_), uridecodebin_); g_object_set(G_OBJECT(uridecodebin_), "uri", url.toEncoded().constData(), NULL); @@ -326,12 +329,13 @@ bool GstEnginePipeline::HandoffCallback(GstPad*, GstBuffer* buf, gpointer self) bool GstEnginePipeline::EventHandoffCallback(GstPad*, GstEvent* e, gpointer self) { GstEnginePipeline* instance = reinterpret_cast(self); - if (GST_EVENT_TYPE(e) == GST_EVENT_NEWSEGMENT) { + if (GST_EVENT_TYPE(e) == GST_EVENT_NEWSEGMENT && !instance->segment_start_received_) { // The segment start time is used to calculate the proper offset of data // buffers from the start of the stream gint64 start = 0; gst_event_parse_new_segment(e, NULL, NULL, NULL, &start, NULL, NULL); instance->segment_start_ = start; + instance->segment_start_received_ = true; } return true; diff --git a/src/engines/gstenginepipeline.h b/src/engines/gstenginepipeline.h index a52297d2f..cd0ea555b 100644 --- a/src/engines/gstenginepipeline.h +++ b/src/engines/gstenginepipeline.h @@ -124,6 +124,7 @@ class GstEnginePipeline : public QObject { QList buffer_consumers_; QMutex buffer_consumers_mutex_; qint64 segment_start_; + bool segment_start_received_; // ReplayGain bool rg_enabled_;