From c8e6fa7e740bd495b44bb77599f2eba696134dd4 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Wed, 2 Aug 2023 03:29:22 +0300 Subject: [PATCH] GstEnginePipeline: place probes/handles *after* output queue We want to get the segments in sync with when they are passed onto the sound card, and now that is after the output queue. --- src/engine/gstenginepipeline.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index 161708f5..4c2b195e 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -576,8 +576,6 @@ bool GstEnginePipeline::InitAudioBin(QString &error) { } - eventprobe_ = audioqueueconverter_; - // Create the replaygain elements if it's enabled. GstElement *rgvolume = nullptr; GstElement *rglimiter = nullptr; @@ -595,7 +593,6 @@ bool GstEnginePipeline::InitAudioBin(QString &error) { if (!rgconverter) { return false; } - eventprobe_ = rgconverter; // Set replaygain settings g_object_set(G_OBJECT(rgvolume), "album-mode", rg_mode_, nullptr); g_object_set(G_OBJECT(rgvolume), "pre-amp", rg_preamp_, nullptr); @@ -612,7 +609,6 @@ bool GstEnginePipeline::InitAudioBin(QString &error) { UpdateEBUR128LoudnessNormalizingGaindB(); - eventprobe_ = ebur128_volume_; } GstElement *bs2b = nullptr; @@ -637,16 +633,6 @@ bool GstEnginePipeline::InitAudioBin(QString &error) { } } - // Add a data probe on the src pad of the audioconvert element for our scope. - // We do it here because we want pre-equalized and pre-volume samples so that our visualization are not be affected by them. - { - GstPad *pad = gst_element_get_static_pad(eventprobe_, "src"); - if (pad) { - upstream_events_probe_cb_id_ = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_EVENT_UPSTREAM, &UpstreamEventsProbeCallback, this, nullptr); - gst_object_unref(pad); - } - } - // Set the buffer duration. // We set this on our queues instead of the playbin because setting it on the playbin only affects network sources. // Disable the default buffer and byte limits, so we only buffer based on time. @@ -767,6 +753,7 @@ bool GstEnginePipeline::InitAudioBin(QString &error) { error = "Failed to link audio sink converter to output audio queue with filter"; return false; } + eventprobe_ = outputaudioqueue_; element_link = outputaudioqueue_; } @@ -777,8 +764,9 @@ bool GstEnginePipeline::InitAudioBin(QString &error) { element_link = audiosink_; { // Add probes and handlers. - GstPad *pad = gst_element_get_static_pad(audioqueueconverter_, "src"); + GstPad *pad = gst_element_get_static_pad(eventprobe_, "src"); if (pad) { + upstream_events_probe_cb_id_ = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_EVENT_UPSTREAM, &UpstreamEventsProbeCallback, this, nullptr); buffer_probe_cb_id_ = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, BufferProbeCallback, this, nullptr); gst_object_unref(pad); }