? remote/dbus/rb-remote-dbus.loT
Index: configure.ac
===================================================================
RCS file: /cvs/gnome/rhythmbox/configure.ac,v
retrieving revision 1.146
diff -u -r1.146 configure.ac
--- configure.ac	25 Jun 2005 21:06:26 -0000	1.146
+++ configure.ac	6 Jul 2005 16:51:25 -0000
@@ -125,8 +125,8 @@
 dnl And we can also ask for the right version of gstreamer
 HAVE_SOUNDSYSTEM=no
 
-GST_MAJORMINOR=0.8
-GST_REQUIRED_VERSION=0.8.2
+GST_MAJORMINOR=0.9
+GST_REQUIRED_VERSION=0.9.0
 PKG_CHECK_MODULES(SOUNDSYSTEM, \
 	gstreamer-$GST_MAJORMINOR >= $GST_REQUIRED_VERSION gstreamer-libs-$GST_MAJORMINOR >= $GST_REQUIRED_VERSION
 	gstreamer-control-$GST_MAJORMINOR >= $GST_REQUIRED_VERSION gstreamer-gconf-$GST_MAJORMINOR >= $GST_REQUIRED_VERSION,
Index: metadata/rb-metadata-gst.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/metadata/rb-metadata-gst.c,v
retrieving revision 1.40
diff -u -r1.40 rb-metadata-gst.c
--- metadata/rb-metadata-gst.c	6 Jul 2005 09:24:11 -0000	1.40
+++ metadata/rb-metadata-gst.c	6 Jul 2005 16:51:31 -0000
@@ -98,24 +98,25 @@
 static GstElement *
 rb_add_id3_tagger (GstBin *pipeline, GstElement *element)
 {
-	GstElement *spider;
-	GstElement *tagger;
+	GstElement *spider = NULL;
+	GstElement *tagger = NULL;
+	GstElement *filter = NULL;
 	GstCaps *filtercaps = NULL;
 
-	if (!(spider = gst_element_factory_make ("spider", "spider")))
-		return NULL;
-
-	if (!(tagger = gst_element_factory_make ("id3mux", "id3mux")))
-		/* FIXME: leaks spider */
-		return NULL;
+	if (!(spider = gst_element_factory_make ("spider", "spider")) ||
+	    !(tagger = gst_element_factory_make ("id3mux", "id3mux")) ||
+	    !(filter = gst_element_factory_make ("capsfilter", NULL)) ||
+	    !(filtercaps = gst_caps_new_simple ("audio/mpeg", NULL))) {
+	    gst_object_unref (GST_OBJECT (spider));
+	    gst_object_unref (GST_OBJECT (tagger));
+	    gst_object_unref (GST_OBJECT (filter));
+	    return NULL;
+	}
 
-	gst_bin_add (GST_BIN (pipeline), spider);
-	gst_bin_add (GST_BIN (pipeline), tagger);
-	
-	gst_element_link_many (element, spider, NULL);
-	filtercaps = gst_caps_new_simple ("audio/mpeg", NULL);
-	gst_element_link_filtered (spider, tagger, filtercaps);
-	gst_caps_free (filtercaps);
+	gst_bin_add_many (GST_BIN (pipeline), spider, tagger, filter, NULL);
+	g_object_set (G_OBJECT (filter), "filter-caps", filtercaps, NULL);
+	gst_element_link_many (element, spider, filter, tagger, NULL);
+	gst_caps_unref (filtercaps);
 
 	return tagger;
 
@@ -506,7 +507,7 @@
 		}
 	}
 
-	gst_caps_free (caps);
+	gst_caps_unref (caps);
 }
 
 static void
@@ -533,6 +534,51 @@
 	return elem;
 }
 
+static void
+rb_metadata_event_loop (RBMetaData *md, GstElement *pipe)
+{
+  GstBus *bus;
+  GstMessageType revent;
+  GstMessage *message = NULL;
+  gboolean done = FALSE;
+
+  bus = gst_element_get_bus (GST_ELEMENT (pipe));
+
+  while (!done) {
+    revent = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
+
+    message = gst_bus_pop (bus);
+    g_assert (message != NULL);
+
+    switch (revent) {
+      case GST_MESSAGE_EOS:
+	md->priv->eos = TRUE;
+	done = TRUE;
+	break;
+      case GST_MESSAGE_WARNING:
+      case GST_MESSAGE_ERROR:{
+        GError *gerror;
+        gchar *debug;
+
+        gst_message_parse_error (message, &gerror, &debug);
+	rb_debug ("caught error: %s ", gerror->message);
+	md->priv->error = g_error_new_literal (RB_METADATA_ERROR,
+					       RB_METADATA_ERROR_GENERAL,
+					       gerror->message);
+
+        gst_message_unref (message);
+        g_error_free (gerror);
+        g_free (debug);
+	done = TRUE;
+	break;
+      }
+      default:
+        break;
+    }
+    gst_message_unref (message);
+  }
+}
+
 void
 rb_metadata_load (RBMetaData *md,
 		  const char *uri,
@@ -589,11 +635,9 @@
 	g_object_set (G_OBJECT (gnomevfssrc), "location", uri, NULL);
 	g_object_set (G_OBJECT (md->priv->sink), "signal-handoffs", TRUE, NULL);
  
- 	g_signal_connect_object (pipeline, "error", G_CALLBACK (rb_metadata_gst_error_cb), md, 0);
  	g_signal_connect_object (pipeline, "found-tag", G_CALLBACK (rb_metadata_gst_found_tag), md, 0);
 
 	g_signal_connect_object (md->priv->sink, "handoff", G_CALLBACK (rb_metadata_gst_fakesink_handoff_cb), md, 0);
-	g_signal_connect_object (md->priv->sink, "eos", G_CALLBACK (rb_metadata_gst_eos_cb), md, 0);
 
  	g_signal_connect_object (decodebin, "new-decoded-pad", G_CALLBACK (rb_metadata_gst_new_decoded_pad_cb), md, 0);
  	g_signal_connect_object (decodebin, "unknown-type", G_CALLBACK (rb_metadata_gst_unknown_type_cb), md, 0);
@@ -611,11 +655,8 @@
 
 	md->priv->pipeline = pipeline;
 	gst_element_set_state (pipeline, GST_STATE_PLAYING);
-	while (gst_bin_iterate (GST_BIN (pipeline))
-	       && md->priv->error == NULL
-	       && !md->priv->handoff
-	       && !md->priv->eos)
-		;
+
+	rb_metadata_event_loop (md, GST_ELEMENT (pipeline));
 
 	if (md->priv->handoff) {
 		/* We caught the first buffer, which means the decoder should have read all
@@ -625,10 +666,10 @@
 			GstFormat format = GST_FORMAT_TIME;
 			gint64 length;
 			
-			if (gst_element_query (md->priv->sink, GST_QUERY_TOTAL,
-					       &format, &length)) {
+			if (gst_element_query_position (md->priv->sink, &format, NULL, &length)) {
 				GValue *newval = g_new0 (GValue, 1);
 				
+				g_assert (format == GST_FORMAT_TIME);
 				rb_debug ("duration query succeeded");
 				
 				g_value_init (newval, G_TYPE_ULONG);
@@ -803,11 +844,9 @@
 
 	md->priv->pipeline = pipeline;
 	gst_element_set_state (pipeline, GST_STATE_PLAYING);
-	while (gst_bin_iterate (GST_BIN (pipeline))
-	       && md->priv->error == NULL
-	       && !md->priv->eos)
-		;
+	rb_metadata_event_loop (md, GST_ELEMENT (pipeline));
 	gst_element_set_state (pipeline, GST_STATE_NULL);
+
 	if (md->priv->error) {
 		g_propagate_error (error, md->priv->error);
 		goto out_error;
Index: player/rb-player-gst.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/player/rb-player-gst.c,v
retrieving revision 1.35
diff -u -r1.35 rb-player-gst.c
--- player/rb-player-gst.c	14 Jun 2005 12:09:54 -0000	1.35
+++ player/rb-player-gst.c	6 Jul 2005 16:51:33 -0000
@@ -162,9 +162,6 @@
 	g_source_remove (mp->priv->tick_timeout_id);
 
 	if (mp->priv->playbin) {
-		g_signal_handler_disconnect (G_OBJECT (mp->priv->playbin),
-					     mp->priv->error_signal_id);
-		
 		gst_element_set_state (mp->priv->playbin,
 				       GST_STATE_NULL);
 		
@@ -190,78 +187,6 @@
 }
 
 static gboolean
-eos_signal_idle (RBPlayer *mp)
-{
-	g_signal_emit (G_OBJECT (mp), rb_player_signals[EOS], 0);
-
-	g_object_unref (G_OBJECT (mp));
-
-	return FALSE;
-}
-
-static gboolean
-error_signal_idle (RBPlayerSignal *signal)
-{
-	g_signal_emit (G_OBJECT (signal->object),
-		       rb_player_signals[ERROR], 0,
-		       signal->error);
-
-	/* close if not already closing */
-	if (signal->object->priv->uri != NULL)
-		rb_player_close (signal->object, NULL);
-
-	g_object_unref (G_OBJECT (signal->object));
-	g_error_free (signal->error);
-	g_free (signal);
-
-	return FALSE;
-}
-
-static void
-eos_cb (GstElement *element,
-	RBPlayer *mp)
-{
-	g_object_ref (G_OBJECT (mp));
-	g_idle_add ((GSourceFunc) eos_signal_idle, mp);
-}
-
-static void
-rb_player_gst_signal_error (RBPlayer *mp, int code, const char *msg)
-{
-	RBPlayerSignal *signal;
-
-	signal = g_new0 (RBPlayerSignal, 1);
-	signal->object = mp;
-	signal->error = g_error_new_literal (RB_PLAYER_ERROR,
-					     code,
-					     msg);
-
-	g_object_ref (G_OBJECT (mp));
-
-	g_idle_add ((GSourceFunc) error_signal_idle, signal);
-}
-
-static void
-error_cb (GstElement *element,
-	  GstElement *source,
-	  GError *error,
-	  gchar *debug,
-	  RBPlayer *mp)
-{
-	int code;
-
-	if ((error->domain == GST_CORE_ERROR)
-	    || (error->domain == GST_LIBRARY_ERROR)
-	    || (error->code == GST_RESOURCE_ERROR_BUSY)) {
-		code = RB_PLAYER_ERROR_NO_AUDIO;
-	} else {
-		code = RB_PLAYER_ERROR_GENERAL;
-	}
-
-	rb_player_gst_signal_error (mp, code, error->message);
-}
-
-static gboolean
 info_signal_idle (RBPlayerSignal *signal)
 {
 	g_signal_emit (G_OBJECT (signal->object),
@@ -302,6 +227,53 @@
 	}
 }
 
+static gboolean
+rb_player_bus_cb (GstBus * bus, GstMessage * message,
+    RBPlayer *mp)
+{
+    g_return_val_if_fail (mp != NULL, FALSE);
+
+    switch (GST_MESSAGE_TYPE (message)) {
+	case GST_MESSAGE_ERROR: {
+	    char *debug;
+	    GError *error, *sig_error;
+	    int code;
+
+	    gst_message_parse_error (message, &error, &debug);
+
+	    if ((error->domain == GST_CORE_ERROR)
+		|| (error->domain == GST_LIBRARY_ERROR)
+		|| (error->code == GST_RESOURCE_ERROR_BUSY)) {
+		code = RB_PLAYER_ERROR_NO_AUDIO;
+	    } else {
+                code = RB_PLAYER_ERROR_GENERAL;
+	    }
+
+	    sig_error = g_error_new_literal (RB_PLAYER_ERROR,
+                                             code,
+                                             error->message);
+	    g_signal_emit (G_OBJECT (mp),
+			rb_player_signals[ERROR], 0,
+			sig_error);
+
+	    /* close if not already closing */
+	    if (mp->priv->uri != NULL)
+                rb_player_close (mp, NULL);
+
+	    g_error_free (error);
+	    g_free (debug);
+	    break;
+        }
+	case GST_MESSAGE_EOS:
+	    g_signal_emit (G_OBJECT (mp), rb_player_signals[EOS], 0);
+	    break;
+	default:
+	    break;
+    }
+
+    return TRUE;
+}
+
 static void
 rb_player_construct (RBPlayer *mp, GError **error)
 {
@@ -319,11 +291,8 @@
 				 G_CALLBACK (deep_notify_cb),
 				 mp, 0);
 
-	mp->priv->error_signal_id =
-		g_signal_connect_object (G_OBJECT (mp->priv->playbin),
-					 "error",
-					 G_CALLBACK (error_cb),
-					 mp, 0);
+	gst_bus_add_watch (gst_element_get_bus (GST_ELEMENT (mp->priv->playbin)),
+			     (GstBusHandler) rb_player_bus_cb, mp);
 
 	/* Output sink */
 	sink = gst_gconf_get_default_audio_sink ();
@@ -337,8 +306,6 @@
 	}
 
 	g_object_set (G_OBJECT (mp->priv->playbin), "audio-sink", sink, NULL);
-	g_signal_connect_object (G_OBJECT (mp->priv->playbin), "eos",
-				 G_CALLBACK (eos_cb), mp, 0);
 
 	if (mp->priv->cur_volume > 1.0)
 		mp->priv->cur_volume = 1.0;
@@ -405,7 +372,7 @@
 	if (mp->priv->playing) {
  		rb_debug ("PLAYING pipeline");
  		if (gst_element_set_state (mp->priv->playbin,
- 					   GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+ 					   GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
  			g_set_error (error,
  				     RB_PLAYER_ERROR,
  				     RB_PLAYER_ERROR_GENERAL,
@@ -416,7 +383,7 @@
 	} else {
 		rb_debug ("PAUSING pipeline");
 		if (gst_element_set_state (mp->priv->playbin,
-					   GST_STATE_PAUSED) == GST_STATE_FAILURE) {
+					   GST_STATE_PAUSED) != GST_STATE_SUCCESS) {
 			g_set_error (error,
 				     RB_PLAYER_ERROR,
 				     RB_PLAYER_ERROR_GENERAL,
