https://bugs.winehq.org/show_bug.cgi?id=53475
--- Comment #9 from ilkka.prusi@gmail.com --- Created attachment 72847 --> https://bugs.winehq.org/attachment.cgi?id=72847 Simplify end of stream and flush event handling
Flush event handling has bogus error message: it is normal that WaitForSingleObject() returns 0 when event has been signalled. Also at that point it is expected that code will stop blocking so expedited return would be preferred instead of continuing in SendSampleData(). This has a case-check in the patch.
In dsound_render_sink_eos(), when stream is finished resetting should buffer have no meaningful purpose: a) buffer will be destroyed and sample no longer matters b) buffer could be reused and rewritten with new sample Zeroing serves no purpose in either case and is removed in the patch.
Additionally, in dsound_render_sink_eos() there is a waiting loop which seems to have no purpose and causes bogus "underrun" message when sample playing is supposed to end already. Code does other things that seem to have no useful meaning when stream is ending. The lines that may have use are lifter up the call chain in the patch.
Finally, filter->state_event should only be set after all modifying of the state is done, so ensure that is the last. This is also in the patch.