Index: widgets/rb-header.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/widgets/rb-header.c,v
retrieving revision 1.14
diff -u -r1.14 rb-header.c
--- widgets/rb-header.c	26 Jun 2005 21:49:57 -0000	1.14
+++ widgets/rb-header.c	12 Jul 2005 12:09:35 -0000
@@ -54,13 +54,14 @@
 static long rb_header_get_duration (RBHeader *player);
 static void rb_header_set_show_timeline (RBHeader *player,
 			                 gboolean show);
-static gboolean rb_header_sync_time_locked (RBHeader *player);
 static void rb_header_update_elapsed (RBHeader *player);
 static gboolean slider_press_callback (GtkWidget *widget, GdkEventButton *event, RBHeader *player);
 static gboolean slider_moved_callback (GtkWidget *widget, GdkEventMotion *event, RBHeader *player);
 static gboolean slider_release_callback (GtkWidget *widget, GdkEventButton *event, RBHeader *player);
 static void slider_changed_callback (GtkWidget *widget, RBHeader *player);
 
+static void rb_header_tick_cb (RBPlayer *mmplayer, long time, RBHeader *header);
+
 typedef struct
 {
 	long elapsed;
@@ -76,6 +77,7 @@
 	char *urltext, *urllink;
 
 	RBPlayer *mmplayer;
+	gulong tick_id;
 
 	GtkWidget *image;
 	GtkWidget *song;
@@ -101,8 +103,6 @@
 	gboolean urlline_shown;
 	GnomeHRef *url;
 
-	guint timeout;
-	
 	RBHeaderState *state;
 };
 
@@ -110,7 +110,7 @@
 {
 	PROP_0,
 	PROP_DB,
-	PROP_HEADER,
+	PROP_PLAYER,
 	PROP_ENTRY,
 	PROP_TITLE,
 	PROP_URLTEXT,
@@ -175,10 +175,10 @@
 							       "RhythmDBEntry pointer",
 							       G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
-					 PROP_HEADER,
+					 PROP_PLAYER,
 					 g_param_spec_object ("player",
 							      "Player",
-							      "MonkeyMediaPlayer",
+							      "RBPlayer object",
 							      RB_TYPE_PLAYER,
 							      G_PARAM_READWRITE));
 	g_object_class_install_property (object_class,
@@ -317,8 +317,6 @@
 
 	gtk_box_pack_start (GTK_BOX (player), hbox, TRUE, TRUE, 0);
 	gtk_box_pack_end (GTK_BOX (player), align, FALSE, FALSE, 0);
-
-	player->priv->timeout = g_timeout_add (1000, (GSourceFunc) rb_header_sync_time_locked, player);
 }
 
 static void
@@ -333,8 +331,6 @@
 
 	g_return_if_fail (player->priv != NULL);
 
-	g_source_remove (player->priv->timeout);
-
 	g_object_unref (G_OBJECT (player->priv->urlline));
 	g_object_unref (G_OBJECT (player->priv->displaybox));
 	g_object_unref (G_OBJECT (player->priv->timeline));
@@ -360,8 +356,17 @@
 	case PROP_ENTRY:
 		player->priv->entry = g_value_get_pointer (value);
 		break;
-	case PROP_HEADER:
+	case PROP_PLAYER:
+		if (player->priv->mmplayer) {
+			g_signal_handler_disconnect (player->priv->mmplayer,
+						     player->priv->tick_id);
+			player->priv->tick_id = 0;
+		}
 		player->priv->mmplayer = g_value_get_object (value);
+		player->priv->tick_id = g_signal_connect (G_OBJECT (player->priv->mmplayer),
+							  "tick", 
+							  (GCallback) rb_header_tick_cb,
+							  player);
 		break;
 	case PROP_TITLE:
 		g_free (player->priv->title);
@@ -396,7 +401,7 @@
 	case PROP_ENTRY:
 		g_value_set_object (value, player->priv->entry);
 		break;
-	case PROP_HEADER:
+	case PROP_PLAYER:
 		g_value_set_object (value, player->priv->mmplayer);
 		break;
 	case PROP_TITLE:
@@ -665,20 +670,6 @@
 }
 
 gboolean
-rb_header_sync_time_locked (RBHeader *player)
-{
-	gboolean ret;
-
-	GDK_THREADS_ENTER ();
-
-	ret = rb_header_sync_time (player);
-
-	GDK_THREADS_LEAVE ();
-
-	return ret;
-}
-
-gboolean
 rb_header_sync_time (RBHeader *player)
 {
 	int seconds;
@@ -694,8 +685,7 @@
 
 	player->priv->state->duration = duration =
 		rb_header_get_duration (player);
-	player->priv->state->elapsed = seconds =
-		rb_player_get_time (player->priv->mmplayer);
+	seconds = player->priv->state->elapsed;
 
 	if (duration > -1) {
 		double progress = 0.0;
@@ -855,11 +845,10 @@
 rb_header_get_elapsed_string (RBHeader *player)
 {
 	int seconds = 0, minutes = 0, seconds2 = -1, minutes2 = -1;
-	guint elapsed = rb_player_get_time (player->priv->mmplayer);
 
-	if (elapsed > 0) {
-		minutes = elapsed / 60;
-		seconds = elapsed % 60;
+	if (player->priv->state->elapsed > 0) {
+		minutes = player->priv->state->elapsed / 60;
+		seconds = player->priv->state->elapsed % 60;
 	}
 
 	if (player->priv->state->duration > 0) {
@@ -868,7 +857,7 @@
 		if (eel_gconf_get_boolean (CONF_UI_TIME_DISPLAY)) {
 			return g_strdup_printf (_("%d:%02d of %d:%02d"), minutes, seconds, minutes2, seconds2);
 		} else {
-			int remaining = player->priv->state->duration - elapsed;
+			int remaining = player->priv->state->duration - player->priv->state->elapsed;
 			int remaining_minutes = remaining / 60;
 			/* remaining could conceivably be negative. This would
 			 * be a bug, but the elapsed time will display right
@@ -895,3 +884,17 @@
 	gtk_label_set_text (GTK_LABEL (player->priv->elapsed), elapsed_text);
 	g_free (elapsed_text);
 }
+
+static void rb_header_tick_cb (RBPlayer *mmplayer, long elapsed, RBHeader *header)
+{
+	gboolean sync = (elapsed != header->priv->state->elapsed);
+	header->priv->state->elapsed = elapsed;
+	
+	if (sync) {
+		GDK_THREADS_ENTER ();
+
+		rb_header_sync_time (header);
+
+		GDK_THREADS_LEAVE ();
+	}
+}
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	12 Jul 2005 12:09:36 -0000
@@ -55,9 +55,6 @@
 
 	float cur_volume;
 
-	GTimer *timer;
-	long timer_add;
-
 	guint tick_timeout_id;
 };
 
@@ -171,9 +168,6 @@
 		rb_player_gst_free_playbin (mp);
 	}
 
-	if (mp->priv->timer)
-		g_timer_destroy (mp->priv->timer);
-	
 	g_free (mp->priv);
 
 	G_OBJECT_CLASS (rb_player_parent_class)->finalize (object);
@@ -346,12 +361,6 @@
 		mp->priv->cur_volume = 0;
 	rb_player_set_volume (mp, mp->priv->cur_volume);
 
-	if (mp->priv->timer)
-		g_timer_destroy (mp->priv->timer);
-	mp->priv->timer = g_timer_new ();
-	g_timer_stop (mp->priv->timer);
-	g_timer_reset (mp->priv->timer);
-	mp->priv->timer_add = 0;
 	rb_debug ("pipeline construction complete");
 	return;
 missing_element:
@@ -412,7 +421,6 @@
  				     _("Could not start pipeline playing"));
  			return FALSE;
 		}
-		g_timer_start (mp->priv->timer);
 	} else {
 		rb_debug ("PAUSING pipeline");
 		if (gst_element_set_state (mp->priv->playbin,
@@ -452,10 +460,6 @@
 	g_object_set (G_OBJECT (mp->priv->playbin), "uri", uri, NULL);	
 	mp->priv->uri = g_strdup (uri);
 
-	g_timer_stop (mp->priv->timer);
-	g_timer_reset (mp->priv->timer);
-	mp->priv->timer_add = 0;
-
 	if (!rb_player_sync_pipeline (mp, error)) {
 		rb_player_close (mp, NULL);
 	}
@@ -515,10 +519,6 @@
 
 	g_return_if_fail (mp->priv->playbin != NULL);
 
-	mp->priv->timer_add += floor (g_timer_elapsed (mp->priv->timer, NULL) + 0.5);
-	g_timer_stop (mp->priv->timer);
-	g_timer_reset (mp->priv->timer);
-
 	rb_player_sync_pipeline (mp, NULL);
 }
 
@@ -627,9 +627,6 @@
 
 	if (mp->priv->playing)
 		gst_element_set_state (mp->priv->playbin, GST_STATE_PLAYING);
-
-	g_timer_reset (mp->priv->timer);
-	mp->priv->timer_add = time;
 }
 
 long
@@ -637,8 +634,12 @@
 {
 	g_return_val_if_fail (RB_IS_PLAYER (mp), -1);
 
-	if (mp->priv->playbin != NULL)
-		return (long) floor (g_timer_elapsed (mp->priv->timer, NULL) + 0.5) + mp->priv->timer_add;
-	else
+	if (mp->priv->playbin != NULL) {
+		gint64 gst_position;
+		GstFormat fmt = GST_FORMAT_TIME;
+		gst_element_query (mp->priv->playbin, GST_QUERY_POSITION, &fmt, &gst_position);
+	
+		return (long)(gst_position / (1000*1000*1000));
+	} else
 		return -1;
 }
