From a0bfd9ff7c675760eba5b61adee1c4cb5cb54c9f Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Mon, 26 Oct 2009 20:21:00 +0000 Subject: [PATCH] Use some black magic (GOTO) to fix #915. See comments in code for explanation. Originally committed to SVN as r3732. --- aegisub/src/audio_player_dsound2.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/aegisub/src/audio_player_dsound2.cpp b/aegisub/src/audio_player_dsound2.cpp index cc51f46bb..605243488 100644 --- a/aegisub/src/audio_player_dsound2.cpp +++ b/aegisub/src/audio_player_dsound2.cpp @@ -328,6 +328,13 @@ void DirectSoundPlayer2Thread::Run() ResetEvent(is_playing); playback_should_be_running = false; } + else + { + // If the user is dragging the start or end point in the audio display + // the set end frame events might come in faster than the timeouts happen + // and then new data never get filled into the buffer. See bug #915. + goto do_fill_buffer; + } break; } @@ -337,7 +344,7 @@ void DirectSoundPlayer2Thread::Run() // We aren't thread safe right now, filling the buffers grabs volume directly // from the field set by the controlling thread, but it shouldn't be a major // problem if race conditions do occur, just some momentary distortion. - break; + goto do_fill_buffer; } case WAIT_OBJECT_0+4: @@ -351,6 +358,7 @@ void DirectSoundPlayer2Thread::Run() } case WAIT_TIMEOUT: +do_fill_buffer: { // Time to fill more into buffer