diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 20 | ||||
-rw-r--r-- | src/playlist.c | 67 | ||||
-rw-r--r-- | src/playlist.h | 8 |
3 files changed, 46 insertions, 49 deletions
diff --git a/src/command.c b/src/command.c index 04220018e..d77b16b42 100644 --- a/src/command.c +++ b/src/command.c @@ -268,10 +268,11 @@ static int handlePlayId(int fd, mpd_unused int *permission, return playPlaylistById(fd, id, 0); } -static int handleStop(int fd, mpd_unused int *permission, +static int handleStop(mpd_unused int fd, mpd_unused int *permission, mpd_unused int argc, mpd_unused char *argv[]) { - return stopPlaylist(fd); + stopPlaylist(); + return 0; } static int handleCurrentSong(int fd, mpd_unused int *permission, @@ -441,10 +442,11 @@ static int handleShuffle(int fd, mpd_unused int *permission, return shufflePlaylist(fd); } -static int handleClear(int fd, mpd_unused int *permission, +static int handleClear(mpd_unused int fd, mpd_unused int *permission, mpd_unused int argc, mpd_unused char *argv[]) { - return clearPlaylist(fd); + clearPlaylist(); + return 0; } static int handleSave(int fd, mpd_unused int *permission, @@ -716,16 +718,18 @@ static int handleUpdate(int fd, mpd_unused int *permission, return updateInit(fd, NULL); } -static int handleNext(int fd, mpd_unused int *permission, +static int handleNext(mpd_unused int fd, mpd_unused int *permission, mpd_unused int argc, mpd_unused char *argv[]) { - return nextSongInPlaylist(fd); + nextSongInPlaylist(); + return 0; } -static int handlePrevious(int fd, mpd_unused int *permission, +static int handlePrevious(mpd_unused int fd, mpd_unused int *permission, mpd_unused int argc, mpd_unused char *argv[]) { - return previousSongInPlaylist(fd); + previousSongInPlaylist(); + return 0; } static int handleListAll(int fd, mpd_unused int *permission, diff --git a/src/playlist.c b/src/playlist.c index bb706002f..2fbe8e126 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -68,7 +68,7 @@ static int playlist_noGoToNext; int playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS; static void swapOrder(int a, int b); -static int playPlaylistOrderNumber(int fd, int orderNum); +static void playPlaylistOrderNumber(int orderNum); static void randomizeOrder(int start, int end); static void incrPlaylistVersion(void) @@ -193,12 +193,11 @@ void finishPlaylist(void) playlist.positionToId = NULL; } -int clearPlaylist(int fd) +void clearPlaylist(void) { int i; - if (stopPlaylist(fd) < 0) - return -1; + stopPlaylist(); for (i = 0; i < playlist.length; i++) { if (playlist.songs[i]->type == SONG_TYPE_URL) { @@ -211,8 +210,6 @@ int clearPlaylist(int fd) playlist.current = -1; incrPlaylistVersion(); - - return 0; } int clearStoredPlaylist(int fd, char *utf8file) @@ -828,7 +825,7 @@ void deleteASongFromPlaylist(Song * song) } } -int stopPlaylist(mpd_unused int fd) +void stopPlaylist(void) { DEBUG("playlist: stop\n"); playerWait(); @@ -837,10 +834,9 @@ int stopPlaylist(mpd_unused int fd) playlist_noGoToNext = 0; if (playlist.random) randomizeOrder(0, playlist.length - 1); - return 0; } -static int playPlaylistOrderNumber(mpd_unused int fd, int orderNum) +static void playPlaylistOrderNumber(int orderNum) { char path_max_tmp[MPD_PATH_MAX]; @@ -857,8 +853,6 @@ static int playPlaylistOrderNumber(mpd_unused int fd, int orderNum) playerPlay(playlist.songs[playlist.order[orderNum]]); playlist.current = orderNum; - - return 0; } int playPlaylist(int fd, int song, int stopOnError) @@ -903,7 +897,8 @@ int playPlaylist(int fd, int song, int stopOnError) playlist_stopOnError = stopOnError; playlist_errorCount = 0; - return playPlaylistOrderNumber(fd, i); + playPlaylistOrderNumber(i); + return 0; } int playPlaylistById(int fd, int id, int stopOnError) @@ -957,39 +952,39 @@ void syncPlayerAndPlaylist(void) syncCurrentPlayerDecodeMetadata(); } -static int currentSongInPlaylist(int fd) +static void currentSongInPlaylist(void) { if (playlist_state != PLAYLIST_STATE_PLAY) - return 0; + return; playlist_stopOnError = 0; syncPlaylistWithQueue(0); - if (playlist.current >= 0 && playlist.current < playlist.length) { - return playPlaylistOrderNumber(fd, playlist.current); - } else - return stopPlaylist(fd); + if (playlist.current >= 0 && playlist.current < playlist.length) + playPlaylistOrderNumber(playlist.current); + else + stopPlaylist(); } -int nextSongInPlaylist(int fd) +void nextSongInPlaylist(void) { if (playlist_state != PLAYLIST_STATE_PLAY) - return 0; + return; syncPlaylistWithQueue(0); playlist_stopOnError = 0; if (playlist.current < playlist.length - 1) { - return playPlaylistOrderNumber(fd, playlist.current + 1); + playPlaylistOrderNumber(playlist.current + 1); } else if (playlist.length && playlist.repeat) { if (playlist.random) randomizeOrder(0, playlist.length - 1); - return playPlaylistOrderNumber(fd, 0); + playPlaylistOrderNumber(0); } else { incrPlaylistCurrent(); - return stopPlaylist(fd); + stopPlaylist(); } } @@ -1008,11 +1003,11 @@ void playPlaylistIfPlayerStopped(void) || error == PLAYER_ERROR_AUDIO || error == PLAYER_ERROR_SYSTEM || playlist_errorCount >= playlist.length)) { - stopPlaylist(STDERR_FILENO); + stopPlaylist(); } else if (playlist_noGoToNext) - currentSongInPlaylist(STDERR_FILENO); + currentSongInPlaylist(); else - nextSongInPlaylist(STDERR_FILENO); + nextSongInPlaylist(); } } @@ -1227,7 +1222,7 @@ int setPlaylistRandomStatus(int fd, int status) return 0; } -int previousSongInPlaylist(int fd) +void previousSongInPlaylist(void) { static time_t lastTime; time_t diff = time(NULL) - lastTime; @@ -1235,20 +1230,19 @@ int previousSongInPlaylist(int fd) lastTime += diff; if (playlist_state != PLAYLIST_STATE_PLAY) - return 0; + return; syncPlaylistWithQueue(0); if (diff && getPlayerElapsedTime() > PLAYLIST_PREV_UNLESS_ELAPSED) { - return playPlaylistOrderNumber(fd, playlist.current); + playPlaylistOrderNumber(playlist.current); } else { if (playlist.current > 0) { - return playPlaylistOrderNumber(fd, - playlist.current - 1); + playPlaylistOrderNumber(playlist.current - 1); } else if (playlist.repeat) { - return playPlaylistOrderNumber(fd, playlist.length - 1); + playPlaylistOrderNumber(playlist.length - 1); } else { - return playPlaylistOrderNumber(fd, playlist.current); + playPlaylistOrderNumber(playlist.current); } } } @@ -1388,12 +1382,11 @@ int seekSongInPlaylist(int fd, int song, float seek_time) if (playlist_state == PLAYLIST_STATE_PLAY) { if (playlist.queued >= 0) clearPlayerQueueLocked(); - } else if (playPlaylistOrderNumber(fd, i) < 0) - return -1; + } else + playPlaylistOrderNumber(i); if (playlist.current != i) { - if (playPlaylistOrderNumber(fd, i) < 0) - return -1; + playPlaylistOrderNumber(i); } return playerSeek(fd, playlist.songs[playlist.order[i]], seek_time); diff --git a/src/playlist.h b/src/playlist.h index db5243ba9..c2b4f9f90 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -51,7 +51,7 @@ void readPlaylistState(FILE *); void savePlaylistState(FILE *); -int clearPlaylist(int fd); +void clearPlaylist(void); int clearStoredPlaylist(int fd, char *utf8file); @@ -71,17 +71,17 @@ int playlistInfo(int fd, int song); int playlistId(int fd, int song); -int stopPlaylist(int fd); +void stopPlaylist(void); int playPlaylist(int fd, int song, int stopOnError); int playPlaylistById(int fd, int song, int stopOnError); -int nextSongInPlaylist(int fd); +void nextSongInPlaylist(void); void syncPlayerAndPlaylist(void); -int previousSongInPlaylist(int fd); +void previousSongInPlaylist(void); int shufflePlaylist(int fd); |