Code

player_command: use libmpdclient2 directly
authorMax Kellermann <max@duempel.org>
Wed, 30 Sep 2009 14:33:55 +0000 (16:33 +0200)
committerMax Kellermann <max@duempel.org>
Wed, 30 Sep 2009 14:33:55 +0000 (16:33 +0200)
Don't use mpdclient_cmd_X().

src/mpdclient.c
src/mpdclient.h
src/player_command.c

index 124c01827f2efeec63f0bba6ff3343f58def9e86..b8d9c6fa2c78118ff3747295445b371c959749b9 100644 (file)
@@ -276,16 +276,6 @@ mpdclient_cmd_play(struct mpdclient *c, gint idx)
        return mpdclient_finish_command(c);
 }
 
-gint
-mpdclient_cmd_pause(struct mpdclient *c, gint value)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_pause(c->connection, value);
-       return mpdclient_finish_command(c);
-}
-
 gint
 mpdclient_cmd_crop(struct mpdclient *c)
 {
@@ -321,56 +311,6 @@ mpdclient_cmd_crop(struct mpdclient *c)
        return mpdclient_finish_command(c);
 }
 
-gint
-mpdclient_cmd_stop(struct mpdclient *c)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_stop(c->connection);
-       return mpdclient_finish_command(c);
-}
-
-gint
-mpdclient_cmd_next(struct mpdclient *c)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_next(c->connection);
-       return mpdclient_finish_command(c);
-}
-
-gint
-mpdclient_cmd_prev(struct mpdclient *c)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_previous(c->connection);
-       return mpdclient_finish_command(c);
-}
-
-gint
-mpdclient_cmd_seek(struct mpdclient *c, gint id, gint pos)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_seek_id(c->connection, id, pos);
-       return mpdclient_finish_command(c);
-}
-
-gint
-mpdclient_cmd_shuffle(struct mpdclient *c)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_shuffle(c->connection);
-       return mpdclient_finish_command(c);
-}
-
 gint
 mpdclient_cmd_shuffle_range(struct mpdclient *c, guint start, guint end)
 {
@@ -393,56 +333,6 @@ mpdclient_cmd_clear(struct mpdclient *c)
        return retval;
 }
 
-gint
-mpdclient_cmd_repeat(struct mpdclient *c, gint value)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_repeat(c->connection, value);
-       return mpdclient_finish_command(c);
-}
-
-gint
-mpdclient_cmd_random(struct mpdclient *c, gint value)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_random(c->connection, value);
-       return mpdclient_finish_command(c);
-}
-
-gint
-mpdclient_cmd_single(struct mpdclient *c, gint value)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_single(c->connection, value);
-       return mpdclient_finish_command(c);
-}
-
-gint
-mpdclient_cmd_consume(struct mpdclient *c, gint value)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_consume(c->connection, value);
-       return mpdclient_finish_command(c);
-}
-
-gint
-mpdclient_cmd_crossfade(struct mpdclient *c, gint value)
-{
-       if (MPD_ERROR(c))
-               return -1;
-
-       mpd_send_crossfade(c->connection, value);
-       return mpdclient_finish_command(c);
-}
-
 gint
 mpdclient_cmd_volume(struct mpdclient *c, gint value)
 {
index e9150ba2d109940e6cc90333d9dda729a1dad2c7..2679a62e5e45d223582e581fa0ea4723538b7f68 100644 (file)
@@ -53,21 +53,10 @@ mpdclient_update(struct mpdclient *c);
 
 /*** MPD Commands  **********************************************************/
 gint mpdclient_cmd_play(struct mpdclient *c, gint index);
-gint mpdclient_cmd_pause(struct mpdclient *c, gint value);
 gint
 mpdclient_cmd_crop(struct mpdclient *c);
-gint mpdclient_cmd_stop(struct mpdclient *c);
-gint mpdclient_cmd_next(struct mpdclient *c);
-gint mpdclient_cmd_prev(struct mpdclient *c);
-gint mpdclient_cmd_seek(struct mpdclient *c, gint id, gint pos);
-gint mpdclient_cmd_shuffle(struct mpdclient *c);
 gint mpdclient_cmd_shuffle_range(struct mpdclient *c, guint start, guint end);
 gint mpdclient_cmd_clear(struct mpdclient *c);
-gint mpdclient_cmd_repeat(struct mpdclient *c, gint value);
-gint mpdclient_cmd_random(struct mpdclient *c, gint value);
-gint mpdclient_cmd_single(struct mpdclient *c, gint value);
-gint mpdclient_cmd_consume(struct mpdclient *c, gint value);
-gint mpdclient_cmd_crossfade(struct mpdclient *c, gint value);
 gint mpdclient_cmd_volume(struct mpdclient *c, gint value);
 gint mpdclient_cmd_volume_up(struct mpdclient *c);
 gint mpdclient_cmd_volume_down(struct mpdclient *c);
index 678d13a07343232d380ee004dd891ebefa6351fc..04256eb1438714ef2dcb6e1d6c8a12377c51005c 100644 (file)
@@ -40,7 +40,8 @@ commit_seek(struct mpdclient *c)
                return;
 
        if (c->song != NULL && (unsigned)seek_id == mpd_song_get_id(c->song))
-               mpdclient_cmd_seek(c, seek_id, seek_target_time);
+               if (!mpd_run_seek_id(c->connection, seek_id, seek_target_time))
+                       mpdclient_handle_error(c);
 
        seek_id = -1;
 }
@@ -91,10 +92,13 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
                */
        case CMD_PAUSE:
-               mpdclient_cmd_pause(c, !IS_PAUSED(mpd_status_get_state(c->status)));
+               if (!mpd_run_pause(c->connection,
+                                  !IS_PAUSED(mpd_status_get_state(c->status))))
+                       mpdclient_handle_error(c);
                break;
        case CMD_STOP:
-               mpdclient_cmd_stop(c);
+               if (!mpd_run_stop(c->connection))
+                       mpdclient_handle_error(c);
                break;
        case CMD_CROP:
                mpdclient_cmd_crop(c);
@@ -114,8 +118,8 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                break;
                /* fall through... */
        case CMD_TRACK_NEXT:
-               if (!IS_STOPPED(mpd_status_get_state(c->status)))
-                       mpdclient_cmd_next(c);
+               if (!mpd_run_next(c->connection))
+                       mpdclient_handle_error(c);
                break;
        case CMD_SEEK_BACKWARD:
                if (!IS_STOPPED(mpd_status_get_state(c->status))) {
@@ -130,34 +134,44 @@ handle_player_command(struct mpdclient *c, command_t cmd)
                }
                break;
        case CMD_TRACK_PREVIOUS:
-               if (!IS_STOPPED(mpd_status_get_state(c->status)))
-                       mpdclient_cmd_prev(c);
+               if (!mpd_run_previous(c->connection))
+                       mpdclient_handle_error(c);
                break;
        case CMD_SHUFFLE:
-               if (mpdclient_cmd_shuffle(c) == 0)
+               if (mpd_run_shuffle(c->connection))
                        screen_status_message(_("Shuffled playlist"));
+               else
+                       mpdclient_handle_error(c);
                break;
        case CMD_CLEAR:
                if (mpdclient_cmd_clear(c) == 0)
                        screen_status_message(_("Cleared playlist"));
                break;
        case CMD_REPEAT:
-               mpdclient_cmd_repeat(c, !mpd_status_get_repeat(c->status));
+               if (!mpd_run_repeat(c->connection,
+                                   !mpd_status_get_repeat(c->status)))
+                       mpdclient_handle_error(c);
                break;
        case CMD_RANDOM:
-               mpdclient_cmd_random(c, !mpd_status_get_random(c->status));
+               if (!mpd_run_random(c->connection,
+                                   !mpd_status_get_random(c->status)))
+                       mpdclient_handle_error(c);
                break;
        case CMD_SINGLE:
-               mpdclient_cmd_single(c, !mpd_status_get_single(c->status));
+               if (!mpd_run_single(c->connection,
+                                   !mpd_status_get_single(c->status)))
+                       mpdclient_handle_error(c);
                break;
        case CMD_CONSUME:
-               mpdclient_cmd_consume(c, !mpd_status_get_consume(c->status));
+               if (!mpd_run_consume(c->connection,
+                                    !mpd_status_get_consume(c->status)))
+                       mpdclient_handle_error(c);
                break;
        case CMD_CROSSFADE:
-               if (mpd_status_get_crossfade(c->status))
-                       mpdclient_cmd_crossfade(c, 0);
-               else
-                       mpdclient_cmd_crossfade(c, options.crossfade_time);
+               if (!mpd_run_crossfade(c->connection,
+                                      mpd_status_get_crossfade(c->status) > 0
+                                      ? 0 : options.crossfade_time))
+                       mpdclient_handle_error(c);
                break;
        case CMD_DB_UPDATE:
                screen_database_update(c, NULL);