From 4b487197fc27641a7fb984e8bf9823f34f1e4146 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 18 Oct 2009 00:57:11 +0200 Subject: [PATCH] mpdclient: removed mpdclient_cmd_play() Call mpdclient_run_play_id() directly. --- src/mpdclient.c | 17 ----------------- src/mpdclient.h | 3 --- src/screen_queue.c | 23 ++++++++++++++++++++--- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/mpdclient.c b/src/mpdclient.c index 748baed..dbe931c 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -261,23 +261,6 @@ mpdclient_put_connection(struct mpdclient *c) /*** MPD Commands **********************************************************/ /****************************************************************************/ -bool -mpdclient_cmd_play(struct mpdclient *c, gint idx) -{ - struct mpd_connection *connection = mpdclient_get_connection(c); - const struct mpd_song *song = playlist_get_song(&c->playlist, idx); - - if (connection == NULL) - return false; - - if (song) - mpd_send_play_id(connection, mpd_song_get_id(song)); - else - mpd_send_play(connection); - - return mpdclient_finish_command(c); -} - bool mpdclient_cmd_crop(struct mpdclient *c) { diff --git a/src/mpdclient.h b/src/mpdclient.h index 6c8758f..9f22d26 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -92,9 +92,6 @@ mpdclient_ui_error(const char *message); /*** MPD Commands **********************************************************/ -bool -mpdclient_cmd_play(struct mpdclient *c, gint index); - bool mpdclient_cmd_crop(struct mpdclient *c); diff --git a/src/screen_queue.c b/src/screen_queue.c index 491d332..0130520 100644 --- a/src/screen_queue.c +++ b/src/screen_queue.c @@ -616,8 +616,16 @@ handle_mouse_event(struct mpdclient *c) if (bstate & BUTTON1_CLICKED) { /* play */ - if (lw->selected < playlist_length(playlist)) - mpdclient_cmd_play(c, lw->start + row); + const struct mpd_song *song = screen_queue_selected_song(); + if (song != NULL) { + struct mpd_connection *connection = + mpdclient_get_connection(c); + + if (connection != NULL && + !mpd_run_play_id(connection, + mpd_song_get_id(song))) + mpdclient_handle_error(c); + } } else if (bstate & BUTTON3_CLICKED) { /* delete */ if (lw->selected == old_selected) @@ -640,6 +648,7 @@ screen_queue_cmd(struct mpdclient *c, command_t cmd) static command_t cached_cmd = CMD_NONE; command_t prev_cmd = cached_cmd; struct list_window_range range; + const struct mpd_song *song; cached_cmd = cmd; @@ -729,7 +738,15 @@ screen_queue_cmd(struct mpdclient *c, command_t cmd) switch(cmd) { case CMD_PLAY: - mpdclient_cmd_play(c, lw->selected); + song = screen_queue_selected_song(); + if (song == NULL) + return false; + + connection = mpdclient_get_connection(c); + if (connection != NULL && + !mpd_run_play_id(connection, mpd_song_get_id(song))) + mpdclient_handle_error(c); + return true; case CMD_DELETE: -- 2.30.2