aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-09 19:15:14 +0100
committerMax Kellermann <max@duempel.org>2009-03-09 19:15:14 +0100
commit9f79c05e431806c5023f6d1537c90b4decf413a1 (patch)
treedf1ed82febc6d8ea99310ca1cdce4adc74e27471 /src/player_thread.c
parent4459a46181549b54dbf40cbe891b019c7793601a (diff)
downloadmpd-9f79c05e431806c5023f6d1537c90b4decf413a1.tar.gz
mpd-9f79c05e431806c5023f6d1537c90b4decf413a1.tar.xz
mpd-9f79c05e431806c5023f6d1537c90b4decf413a1.zip
player_thread: moved code to player_song_border()
Moved some more cruft out of do_play().
Diffstat (limited to 'src/player_thread.c')
-rw-r--r--src/player_thread.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/player_thread.c b/src/player_thread.c
index 9b9787261..2a3580da6 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -459,6 +459,24 @@ play_next_chunk(struct player *player)
return true;
}
+/**
+ * This is called at the border between two songs: the audio output
+ * has consumed all chunks of the current song, and we should start
+ * sending chunks from the next one.
+ *
+ * @return true on success, false on error (playback will be stopped)
+ */
+static bool
+player_song_border(struct player *player)
+{
+ player->xfade = XFADE_UNKNOWN;
+
+ music_pipe_free(player->pipe);
+ player->pipe = dc.pipe;
+
+ return player_wait_for_decoder(player);
+}
+
static void do_play(void)
{
struct player player = {
@@ -572,12 +590,7 @@ static void do_play(void)
} else if (dc.pipe != NULL && dc.pipe != player.pipe) {
/* at the beginning of a new song */
- player.xfade = XFADE_UNKNOWN;
-
- music_pipe_free(player.pipe);
- player.pipe = dc.pipe;
-
- if (!player_wait_for_decoder(&player))
+ if (!player_song_border(&player))
break;
} else if (decoder_is_idle()) {
break;