wasapi2: Fallback to IAudioClient interface if IAudioClient3 API is unavailable

When default device is selected, IAudioClient3 API doesn't look like
available.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1332>
This commit is contained in:
Seungha Yang 2020-06-11 01:47:14 +09:00 committed by GStreamer Merge Bot
parent 969e647925
commit 2e1bec7ff6

View file

@ -1165,12 +1165,24 @@ gst_wasapi2_client_initialize_audio_client (GstWasapi2Client * self,
rate = GST_AUDIO_INFO_RATE (&spec->info); rate = GST_AUDIO_INFO_RATE (&spec->info);
/* Clamp values to integral multiples of an appropriate period */ if (self->low_latency) {
gst_wasapi2_util_get_best_buffer_sizes (spec, device_period = default_period;
default_period, min_period, &device_period, &device_buffer_duration); /* this should be same as hnsPeriodicity
* when AUDCLNT_STREAMFLAGS_EVENTCALLBACK is used
* And in case of shared mode, hnsPeriodicity should be zero, so
* this value should be zero as well */
device_buffer_duration = 0;
} else {
/* Clamp values to integral multiples of an appropriate period */
gst_wasapi2_util_get_best_buffer_sizes (spec,
default_period, min_period, &device_period, &device_buffer_duration);
}
hr = audio_client->Initialize (AUDCLNT_SHAREMODE_SHARED, stream_flags, hr = audio_client->Initialize (AUDCLNT_SHAREMODE_SHARED, stream_flags,
device_buffer_duration, 0, self->mix_format, nullptr); device_buffer_duration,
/* This must always be 0 in shared mode */
0,
self->mix_format, nullptr);
if (!gst_wasapi2_result (hr)) { if (!gst_wasapi2_result (hr)) {
GST_WARNING_OBJECT (self, "Couldn't initialize audioclient"); GST_WARNING_OBJECT (self, "Couldn't initialize audioclient");
return FALSE; return FALSE;
@ -1220,7 +1232,14 @@ gst_wasapi2_client_open (GstWasapi2Client * client, GstAudioRingBufferSpec * spe
* https://bugzilla.gnome.org/show_bug.cgi?id=794497 */ * https://bugzilla.gnome.org/show_bug.cgi?id=794497 */
if (client->low_latency) if (client->low_latency)
initialized = gst_wasapi2_client_initialize_audio_client3 (client); initialized = gst_wasapi2_client_initialize_audio_client3 (client);
else
/* Try again if IAudioClinet3 API is unavailable.
* NOTE: IAudioClinet3:: methods might not be available for default device
* NOTE: The default device is a special device which is needed for supporting
* automatic stream routing
* https://docs.microsoft.com/en-us/windows/win32/coreaudio/automatic-stream-routing
*/
if (!initialized)
initialized = gst_wasapi2_client_initialize_audio_client (client, spec); initialized = gst_wasapi2_client_initialize_audio_client (client, spec);
if (!initialized) { if (!initialized) {