Code

player_command: implement setup_seek() without a song object
authorMax Kellermann <max@duempel.org>
Mon, 2 Nov 2009 19:57:38 +0000 (20:57 +0100)
committerMax Kellermann <max@duempel.org>
Mon, 2 Nov 2009 19:57:38 +0000 (20:57 +0100)
Get the current song id from mpd_status_get_song_id().

src/player_command.c
src/screen.c
src/status_bar.c

index 505d2fc596d47709089fbb4bef3cbda925a3a1d5..a366b2a3003cccd08cdd3c8a0593b54ccc665f14 100644 (file)
@@ -85,14 +85,11 @@ cancel_seek_timer(void)
 static bool
 setup_seek(struct mpdclient *c)
 {
-       const struct mpd_song *song;
-
-       song = mpdclient_get_current_song(c);
-       if (song == NULL)
+       if (!mpdclient_is_playing(c))
                return false;
 
-       if (seek_id != (int)mpd_song_get_id(song)) {
-               seek_id = mpd_song_get_id(song);
+       if (seek_id != (int)mpd_status_get_song_id(c->status)) {
+               seek_id = mpd_status_get_song_id(c->status);
                seek_target_time = mpd_status_get_elapsed_time(c->status);
        }
 
index 5d6e4091698cc70b61635b7fbdaab4dfe945f58d..d3a826523b548380a9638d539113d31d764ebc38 100644 (file)
@@ -158,12 +158,12 @@ update_progress_window(struct mpdclient *c, bool repaint)
 {
        unsigned elapsed, duration;
 
-       if (c->song != NULL && seek_id == (int)mpd_song_get_id(c->song))
+       if (c->status == NULL)
+               elapsed = 0;
+       else if (seek_id >= 0 && seek_id == mpd_status_get_song_id(c->status))
                elapsed = seek_target_time;
-       else if (c->status != NULL)
-               elapsed = mpd_status_get_elapsed_time(c->status);
        else
-               elapsed = 0;
+               elapsed = mpd_status_get_elapsed_time(c->status);
 
        duration = mpdclient_is_playing(c)
                ? mpd_status_get_total_time(c->status)
index 00724e3aae062952b1a9ab96ca74368f0c6de862..2e9449963058e00a7dec38be20a41e81249dd145 100644 (file)
@@ -134,8 +134,8 @@ status_bar_paint(struct status_bar *p, const struct mpd_status *status,
                        char elapsed_string[32], duration_string[32];
 
                        /*checks the conf to see whether to display elapsed or remaining time */
-                       if (song != NULL &&
-                           seek_id == (int)mpd_song_get_id(song))
+                       if (seek_id >= 0 &&
+                           seek_id == mpd_status_get_song_id(status))
                                elapsedTime = seek_target_time;
                        else if (options.display_remaining_time)
                                elapsedTime = total_time -