[rhythmbox] playbin2: revert hacky fix for bug #585595, fix it properly



commit e8d83cdfb1ba93bda180eb7d55f10b8a1642175b
Author: Jonathan Matthew <jonathan d14n org>
Date:   Thu Jul 9 20:50:12 2009 +1000

    playbin2: revert hacky fix for bug #585595, fix it properly
    
    This adds a parameter to the player backend EOS signal indicating
    whether the signal is being emitted early to allow a track transition.
    We only allow playback to be stopped on real EOS signals.

 backends/gstreamer/rb-player-gst-xfade.c |    2 +-
 backends/gstreamer/rb-player-gst.c       |   14 ++------------
 backends/rb-player.c                     |   14 +++++++++-----
 backends/rb-player.h                     |    5 +++--
 lib/rb-marshal.list                      |    1 +
 shell/rb-shell-player.c                  |    8 +++++---
 6 files changed, 21 insertions(+), 23 deletions(-)
---
diff --git a/backends/gstreamer/rb-player-gst-xfade.c b/backends/gstreamer/rb-player-gst-xfade.c
index 44638e7..101ba0c 100644
--- a/backends/gstreamer/rb-player-gst-xfade.c
+++ b/backends/gstreamer/rb-player-gst-xfade.c
@@ -1787,7 +1787,7 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
 			stream->needs_unlink = TRUE;
 			if (stream->state != REUSING) {
 				rb_debug ("got EOS message for stream %s -> PENDING_REMOVE", stream->uri);
-				_rb_player_emit_eos (RB_PLAYER (player), stream->stream_data);
+				_rb_player_emit_eos (RB_PLAYER (player), stream->stream_data, FALSE);
 				stream->state = PENDING_REMOVE;
 
 				unlink_blocked_cb (stream->src_pad, TRUE, stream);
diff --git a/backends/gstreamer/rb-player-gst.c b/backends/gstreamer/rb-player-gst.c
index 3626189..2dbf024 100644
--- a/backends/gstreamer/rb-player-gst.c
+++ b/backends/gstreamer/rb-player-gst.c
@@ -149,7 +149,7 @@ about_to_finish_cb (GstElement *playbin, RBPlayerGst *player)
 	/* emit EOS now and hope we get something to play */
 	player->priv->current_track_finishing = TRUE;
 
-	_rb_player_emit_eos (RB_PLAYER (player), player->priv->stream_data);
+	_rb_player_emit_eos (RB_PLAYER (player), player->priv->stream_data, TRUE);
 }
 
 static gboolean
@@ -278,8 +278,7 @@ bus_cb (GstBus *bus, GstMessage *message, RBPlayerGst *mp)
 	}
 
 	case GST_MESSAGE_EOS:
-		rb_debug ("got EOS.. why haven't you told me what to do yet?");
-		_rb_player_emit_eos (RB_PLAYER (mp), mp->priv->stream_data);
+		_rb_player_emit_eos (RB_PLAYER (mp), mp->priv->stream_data, FALSE);
 		break;
 
 	case GST_MESSAGE_TAG: {
@@ -651,15 +650,6 @@ impl_close (RBPlayer *player, const char *uri, GError **error)
 		return TRUE;
 	}
 
-	if (mp->priv->current_track_finishing) {
-		/* this is a bit of a hack.
-		 * about-to-finish should result in either a track change or nothing.
-		 */
-		rb_debug ("not closing in about-to-finish callback");
-		mp->priv->current_track_finishing = FALSE;
-		return TRUE;
-	}
-
 	mp->priv->playing = FALSE;
 	mp->priv->buffering = FALSE;
 
diff --git a/backends/rb-player.c b/backends/rb-player.c
index 9f4d3af..3583d56 100644
--- a/backends/rb-player.c
+++ b/backends/rb-player.c
@@ -92,8 +92,11 @@ rb_player_interface_init (RBPlayerIface *iface)
 	 * RBPlayer::eos:
 	 * @player: the #RBPlayer
 	 * @stream_data: the data associated with the stream that finished
+	 * @early: if %TRUE, the EOS notification should only be used for track changes.
 	 *
-	 * The 'eos' signal is emitted when a stream finishes.
+	 * The 'eos' signal is emitted when a stream finishes, or in some cases, when it
+	 * is about to finish (with @early set to %TRUE) to allow for a new track to be
+	 * played immediately afterwards.
 	 **/
 	signals[EOS] =
 		g_signal_new ("eos",
@@ -101,9 +104,9 @@ rb_player_interface_init (RBPlayerIface *iface)
 			      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
 			      G_STRUCT_OFFSET (RBPlayerIface, eos),
 			      NULL, NULL,
-			      g_cclosure_marshal_VOID__POINTER,
+			      rb_marshal_VOID__POINTER_BOOLEAN,
 			      G_TYPE_NONE,
-			      1, G_TYPE_POINTER);
+			      2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
 
 	/**
 	 * RBPlayer::info:
@@ -565,14 +568,15 @@ rb_player_new (gboolean want_crossfade, GError **error)
  * _rb_player_emit_eos:
  * @player: a #RBPlayer implementation
  * @stream_data: data associated with the stream
+ * @early: whether this is an early EOS notification
  *
  * Emits the 'eos' signal for a stream.  To be used by
  * implementations only.
  */
 void
-_rb_player_emit_eos (RBPlayer *player, gpointer stream_data)
+_rb_player_emit_eos (RBPlayer *player, gpointer stream_data, gboolean early)
 {
-	g_signal_emit (player, signals[EOS], 0, stream_data);
+	g_signal_emit (player, signals[EOS], 0, stream_data, early);
 }
 
 /**
diff --git a/backends/rb-player.h b/backends/rb-player.h
index 0936074..00554b3 100644
--- a/backends/rb-player.h
+++ b/backends/rb-player.h
@@ -114,7 +114,8 @@ struct _RBPlayerIface
 	void		(*playing_stream)	(RBPlayer *player,
 						 gpointer stream_data);
 	void		(*eos)			(RBPlayer *player,
-						 gpointer stream_data);
+						 gpointer stream_data,
+						 gboolean early);
 	void		(*info)			(RBPlayer *player,
 						 gpointer stream_data,
 						 RBMetaDataField field,
@@ -174,7 +175,7 @@ gint64		rb_player_get_time   (RBPlayer *player);
 gboolean	rb_player_multiple_open (RBPlayer *player);
 
 /* only to be used by subclasses */
-void	_rb_player_emit_eos (RBPlayer *player, gpointer stream_data);
+void	_rb_player_emit_eos (RBPlayer *player, gpointer stream_data, gboolean early);
 void	_rb_player_emit_info (RBPlayer *player, gpointer stream_data, RBMetaDataField field, GValue *value);
 void	_rb_player_emit_buffering (RBPlayer *player, gpointer stream_data, guint progress);
 void	_rb_player_emit_error (RBPlayer *player, gpointer stream_data, GError *error);
diff --git a/lib/rb-marshal.list b/lib/rb-marshal.list
index f7a26e9..d5f8ca5 100644
--- a/lib/rb-marshal.list
+++ b/lib/rb-marshal.list
@@ -26,6 +26,7 @@ VOID:INT64
 VOID:OBJECT,INT,INT
 VOID:OBJECT,INT,INT,BOXED,UINT,UINT
 VOID:OBJECT,INT,POINTER
+VOID:POINTER,BOOLEAN
 VOID:POINTER,INT
 VOID:POINTER,INT64,INT64
 VOID:POINTER,INT,POINTER
diff --git a/shell/rb-shell-player.c b/shell/rb-shell-player.c
index c2cc720..009adb0 100644
--- a/shell/rb-shell-player.c
+++ b/shell/rb-shell-player.c
@@ -880,6 +880,7 @@ rb_shell_player_slider_dragging_cb (GObject *header, GParamSpec *pspec, RBShellP
 static void
 rb_shell_player_handle_eos (RBPlayer *player,
 			    RhythmDBEntry *entry,
+			    gboolean early,
 			    RBShellPlayer *shell_player)
 {
 	const char *location;
@@ -901,7 +902,8 @@ rb_shell_player_handle_eos (RBPlayer *player,
 		rb_debug ("got unexpected eos for %s", location);
 	} else {
 		rb_debug ("handling eos for %s", location);
-		rb_shell_player_handle_eos_unlocked (shell_player, entry, TRUE);
+		/* don't allow playback to be stopped on early EOS notifications */
+		rb_shell_player_handle_eos_unlocked (shell_player, entry, (early == FALSE));
 	}
 
 	GDK_THREADS_LEAVE ();
@@ -1624,7 +1626,7 @@ static gboolean
 do_next_idle (RBShellPlayer *player)
 {
 	/* use the EOS callback, so that EOF_SOURCE_ conditions are handled properly */
-	rb_shell_player_handle_eos (NULL, NULL, player);
+	rb_shell_player_handle_eos (NULL, NULL, FALSE, player);
 	player->priv->do_next_idle_id = 0;
 
 	return FALSE;
@@ -3635,7 +3637,7 @@ missing_plugins_cb (RBPlayer *player,
 		rb_player_close (retry_data->player->priv->mmplayer, NULL, NULL);
 	} else {
 		rb_debug ("not processing missing plugins; simulating EOS");
-		rb_shell_player_handle_eos (NULL, NULL, retry_data->player);
+		rb_shell_player_handle_eos (NULL, NULL, FALSE, retry_data->player);
 	}
 
 	g_closure_sink (retry);



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