From 48e321f8efd2c7ca872c53f07b3ebb7745df3a97 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Fri, 5 Feb 2010 16:06:37 +0000 Subject: [PATCH] Juggle a weird control structure to be more regular. Originally committed to SVN as r4086. --- aegisub/src/audio_player_dsound2.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/aegisub/src/audio_player_dsound2.cpp b/aegisub/src/audio_player_dsound2.cpp index 82ea93d22..118b0e8e3 100644 --- a/aegisub/src/audio_player_dsound2.cpp +++ b/aegisub/src/audio_player_dsound2.cpp @@ -354,22 +354,21 @@ void DirectSoundPlayer2Thread::Run() REPORT_ERROR("Could not reset playback buffer cursor before filling first buffer.") HRESULT res = bfr->Lock(buffer_offset, 0, &buf, &buf_size, 0, 0, DSBLOCK_ENTIREBUFFER); - while (FAILED(res)) // yes, while, so I can break out of it without a goto! + if (FAILED(res)) { if (res == DSERR_BUFFERLOST) { // Try to regain the buffer - if (SUCCEEDED(bfr->Restore()) && - SUCCEEDED(bfr->Lock(buffer_offset, 0, &buf, &buf_size, 0, 0, DSBLOCK_ENTIREBUFFER))) + if (FAILED(bfr->Restore()) || + FAILED(bfr->Lock(buffer_offset, 0, &buf, &buf_size, 0, 0, DSBLOCK_ENTIREBUFFER))) { - //wxLogDebug(_T("DirectSoundPlayer2: Lost and restored buffer")); - break; + REPORT_ERROR("Lost buffer and could not restore it.") } - - REPORT_ERROR("Lost buffer and could not restore it.") } - - REPORT_ERROR("Could not lock buffer for playback.") + else + { + REPORT_ERROR("Could not lock buffer for playback.") + } } // Clear the buffer in case we can't fill it completely