Commit 113c1c0a authored by Max Kellermann's avatar Max Kellermann

queueSong() cannot fail

All (indirect) callers of queueSong() ensure that the queue state is BLANK, so there is no need to check it in queueSong() again. As a side effect, queueSong() cannot fail anymore, and can return void. Also, playlist_queueError and all its error handling can go away.
parent b94af791
...@@ -165,15 +165,12 @@ char *getPlayerErrorStr(void) ...@@ -165,15 +165,12 @@ char *getPlayerErrorStr(void)
return *error ? error : NULL; return *error ? error : NULL;
} }
int queueSong(Song * song) void queueSong(Song * song)
{ {
if (pc.queueState == PLAYER_QUEUE_BLANK) { assert(pc.queueState == PLAYER_QUEUE_BLANK);
set_current_song(song);
pc.queueState = PLAYER_QUEUE_FULL;
return 0;
}
return -1; set_current_song(song);
pc.queueState = PLAYER_QUEUE_FULL;
} }
enum player_queue_state getPlayerQueueState(void) enum player_queue_state getPlayerQueueState(void)
......
...@@ -129,7 +129,7 @@ int getPlayerError(void); ...@@ -129,7 +129,7 @@ int getPlayerError(void);
void playerWait(void); void playerWait(void);
int queueSong(Song * song); void queueSong(Song * song);
enum player_queue_state getPlayerQueueState(void); enum player_queue_state getPlayerQueueState(void);
......
...@@ -62,7 +62,6 @@ static int playlist_state = PLAYLIST_STATE_STOP; ...@@ -62,7 +62,6 @@ static int playlist_state = PLAYLIST_STATE_STOP;
int playlist_max_length = DEFAULT_PLAYLIST_MAX_LENGTH; int playlist_max_length = DEFAULT_PLAYLIST_MAX_LENGTH;
static int playlist_stopOnError; static int playlist_stopOnError;
static int playlist_errorCount; static int playlist_errorCount;
static int playlist_queueError;
static int playlist_noGoToNext; static int playlist_noGoToNext;
int playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS; int playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
...@@ -491,11 +490,7 @@ static void queueNextSongInPlaylist(void) ...@@ -491,11 +490,7 @@ static void queueNextSongInPlaylist(void)
get_song_url(path_max_tmp, get_song_url(path_max_tmp,
playlist. playlist.
songs[playlist.order[playlist.queued]])); songs[playlist.order[playlist.queued]]));
if (queueSong(playlist.songs[playlist.order[playlist.queued]]) < queueSong(playlist.songs[playlist.order[playlist.queued]]);
0) {
playlist.queued = -1;
playlist_queueError = 1;
}
} else if (playlist.length && playlist.repeat) { } else if (playlist.length && playlist.repeat) {
if (playlist.length > 1 && playlist.random) { if (playlist.length > 1 && playlist.random) {
randomizeOrder(0, playlist.length - 1); randomizeOrder(0, playlist.length - 1);
...@@ -506,11 +501,7 @@ static void queueNextSongInPlaylist(void) ...@@ -506,11 +501,7 @@ static void queueNextSongInPlaylist(void)
get_song_url(path_max_tmp, get_song_url(path_max_tmp,
playlist. playlist.
songs[playlist.order[playlist.queued]])); songs[playlist.order[playlist.queued]]));
if (queueSong(playlist.songs[playlist.order[playlist.queued]]) < queueSong(playlist.songs[playlist.order[playlist.queued]]);
0) {
playlist.queued = -1;
playlist_queueError = 1;
}
} }
} }
...@@ -851,7 +842,6 @@ static void playPlaylistOrderNumber(int orderNum) ...@@ -851,7 +842,6 @@ static void playPlaylistOrderNumber(int orderNum)
playlist_state = PLAYLIST_STATE_PLAY; playlist_state = PLAYLIST_STATE_PLAY;
playlist_noGoToNext = 0; playlist_noGoToNext = 0;
playlist.queued = -1; playlist.queued = -1;
playlist_queueError = 0;
DEBUG("playlist: play %i:\"%s\"\n", orderNum, DEBUG("playlist: play %i:\"%s\"\n", orderNum,
get_song_url(path_max_tmp, get_song_url(path_max_tmp,
...@@ -953,7 +943,7 @@ void syncPlayerAndPlaylist(void) ...@@ -953,7 +943,7 @@ void syncPlayerAndPlaylist(void)
if (getPlayerState() == PLAYER_STATE_STOP) if (getPlayerState() == PLAYER_STATE_STOP)
playPlaylistIfPlayerStopped(); playPlaylistIfPlayerStopped();
else else
syncPlaylistWithQueue(!playlist_queueError); syncPlaylistWithQueue(1);
syncCurrentPlayerDecodeMetadata(); syncCurrentPlayerDecodeMetadata();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment