diff --git a/src/xpdev/xpbeep.c b/src/xpdev/xpbeep.c
index f47d9e1c6ed7ad6098e413d80df4def80472bc11..21ad357e52f6c32cbb38e4cd9db6fdb48a5aa3f5 100644
--- a/src/xpdev/xpbeep.c
+++ b/src/xpdev/xpbeep.c
@@ -445,11 +445,10 @@ BOOL DLLCALL xptone(double freq, DWORD duration, enum WAVE_SHAPE shape)
 
 		makewave(freq,wave,wh.dwBufferLength,shape);
 
-		if(waveOutWrite(waveOut, &wh, sizeof(wh))==MMSYSERR_NOERROR)
-			success=TRUE;
-
-		while(!(wh.dwFlags & WHDR_DONE))
-			SLEEP(1);
+		if(waveOutWrite(waveOut, &wh, sizeof(wh))==MMSYSERR_NOERROR) {
+			while(!(wh.dwFlags & WHDR_DONE))
+				SLEEP(1);
+		}
 	}
 #endif