diff options
author | Romain Bignon <romain@peerfuse.org> | 2009-03-27 14:42:55 +0100 |
---|---|---|
committer | Romain Bignon <romain@peerfuse.org> | 2009-03-27 14:58:31 +0100 |
commit | e46722b2ebe05fce63bc7b86100c159b5cadd297 (patch) | |
tree | c61515a84ad0f425233a7ebe7ee3731ab63df92a /src/command.c | |
parent | 929c200c380996d6dfcbdd468a74aaef48298af6 (diff) | |
download | mpd-e46722b2ebe05fce63bc7b86100c159b5cadd297.tar.gz mpd-e46722b2ebe05fce63bc7b86100c159b5cadd297.tar.xz mpd-e46722b2ebe05fce63bc7b86100c159b5cadd297.zip |
implements the smartstop feature
The smartstop feature is a way to tell mpd to stop playing after
current song.
This patche provides:
- 'state' command returns 'smartstop' state (1 or 0)
- 'smartstop' can activate or not the smartstop state
- when song is terminated, mpd stops playing and smartstop is set to 0
Diffstat (limited to '')
-rw-r--r-- | src/command.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c index 1b8c45f26..82b088587 100644 --- a/src/command.c +++ b/src/command.c @@ -59,6 +59,7 @@ #define COMMAND_STATUS_VOLUME "volume" #define COMMAND_STATUS_STATE "state" #define COMMAND_STATUS_REPEAT "repeat" +#define COMMAND_STATUS_SMARTSTOP "smartstop" #define COMMAND_STATUS_RANDOM "random" #define COMMAND_STATUS_PLAYLIST "playlist" #define COMMAND_STATUS_PLAYLIST_LENGTH "playlistlength" @@ -469,6 +470,7 @@ handle_status(struct client *client, COMMAND_STATUS_VOLUME ": %i\n" COMMAND_STATUS_REPEAT ": %i\n" COMMAND_STATUS_RANDOM ": %i\n" + COMMAND_STATUS_SMARTSTOP ": %i\n" COMMAND_STATUS_PLAYLIST ": %li\n" COMMAND_STATUS_PLAYLIST_LENGTH ": %i\n" COMMAND_STATUS_CROSSFADE ": %i\n" @@ -476,6 +478,7 @@ handle_status(struct client *client, volume_level_get(), getPlaylistRepeatStatus(&g_playlist), getPlaylistRandomStatus(&g_playlist), + getPlaylistSmartstopStatus(&g_playlist), getPlaylistVersion(&g_playlist), getPlaylistLength(&g_playlist), (int)(getPlayerCrossFade() + 0.5), @@ -1093,6 +1096,24 @@ handle_repeat(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) } static enum command_return +handle_smartstop(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) +{ + int status; + + if (!check_int(client, &status, argv[1], need_integer)) + return COMMAND_RETURN_ERROR; + + if (status != 0 && status != 1) { + command_error(client, ACK_ERROR_ARG, + "\"%i\" is not 0 or 1", status); + return COMMAND_RETURN_ERROR; + } + + setPlaylistSmartstopStatus(&g_playlist, status); + return COMMAND_RETURN_OK; +} + +static enum command_return handle_random(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) { int status; @@ -1602,6 +1623,7 @@ static const struct command commands[] = { { "seekid", PERMISSION_CONTROL, 2, 2, handle_seekid }, { "setvol", PERMISSION_CONTROL, 1, 1, handle_setvol }, { "shuffle", PERMISSION_CONTROL, 0, 1, handle_shuffle }, + { "smartstop", PERMISSION_CONTROL, 1, 1, handle_smartstop }, { "stats", PERMISSION_READ, 0, 0, handle_stats }, { "status", PERMISSION_READ, 0, 0, handle_status }, #ifdef ENABLE_SQLITE |