summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2019-11-26 11:39:32 +0530
committerTim-Philipp Müller <tim@centricular.com>2019-11-28 10:43:28 +0000
commitd9e6f19026880f1f068aabb50c52b9a4d7b524e5 (patch)
treeb8df3ddfebe886cd9f60ce5a37273a2e4420990b /sys
parent5f92188a1ed42c8cf0b41f7f7e83bceb88803a6e (diff)
downloadgstreamer-plugins-bad-d9e6f19026880f1f068aabb50c52b9a4d7b524e5.tar.gz
wasapisrc: Correctly handle BUFFERFLAGS_SILENT
We need to ignore the data we get from WASAPI in this case and write out silence (zeroes). Initially reported at https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/808
Diffstat (limited to 'sys')
-rw-r--r--sys/wasapi/gstwasapisrc.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/wasapi/gstwasapisrc.c b/sys/wasapi/gstwasapisrc.c
index 63357c1ef..2286b0da9 100644
--- a/sys/wasapi/gstwasapisrc.c
+++ b/sys/wasapi/gstwasapisrc.c
@@ -611,10 +611,6 @@ gst_wasapi_src_read (GstAudioSrc * asrc, gpointer data, guint length,
goto err);
}
- /* XXX: How do we handle AUDCLNT_BUFFERFLAGS_SILENT? We're supposed to write
- * out silence when that flag is set? See:
- * https://msdn.microsoft.com/en-us/library/windows/desktop/dd370800(v=vs.85).aspx */
-
if (G_UNLIKELY (flags != 0)) {
/* https://docs.microsoft.com/en-us/windows/win32/api/audioclient/ne-audioclient-_audclnt_bufferflags */
if (flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY)
@@ -625,9 +621,14 @@ gst_wasapi_src_read (GstAudioSrc * asrc, gpointer data, guint length,
/* Copy all the frames we got into the adapter, and then extract at most
* @wanted size of frames from it. This helps when ::GetBuffer returns more
- * data than we can handle right now */
+ * data than we can handle right now. */
{
GstBuffer *tmp = gst_buffer_new_allocate (NULL, got_frames * bpf, NULL);
+ /* If flags has AUDCLNT_BUFFERFLAGS_SILENT, we will ignore the actual
+ * data and write out silence, see:
+ * https://docs.microsoft.com/en-us/windows/win32/api/audioclient/ne-audioclient-_audclnt_bufferflags */
+ if (flags & AUDCLNT_BUFFERFLAGS_SILENT)
+ memset (from, 0, got_frames * bpf);
gst_buffer_fill (tmp, 0, from, got_frames * bpf);
gst_adapter_push (self->adapter, tmp);
}