[banshee/gapless-ng: 374/836] [libbanshee] Rename player->timeout_id to player->next_track_starting_timer_id to make it more obvio



commit 0cc195fc1524a549e9e65b16e54a85adc7fd0ced
Author: Christopher James Halse Rogers <raof ubuntu com>
Date:   Wed Nov 11 11:17:44 2009 +1100

    [libbanshee] Rename player->timeout_id to player->next_track_starting_timer_id to make it more obvious what it does

 libbanshee/banshee-player-pipeline.c |    6 ++++--
 libbanshee/banshee-player-private.h  |    6 +++++-
 libbanshee/banshee-player.c          |   22 +++++++++++++---------
 3 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/libbanshee/banshee-player-pipeline.c b/libbanshee/banshee-player-pipeline.c
index 779fc05..b5359e0 100644
--- a/libbanshee/banshee-player-pipeline.c
+++ b/libbanshee/banshee-player-pipeline.c
@@ -221,7 +221,7 @@ bp_next_track_starting (gpointer player)
     if (((BansheePlayer *)player)->next_track_starting_cb != NULL) {
         ((BansheePlayer *)player)->next_track_starting_cb (player);
     }
-    ((BansheePlayer *)player)->timeout_id = 0;
+    ((BansheePlayer *)player)->next_track_starting_timer_id = 0;
     return FALSE;
 }
 
@@ -230,7 +230,9 @@ static void bp_about_to_finish_callback (GstElement *playbin, BansheePlayer *pla
     g_return_if_fail (IS_BANSHEE_PLAYER (player));
     // Playbin2 doesn't (yet) have any way to notify us when the current track has actually finished playing on the
     // hardware.  Fake this for now by adding a timer with length equal to the hardware buffer.
-    player->timeout_id = g_timeout_add (((guint64)BP_BUFFER_LEN_MICROSECONDS) / 1000, &bp_next_track_starting, player);
+    player->next_track_starting_timer_id = g_timeout_add (((guint64)BP_BUFFER_LEN_MICROSECONDS) / 1000, 
+                                                          &bp_next_track_starting, 
+                                                          player);
     
     if (player->about_to_finish_cb != NULL) {
         player->about_to_finish_cb (player);
diff --git a/libbanshee/banshee-player-private.h b/libbanshee/banshee-player-private.h
index 1512a84..b196d54 100644
--- a/libbanshee/banshee-player-private.h
+++ b/libbanshee/banshee-player-private.h
@@ -165,7 +165,11 @@ struct BansheePlayer {
     gdouble track_gain;
     gdouble track_peak;
     
-    guint timeout_id;
+    // Work around playbin2 not giving any notification about when a
+    // track changes.  We know how long playbin's buffer is, so we know
+    // how long after about-to-finish is raised the track will end.
+    // Use this timer to fire a signal when that happens.
+    guint next_track_starting_timer_id;
 };
 
 #endif /* _BANSHEE_PLAYER_PRIVATE_H */
diff --git a/libbanshee/banshee-player.c b/libbanshee/banshee-player.c
index 32efc68..d51c53d 100644
--- a/libbanshee/banshee-player.c
+++ b/libbanshee/banshee-player.c
@@ -180,9 +180,9 @@ bp_stop (BansheePlayer *player, gboolean nullstate)
         state = GST_STATE_NULL;
     }
     
-    if (player->timeout_id != 0) {
-        g_source_remove (player->timeout_id);
-        player->timeout_id = 0;
+    if (player->next_track_starting_timer_id != 0) {
+        g_source_remove (player->next_track_starting_timer_id);
+        player->next_track_starting_timer_id = 0;
     }
     
     bp_debug ("bp_stop: setting state to %s", 
@@ -201,9 +201,9 @@ P_INVOKE void
 bp_play (BansheePlayer *player)
 {
     g_return_if_fail (IS_BANSHEE_PLAYER (player));
-    if (player->timeout_id != 0) {
-        g_source_remove (player->timeout_id);
-        player->timeout_id = 0;
+    if (player->next_track_starting_timer_id != 0) {
+        g_source_remove (player->next_track_starting_timer_id);
+        player->next_track_starting_timer_id = 0;
     }
     bp_pipeline_set_state (player, GST_STATE_PLAYING);
 }
@@ -213,9 +213,13 @@ bp_set_next_track (BansheePlayer *player, const gchar *uri)
 {
     g_return_val_if_fail (IS_BANSHEE_PLAYER (player), FALSE);
     g_return_val_if_fail (player->playbin != NULL, FALSE);
-    if (uri == NULL && player->timeout_id != 0) {
-        g_source_remove (player->timeout_id);
-        player->timeout_id = 0;
+    if (uri == NULL && player->next_track_starting_timer_id != 0) {
+        // URI == NULL indicates that there is not a next track to play.
+        // This means that there will not be a next track *starting*, so
+        // we have to disable the timer so that we don't fire a spurious
+        // next-track-starting signal.
+        g_source_remove (player->next_track_starting_timer_id);
+        player->next_track_starting_timer_id = 0;
         return TRUE;
     }
     g_object_set (G_OBJECT (player->playbin), "uri", uri, NULL);



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