aboutsummaryrefslogtreecommitdiff
path: root/src/playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-07 13:38:59 +0200
committerMax Kellermann <max@duempel.org>2008-09-07 13:38:59 +0200
commite1bf96672e8ef46b4ed20eba2c91efa048c4789c (patch)
tree22fd5495c789d974e0ffff385248528cb1e682f6 /src/playlist.c
parentd1df71ebbcb23456ca5985dea9cb06e2453f903e (diff)
playlist: moved "repeat" and "random" value checks to command.c
Client's input values should be validated by the command implementation, and the core libraries shouldn't talk to the client directly if possible. Thus, setPlaylistRepeatStatus() and setPlaylistRandomStatus() don't get the file descriptor, and cannot fail (return void).
Diffstat (limited to 'src/playlist.c')
-rw-r--r--src/playlist.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 3c41b4d7..06df43fc 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -327,9 +327,9 @@ void readPlaylistState(FILE *fp)
if (strcmp
(&(buffer[strlen(PLAYLIST_STATE_FILE_REPEAT)]),
"1") == 0) {
- setPlaylistRepeatStatus(STDERR_FILENO, 1);
+ setPlaylistRepeatStatus(1);
} else
- setPlaylistRepeatStatus(STDERR_FILENO, 0);
+ setPlaylistRepeatStatus(0);
} else
if (strncmp
(buffer, PLAYLIST_STATE_FILE_CROSSFADE,
@@ -348,9 +348,9 @@ void readPlaylistState(FILE *fp)
(buffer
[strlen(PLAYLIST_STATE_FILE_RANDOM)]),
"1") == 0) {
- setPlaylistRandomStatus(STDERR_FILENO, 1);
+ setPlaylistRandomStatus(1);
} else
- setPlaylistRandomStatus(STDERR_FILENO, 0);
+ setPlaylistRandomStatus(0);
} else if (strncmp(buffer, PLAYLIST_STATE_FILE_CURRENT,
strlen(PLAYLIST_STATE_FILE_CURRENT))
== 0) {
@@ -1012,21 +1012,14 @@ int getPlaylistRandomStatus(void)
return playlist.random;
}
-int setPlaylistRepeatStatus(int fd, int status)
+void setPlaylistRepeatStatus(int status)
{
- if (status != 0 && status != 1) {
- commandError(fd, ACK_ERROR_ARG, "\"%i\" is not 0 or 1", status);
- return -1;
- }
-
if (playlist_state == PLAYLIST_STATE_PLAY) {
if (playlist.repeat && !status && playlist.queued == 0)
clearPlayerQueue();
}
playlist.repeat = status;
-
- return 0;
}
int moveSongInPlaylist(int fd, int from, int to)
@@ -1183,15 +1176,10 @@ static void randomizeOrder(int start, int end)
}
}
-int setPlaylistRandomStatus(int fd, int status)
+void setPlaylistRandomStatus(int status)
{
int statusWas = playlist.random;
- if (status != 0 && status != 1) {
- commandError(fd, ACK_ERROR_ARG, "\"%i\" is not 0 or 1", status);
- return -1;
- }
-
playlist.random = status;
if (status != statusWas) {
@@ -1209,8 +1197,6 @@ int setPlaylistRandomStatus(int fd, int status)
} else
orderPlaylist();
}
-
- return 0;
}
void previousSongInPlaylist(void)