aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:17 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:17 +0200
commit113c1c0af5383d356c9e527f8763566aa5a63ea1 (patch)
tree26402349d1917d591f438e891c6dfa8e8d5ac88b
parentb94af79134678f6998988fea902054c5ce5e34ca (diff)
downloadmpd-113c1c0af5383d356c9e527f8763566aa5a63ea1.tar.gz
mpd-113c1c0af5383d356c9e527f8763566aa5a63ea1.tar.xz
mpd-113c1c0af5383d356c9e527f8763566aa5a63ea1.zip
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.
-rw-r--r--src/player.c11
-rw-r--r--src/player.h2
-rw-r--r--src/playlist.c16
3 files changed, 8 insertions, 21 deletions
diff --git a/src/player.c b/src/player.c
index 2df6b6cd1..84fd163fe 100644
--- a/src/player.c
+++ b/src/player.c
@@ -165,15 +165,12 @@ char *getPlayerErrorStr(void)
return *error ? error : NULL;
}
-int queueSong(Song * song)
+void queueSong(Song * song)
{
- if (pc.queueState == PLAYER_QUEUE_BLANK) {
- set_current_song(song);
- pc.queueState = PLAYER_QUEUE_FULL;
- return 0;
- }
+ assert(pc.queueState == PLAYER_QUEUE_BLANK);
- return -1;
+ set_current_song(song);
+ pc.queueState = PLAYER_QUEUE_FULL;
}
enum player_queue_state getPlayerQueueState(void)
diff --git a/src/player.h b/src/player.h
index b3cf207ec..de237c4ba 100644
--- a/src/player.h
+++ b/src/player.h
@@ -129,7 +129,7 @@ int getPlayerError(void);
void playerWait(void);
-int queueSong(Song * song);
+void queueSong(Song * song);
enum player_queue_state getPlayerQueueState(void);
diff --git a/src/playlist.c b/src/playlist.c
index cc2a67f2f..0f6f1d010 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -62,7 +62,6 @@ static int playlist_state = PLAYLIST_STATE_STOP;
int playlist_max_length = DEFAULT_PLAYLIST_MAX_LENGTH;
static int playlist_stopOnError;
static int playlist_errorCount;
-static int playlist_queueError;
static int playlist_noGoToNext;
int playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
@@ -491,11 +490,7 @@ static void queueNextSongInPlaylist(void)
get_song_url(path_max_tmp,
playlist.
songs[playlist.order[playlist.queued]]));
- if (queueSong(playlist.songs[playlist.order[playlist.queued]]) <
- 0) {
- playlist.queued = -1;
- playlist_queueError = 1;
- }
+ queueSong(playlist.songs[playlist.order[playlist.queued]]);
} else if (playlist.length && playlist.repeat) {
if (playlist.length > 1 && playlist.random) {
randomizeOrder(0, playlist.length - 1);
@@ -506,11 +501,7 @@ static void queueNextSongInPlaylist(void)
get_song_url(path_max_tmp,
playlist.
songs[playlist.order[playlist.queued]]));
- if (queueSong(playlist.songs[playlist.order[playlist.queued]]) <
- 0) {
- playlist.queued = -1;
- playlist_queueError = 1;
- }
+ queueSong(playlist.songs[playlist.order[playlist.queued]]);
}
}
@@ -851,7 +842,6 @@ static void playPlaylistOrderNumber(int orderNum)
playlist_state = PLAYLIST_STATE_PLAY;
playlist_noGoToNext = 0;
playlist.queued = -1;
- playlist_queueError = 0;
DEBUG("playlist: play %i:\"%s\"\n", orderNum,
get_song_url(path_max_tmp,
@@ -953,7 +943,7 @@ void syncPlayerAndPlaylist(void)
if (getPlayerState() == PLAYER_STATE_STOP)
playPlaylistIfPlayerStopped();
else
- syncPlaylistWithQueue(!playlist_queueError);
+ syncPlaylistWithQueue(1);
syncCurrentPlayerDecodeMetadata();
}