From 001df25b86280222c4d54c43f0bbd5681ac8b414 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Tue, 30 Sep 2008 03:33:24 +0000
Subject: [PATCH] Ensure snd_pcm_drain() completes

---
 src/xpdev/xpbeep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/xpdev/xpbeep.c b/src/xpdev/xpbeep.c
index 4fa3ba61f1..2bfdc202ef 100644
--- a/src/xpdev/xpbeep.c
+++ b/src/xpdev/xpbeep.c
@@ -632,7 +632,8 @@ void xp_play_sample_thread(void *data)
 				xptone_open();
 			}
 			else {
-				alsa_api->snd_pcm_drain(playback_handle);
+				while(alsa_api->snd_pcm_drain(playback_handle))
+					SLEEP(1);
 			}
 		}
 	#endif
@@ -765,7 +766,8 @@ BOOL DLLCALL xp_play_sample(const unsigned char *sample, size_t sample_size, BOO
 			xptone_open();
 		}
 		else {
-			alsa_api->snd_pcm_drain(playback_handle);
+			while(alsa_api->snd_pcm_drain(playback_handle))
+				SLEEP(1);
 			if(must_close)
 				xptone_close();
 			return(TRUE);
-- 
GitLab