From 8bc5ada885b50952d4f5742bc96d11f4feab1bd0 Mon Sep 17 00:00:00 2001
From: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
Date: Mon, 12 Oct 2026 08:50:41 -0300
Subject: Fix GStreamer sink setup and pipeline teardown
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
---
 src/gstplayer.cpp | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/src/gstplayer.cpp b/src/gstplayer.cpp
index 3683989..8f2449b 100644
--- a/src/gstplayer.cpp
+++ b/src/gstplayer.cpp
@@ -593,7 +593,6 @@ void KGStreamerPlayer::play (int repeat) {
     GstElement *element;
     GstElement *videosink = 0L;
     GstElement *audiosink = 0L;
-    bool success;
     fprintf (stderr, "play %s\n", mrl.isEmpty() ? "<empty>" : mrl.ascii ());
     if (gst_elm_play) {
         if (GST_STATE (gst_elm_play) == GST_STATE_PAUSED) {
@@ -657,18 +656,6 @@ void KGStreamerPlayer::play (int repeat) {
         gst_x_overlay_set_xwindow_id (xoverlay, wid);
     }
 #endif
-    gst_element_set_bus (videosink, gst_bus);
-    gst_element_set_state (videosink, GST_STATE_READY);
-    success = gstPollForStateChange (videosink, GST_STATE_READY);
-    //if (!success) {
-        /* Drop this video sink */
-    //    gst_element_set_state (videosink, GST_STATE_NULL);
-    //    gst_object_unref (videosink);
-    if (audiosink) {
-        gst_element_set_bus (audiosink, gst_bus);
-        gst_element_set_state (audiosink, GST_STATE_READY);
-        success = gstPollForStateChange (audiosink, GST_STATE_READY);
-    }
     g_object_set (G_OBJECT (gst_elm_play),
             "video-sink",  videosink,
             "audio-sink",  audiosink,
@@ -842,6 +829,7 @@ bool KGStreamerPlayer::event (TQEvent * e) {
             fprintf (stderr, "event_finished\n");
             mutex.lock ();
             if (gst_elm_play) {
+                gst_element_set_state (gst_elm_play, GST_STATE_NULL);
                 gst_bus_set_flushing (gst_bus, true);
                 if (gst_bus_sync)
                     g_signal_handler_disconnect (gst_bus, gst_bus_sync);
-- 
cgit v1.2.3

