3b5c35e
From eb21b6827e25b2c943025a662cde2049c0454a6b Mon Sep 17 00:00:00 2001
3b5c35e
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
3b5c35e
Date: Fri, 15 Aug 2014 15:59:58 +0100
3b5c35e
Subject: [PATCH] Related: rhbz#1130264 plausible fix for reported crash
3b5c35e
3b5c35e
Change-Id: I4ccdf19bfc7986881f7022109f22f47a0f493591
3b5c35e
---
3b5c35e
 avmedia/source/gstreamer/gstplayer.cxx | 20 ++++++++++++++++----
3b5c35e
 avmedia/source/gstreamer/gstplayer.hxx |  3 +++
3b5c35e
 2 files changed, 19 insertions(+), 4 deletions(-)
3b5c35e
3b5c35e
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
3b5c35e
index ceea8e2..836e89e 100644
3b5c35e
--- a/avmedia/source/gstreamer/gstplayer.cxx
3b5c35e
+++ b/avmedia/source/gstreamer/gstplayer.cxx
3b5c35e
@@ -74,7 +74,9 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
3b5c35e
     mpXOverlay( NULL ),
3b5c35e
     mnDuration( 0 ),
3b5c35e
     mnWidth( 0 ),
3b5c35e
-    mnHeight( 0 )
3b5c35e
+    mnHeight( 0 ),
3b5c35e
+    mnWatchID( 0 ),
3b5c35e
+    mbWatchID( false )
3b5c35e
 {
3b5c35e
     // Initialize GStreamer library
3b5c35e
     int argc = 1;
3b5c35e
@@ -127,11 +129,15 @@ void SAL_CALL Player::disposing()
3b5c35e
             g_object_unref( G_OBJECT ( mpXOverlay ) );
3b5c35e
             mpXOverlay = NULL;
3b5c35e
         }
3b5c35e
+
3b5c35e
+    }
3b5c35e
+    if (mbWatchID)
3b5c35e
+    {
3b5c35e
+        g_source_remove(mnWatchID);
3b5c35e
+        mbWatchID = false;
3b5c35e
     }
3b5c35e
 }
3b5c35e
 
065810b
-// ------------------------------------------------------------------------------
3b5c35e
-
3b5c35e
 static gboolean pipeline_bus_callback( GstBus *, GstMessage *message, gpointer data )
3b5c35e
 {
3b5c35e
     Player* pPlayer = static_cast<Player*>(data);
3b5c35e
@@ -357,7 +363,13 @@ void Player::preparePlaybin( const OUString& rURL, GstElement *pSink )
3b5c35e
         g_object_set( G_OBJECT( mpPlaybin ), "uri", ascURL.getStr() , NULL );
3b5c35e
 
3b5c35e
         pBus = gst_element_get_bus( mpPlaybin );
3b5c35e
-        gst_bus_add_watch( pBus, pipeline_bus_callback, this );
3b5c35e
+        if (mbWatchID)
3b5c35e
+        {
3b5c35e
+            g_source_remove(mnWatchID);
3b5c35e
+            mbWatchID = false;
3b5c35e
+        }
3b5c35e
+        mnWatchID = gst_bus_add_watch( pBus, pipeline_bus_callback, this );
3b5c35e
+        mbWatchID = true;
3b5c35e
         DBG( "%p set sync handler", this );
3b5c35e
 #ifdef AVMEDIA_GST_0_10
3b5c35e
         gst_bus_set_sync_handler( pBus, pipeline_bus_sync_handler, this );
3b5c35e
diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx
3b5c35e
index 2426eed..33c9e4d 100644
3b5c35e
--- a/avmedia/source/gstreamer/gstplayer.hxx
3b5c35e
+++ b/avmedia/source/gstreamer/gstplayer.hxx
3b5c35e
@@ -97,6 +97,9 @@ protected:
3b5c35e
     int                     mnWidth;
3b5c35e
     int                     mnHeight;
3b5c35e
 
3b5c35e
+    guint                   mnWatchID;
3b5c35e
+    bool                    mbWatchID;
3b5c35e
+
3b5c35e
     osl::Condition          maSizeCondition;
3b5c35e
 };
3b5c35e
 
3b5c35e
-- 
3b5c35e
1.9.3
3b5c35e