directsoundsink: Fix corner case causing large CPU usage
authorNirbheek Chauhan <nirbheek@centricular.com>
Wed, 3 May 2017 17:53:10 +0000 (23:23 +0530)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 8 May 2017 14:02:46 +0000 (16:02 +0200)
commit2d44b53ff664658ba9a4578b5b3231365c7c8e71
tree16160805606fa8d257db6edab1535254b8381a1f
parent0700b1f0b0dd6b986f232c993b20929cee69ed6a
directsoundsink: Fix corner case causing large CPU usage

We were unnecessarily looping/goto-ing repeatedly when we had exactly
the amount of data as the free space, and also when the free space was
too small. This, as it turns out, is a very common scenario with
Directsound on Windows.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=773681

We have to do polling here because the event notification API that
Directsound exposes cannot be used with live playback since all events
must be registered in advance with the capture buffer, you cannot
add/remove them once playback has begun. Directsoundsrc had the same
problem.

See also: https://bugzilla.gnome.org/show_bug.cgi?id=781249
sys/directsound/gstdirectsoundsink.c