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 15:15:33 +0000 (17:15 +0200)
commit74500db9fe1c44036ba7894fede2f1cb34b59b15
tree0941310721f023248eafbc7ef93ce7555799e418
parent27f40eca4dee0417aa477896b98ebcf4e7c349ce
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