From 1d03bb217871a9bb812c9f059ceb72f4259773cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 00:06:03 +0000 Subject: [PATCH] GstEnginePipeline: Fix crash in GStreamer decodebin3 when switching tracks Add guard in AboutToFinishCallback to prevent race condition when pipeline is being torn down. This prevents the callback from trying to set next URL while the pipeline is being destroyed, which caused crashes in GStreamer's decodebin3. Fixes issue where rapidly switching tracks could cause segmentation fault in gst_decodebin_input_link_to_slot. See: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4626 Fixes #1863 Co-Authored-By: Jonas Kvinge --- src/engine/gstenginepipeline.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index 9e226353b..479c9e8c3 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -1364,6 +1364,13 @@ void GstEnginePipeline::AboutToFinishCallback(GstPlayBin *playbin, gpointer self GstEnginePipeline *instance = reinterpret_cast(self); + // Ignore about-to-finish if we're in the process of tearing down the pipeline + // This prevents race conditions in GStreamer's decodebin3 when rapidly switching tracks + // See: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4626 + if (instance->finish_requested_.value()) { + return; + } + { QMutexLocker l(&instance->mutex_url_); qLog(Debug) << "Stream from URL" << instance->gst_url_ << "about to finish.";