summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2019-02-23 10:17:37 +0100
committerGitHub <noreply@github.com>2019-02-23 10:17:37 +0100
commit76a8d6f15fae400c1ad667425b7cacd999055026 (patch)
treee1ef92771c30123f483c54fcf8d373810df15ff9
parent4f697f73a5ac567c1dc22ce44a7fab98f619dfe3 (diff)
parente1e4f96995a5c490ecbc522852ebb8e8ea626045 (diff)
Merge pull request #26183 from marcelofg55/wasapi_notsupported_format
Fix WASAPI driver not working when the device doesn't supports the mix format
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index 685e821389..c97849ef07 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -238,6 +238,32 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
hr = p_device->audio_client->GetMixFormat(&pwfex);
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
+ print_verbose("WASAPI: wFormatTag = " + itos(pwfex->wFormatTag));
+ print_verbose("WASAPI: nChannels = " + itos(pwfex->nChannels));
+ print_verbose("WASAPI: nSamplesPerSec = " + itos(pwfex->nSamplesPerSec));
+ print_verbose("WASAPI: nAvgBytesPerSec = " + itos(pwfex->nAvgBytesPerSec));
+ print_verbose("WASAPI: nBlockAlign = " + itos(pwfex->nBlockAlign));
+ print_verbose("WASAPI: wBitsPerSample = " + itos(pwfex->wBitsPerSample));
+ print_verbose("WASAPI: cbSize = " + itos(pwfex->cbSize));
+
+ WAVEFORMATEX *closest = NULL;
+ hr = p_device->audio_client->IsFormatSupported(AUDCLNT_SHAREMODE_SHARED, pwfex, &closest);
+ if (hr == S_FALSE) {
+ WARN_PRINT("WASAPI: Mix format is not supported by the Device");
+ if (closest) {
+ print_verbose("WASAPI: closest->wFormatTag = " + itos(closest->wFormatTag));
+ print_verbose("WASAPI: closest->nChannels = " + itos(closest->nChannels));
+ print_verbose("WASAPI: closest->nSamplesPerSec = " + itos(closest->nSamplesPerSec));
+ print_verbose("WASAPI: closest->nAvgBytesPerSec = " + itos(closest->nAvgBytesPerSec));
+ print_verbose("WASAPI: closest->nBlockAlign = " + itos(closest->nBlockAlign));
+ print_verbose("WASAPI: closest->wBitsPerSample = " + itos(closest->wBitsPerSample));
+ print_verbose("WASAPI: closest->cbSize = " + itos(closest->cbSize));
+
+ WARN_PRINT("WASAPI: Using closest match instead");
+ pwfex = closest;
+ }
+ }
+
// Since we're using WASAPI Shared Mode we can't control any of these, we just tag along
p_device->channels = pwfex->nChannels;
p_device->format_tag = pwfex->wFormatTag;