[Xfce4-commits] <parole:master> Properly shutdown gst backend on exit to avoid XSync error

Ali Abdallah aliov at xfce.org
Fri Aug 14 19:02:03 CEST 2009


Updating branch refs/heads/master
         to 4f75f4ebb05786b9bc51132e85b937e75b502b01 (commit)
       from d07192f2c74b1e5d70efd0e308c2959e9244bfda (commit)

commit 4f75f4ebb05786b9bc51132e85b937e75b502b01
Author: Ali Abdallah <aliov at xfce.org>
Date:   Fri Aug 14 18:38:00 2009 +0200

    Properly shutdown gst backend on exit to avoid XSync error

 parole/parole-gst.c    |   33 +++++++++++++++++++++++++++------
 parole/parole-gst.h    |    2 ++
 parole/parole-player.c |    8 +-------
 3 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/parole/parole-gst.c b/parole/parole-gst.c
index b186cf2..c2a6068 100644
--- a/parole/parole-gst.c
+++ b/parole/parole-gst.c
@@ -93,6 +93,9 @@ struct ParoleGstPrivate
      * xvimage sink has brightness+hue+aturation+contrast.
      */
     gboolean	  xvimage_sink;
+    
+    gulong	  sig1;
+    gulong	  sig2;
 };
 
 enum
@@ -124,8 +127,6 @@ parole_gst_finalize (GObject *object)
     parole_stream_init_properties (gst->priv->stream);
     
     g_object_unref (gst->priv->stream);
-    g_object_unref (gst->priv->playbin);
-    g_object_unref (gst->priv->bus);
     g_object_unref (gst->priv->conf);
     g_object_unref (gst->priv->logo);
     
@@ -1314,16 +1315,18 @@ parole_gst_construct (GObject *object)
     gst->priv->bus = gst_element_get_bus (gst->priv->playbin);
     gst_bus_add_signal_watch (gst->priv->bus);
     
-    g_signal_connect (gst->priv->bus, "message",
-		      G_CALLBACK (parole_gst_bus_event), gst);
+    gst->priv->sig1 =
+	g_signal_connect (gst->priv->bus, "message",
+			  G_CALLBACK (parole_gst_bus_event), gst);
 		      
     /* 
      * Handling 'prepare-xwindow-id' message async causes XSync 
      * error in some occasions So we handle this message synchronously
      */
     gst_bus_set_sync_handler (gst->priv->bus, gst_bus_sync_signal_handler, gst);
-    g_signal_connect (gst->priv->bus, "sync-message::element",
-		      G_CALLBACK (parole_gst_element_message_sync), gst);
+    gst->priv->sig2 =
+	g_signal_connect (gst->priv->bus, "sync-message::element",
+			  G_CALLBACK (parole_gst_element_message_sync), gst);
 
     /*
      * Handle stream info changes, this can happen on live/radio stream.
@@ -1795,6 +1798,24 @@ void parole_gst_terminate (ParoleGst *gst)
     parole_gst_terminate_internal (gst, TRUE);
 }
 
+void parole_gst_shutdown (ParoleGst *gst)
+{
+    if ( g_signal_handler_is_connected (gst->priv->playbin, gst->priv->sig1) )
+        g_signal_handler_disconnect (gst->priv->playbin, gst->priv->sig1);
+        
+    if ( g_signal_handler_is_connected (gst->priv->playbin, gst->priv->sig2) )
+        g_signal_handler_disconnect (gst->priv->playbin, gst->priv->sig2);
+
+    g_object_unref (gst->priv->bus);
+    
+    if ( gst->priv->vis_sink )
+        g_object_unref (gst->priv->vis_sink);
+        
+    gst_element_set_state (gst->priv->playbin, GST_STATE_VOID_PENDING);
+
+    g_object_unref (gst->priv->playbin);
+}
+
 void parole_gst_seek (ParoleGst *gst, gdouble pos)
 {
     gint64 seek;
diff --git a/parole/parole-gst.h b/parole/parole-gst.h
index 7fa10e5..a51be66 100644
--- a/parole/parole-gst.h
+++ b/parole/parole-gst.h
@@ -98,6 +98,8 @@ void			parole_gst_stop            	(ParoleGst *gst);
 
 void			parole_gst_terminate	   	(ParoleGst *gst);
 
+void			parole_gst_shutdown	   	(ParoleGst *gst);
+
 void			parole_gst_seek		   	(ParoleGst *gst,
 							 gdouble pos);
 
diff --git a/parole/parole-player.c b/parole/parole-player.c
index b66a287..1d5f8ed 100644
--- a/parole/parole-player.c
+++ b/parole/parole-player.c
@@ -535,6 +535,7 @@ static void
 parole_player_quit (ParolePlayer *player)
 {
     parole_media_list_save_list (player->priv->list);
+    parole_gst_shutdown (PAROLE_GST (player->priv->gst));
     gtk_widget_destroy (player->priv->window);
     g_object_unref (player);
     gtk_main_quit ();
@@ -1222,7 +1223,6 @@ parole_player_finalize (GObject *object)
 
     TRACE ("start");
 
-    g_object_unref (player->priv->gst);
     g_object_unref (player->priv->status);
     g_object_unref (player->priv->disc);
     g_object_unref (player->priv->disc_menu);
@@ -1388,12 +1388,6 @@ parole_player_init (ParolePlayer *player)
 			      G_CALLBACK (parole_player_session_die_cb), player);
     
     player->priv->gst = parole_gst_new ();
-    /*
-     * Since ParoleGst is derived from GtkWidget and packed in the media output
-     * box the destroy event on the window will destroy the ParoleGst widget
-     * so we ref it to clean up the gst objects before quitting.
-     */
-    g_object_ref (player->priv->gst);
     
     player->priv->status = parole_statusbar_new ();
     player->priv->disc = parole_disc_new ();



More information about the Xfce4-commits mailing list