summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-05-24 11:04:08 +0200
committerNirbheek Chauhan <nirbheek@centricular.com>2018-05-25 19:08:18 +0530
commit839cc392686c2d5657d5a0b16661ad53ce0e76b3 (patch)
tree975fa70f8833c233200ba961a19ec22243b7d1a1
parent6184527532617cbc082e26dffa94108f958e1b21 (diff)
wasapisink: fix a rounding error when calculating the buffer frame count
The calculation for the frame count in the non-aligned case resulted in a one too low buffer frame count. This resulted in: 1) exclusive mode not working as the frame count has to match exactly there. 2) Buffer underruns in shared mode as the current write() code doesn't handle catching up to low buffer levels (fixed in the next commit) To fix just use the wasapi API to get the buffer size which will always be correct. https://bugzilla.gnome.org/show_bug.cgi?id=796354
-rw-r--r--sys/wasapi/gstwasapiutil.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/wasapi/gstwasapiutil.c b/sys/wasapi/gstwasapiutil.c
index 2084dbb86..e09d1364e 100644
--- a/sys/wasapi/gstwasapiutil.c
+++ b/sys/wasapi/gstwasapiutil.c
@@ -845,6 +845,7 @@ gst_wasapi_util_initialize_audioclient (GstElement * self,
REFERENCE_TIME default_period, min_period;
REFERENCE_TIME device_period, device_buffer_duration;
guint rate;
+ guint32 n_frames;
HRESULT hr;
hr = IAudioClient_GetDevicePeriod (client, &default_period, &min_period);
@@ -877,8 +878,6 @@ gst_wasapi_util_initialize_audioclient (GstElement * self,
if (hr == AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED &&
sharemode == AUDCLNT_SHAREMODE_EXCLUSIVE) {
- guint32 n_frames;
-
GST_WARNING_OBJECT (self, "initialize failed due to unaligned period %i",
(int) device_period);
@@ -897,7 +896,10 @@ gst_wasapi_util_initialize_audioclient (GstElement * self,
}
HR_FAILED_RET (hr, IAudioClient::Initialize, FALSE);
- *ret_devicep_frames = (rate * device_period * 100) / GST_SECOND;
+ hr = IAudioClient_GetBufferSize (client, &n_frames);
+ HR_FAILED_RET (hr, IAudioClient::GetBufferSize, FALSE);
+
+ *ret_devicep_frames = n_frames;
return TRUE;
}