[rhythmbox] player-gst: pretend playing time is 0 during track changes (bug #584804)



commit 0b217fa895f03cf88d3bb47b7ceffac948d849b7
Author: Jonathan Matthew <jonathan d14n org>
Date:   Thu Jun 11 00:39:57 2009 +1000

    player-gst: pretend playing time is 0 during track changes (bug #584804)
    
    Since we don't know exactly when playbin2 changes from one track to the
    next, we can't emit the playing-stream signal at the right point, and we
    can't answer playing position queries properly either.  So, we emit the
    playing-stream signal when we set the new URI and pretend the playback
    position is 0 (in the new stream) until the next timer tick.
---
 backends/gstreamer/rb-player-gst.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/backends/gstreamer/rb-player-gst.c b/backends/gstreamer/rb-player-gst.c
index a39350e..20dd373 100644
--- a/backends/gstreamer/rb-player-gst.c
+++ b/backends/gstreamer/rb-player-gst.c
@@ -98,6 +98,7 @@ struct _RBPlayerGstPrivate
 
 	gboolean stream_change_pending;
 	gboolean current_track_finishing;
+	gboolean fake_playing_position;
 
 	gboolean emitted_error;
 
@@ -122,6 +123,7 @@ tick_timeout (RBPlayerGst *mp)
 				      mp->priv->stream_data,
 				      rb_player_get_time (RB_PLAYER (mp)),
 				      -1);
+		mp->priv->fake_playing_position = FALSE;
 	}
 	return TRUE;
 }
@@ -729,6 +731,12 @@ impl_play (RBPlayer *player, RBPlayerPlayType play_type, gint64 crossfade, GErro
 		g_object_set (mp->priv->playbin, "uri", mp->priv->uri, NULL);
 		result = TRUE;
 
+		/* since we don't know exactly when the change occurs, pretend the playing position
+		 * is 0 until the next tick.  otherwise we sometimes get the playing position from the
+		 * previous track.
+		 */
+		mp->priv->fake_playing_position = TRUE;
+
 	} else {
 		gboolean reused = FALSE;
 
@@ -937,7 +945,10 @@ impl_get_time (RBPlayer *player)
 {
 	RBPlayerGst *mp = RB_PLAYER_GST (player);
 
-	if (mp->priv->playbin != NULL) {
+	if (mp->priv->fake_playing_position) {
+		/* track transition occurring, so pretend we're at the start of the new one */
+		return 0;
+	} else if (mp->priv->playbin != NULL) {
 		gint64 position = -1;
 		GstFormat fmt = GST_FORMAT_TIME;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]