From fe657496239b58e10f3c67dcb6cc9484ef7fced7 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Fri, 5 Feb 2010 13:22:43 +0000 Subject: [PATCH] Merge r4081, closes #1126. Originally committed to SVN as r4082. --- aegisub/src/audio_player_dsound2.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/aegisub/src/audio_player_dsound2.cpp b/aegisub/src/audio_player_dsound2.cpp index 4fe89d985..48b1282a3 100644 --- a/aegisub/src/audio_player_dsound2.cpp +++ b/aegisub/src/audio_player_dsound2.cpp @@ -683,9 +683,20 @@ DirectSoundPlayer2Thread::DirectSoundPlayer2Thread(AudioProvider *provider, int if (!thread_handle) throw _T("Failed creating playback thread in DirectSoundPlayer2. This is bad."); - CheckError(); + HANDLE running_or_error[] = { thread_running, error_happened }; + switch (WaitForMultipleObjects(2, running_or_error, FALSE, INFINITE)) + { + case WAIT_OBJECT_0: + // running, all good + return; - WaitForSingleObject(thread_running, INFINITE); + case WAIT_OBJECT_0 + 1: + // error happened, we fail + throw error_message; + + default: + throw _T("Failed wait for thread start or thread error in DirectSoundPlayer2. This is bad."); + } }