From: Max Kellermann Date: Wed, 17 Sep 2008 10:29:06 +0000 (+0200) Subject: playlist: use playlist_get() instead of playlist_get_song() X-Git-Tag: v0.12_alpha1~265 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9e7dda69f7951f678a1b31d693dba90199d17248;p=ncmpc.git playlist: use playlist_get() instead of playlist_get_song() --- diff --git a/src/mpdclient.c b/src/mpdclient.c index 2318dcf..ae4a761 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -439,11 +439,13 @@ gint mpdclient_cmd_delete(mpdclient_t *c, gint idx) { gint retval = 0; - struct mpd_song *song = playlist_get_song(c, idx); + struct mpd_song *song; - if( !song ) + if (idx < 0 || (guint)idx >= playlist_length(&c->playlist)) return -1; + song = playlist_get(&c->playlist, idx); + /* send the delete command to mpd */ #ifdef ENABLE_SONG_ID D("Delete id:%d\n", song->id); @@ -487,8 +489,8 @@ mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index) (guint)new_index >= c->playlist.list->len) return -1; - song1 = playlist_get_song(c, old_index); - song2 = playlist_get_song(c, new_index); + song1 = playlist_get(&c->playlist, old_index); + song2 = playlist_get(&c->playlist, new_index); /* send the move command to mpd */ #ifdef ENABLE_SONG_ID diff --git a/src/screen_play.c b/src/screen_play.c index c59c766..d257ec1 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -80,9 +80,10 @@ list_callback(unsigned idx, int *highlight, void *data) mpdclient_t *c = (mpdclient_t *) data; mpd_Song *song; - if( (song=playlist_get_song(c, idx)) == NULL ) { + if (idx >= playlist_length(&c->playlist)) return NULL; - } + + song = playlist_get(&c->playlist, idx); if( c->song && song->id==c->song->id && !IS_STOPPED(c->status->state) ) { *highlight = 1;