From 9ee53bc76e110b5c1222f5ec2a10721e982d6e7b Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Tue, 2 Jun 2009 08:39:17 +0200
Subject: player_thread: check pipe size again before exiting

When the decoder is finished, break out of the player loop only after
another player.pipe check.  We did check the pipe size a few lines
above, but that check was kind of racy.
---
 src/player_thread.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'src/player_thread.c')

diff --git a/src/player_thread.c b/src/player_thread.c
index add093083..7fc55d3d1 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -730,7 +730,11 @@ static void do_play(void)
 			if (!player_song_border(&player))
 				break;
 		} else if (decoder_is_idle()) {
-			break;
+			/* check the size of the pipe again, because
+			   the decoder thread may have added something
+			   since we last checked */
+			if (music_pipe_size(player.pipe) == 0)
+				break;
 		} else {
 			/* the decoder is too busy and hasn't provided
 			   new PCM data in time: send silence (if the
-- 
cgit v1.2.3