wasapisrc: Make sure that wasapisrc produces data in loopback mode
authorSeungha Yang <seungha@centricular.com>
Fri, 18 Sep 2020 15:26:35 +0000 (00:26 +0900)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 30 Sep 2020 12:57:34 +0000 (12:57 +0000)
commita668de747fd3bffb78550c37f82a33a30d489b27
treef027abf7581467ac263a9e4192004661e25b1538
parentb003387526d895f46477c48d3788f353147445a6
wasapisrc: Make sure that wasapisrc produces data in loopback mode

An oddness of wasapi loopback feature is that capture client will not
produce any data if there's no outputting sound to corresponding
render client. In other words, if there's no sound to render,
capture task will stall. As an option to solve such issue, we can
add timeout to wake up from capture thread if there's no incoming data
within given time interval. But it seems to be glitch prone.
Another approach is that we can keep pushing silence data into
render client so that capture client can keep capturing data
(even if it's just silence).

This patch will choose the latter one because it's more straightforward
way and it's likely produce glitchless sound than former approach.

A bonus point of this approach is that loopback capture on Windows7/8
will work with this patch. Note that there's an OS bug prior to Windows10
when loopback capture client is running with event-driven mode.
To work around the bug, event signalling should be handled manually
for read thread to wake up.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1588>
sys/wasapi/gstwasapisrc.c
sys/wasapi/gstwasapisrc.h