This will be in next FAudio release.
This fixes a regression in some games, such as Far Cry 4, where audio doesn't work anymore since the move to FAudio Win32 platform.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
v2: Only pick the format change, remove the corresponding todo_wine.
dlls/xaudio2_7/tests/xaudio2.c | 1 - libs/faudio/src/FAudio_platform_win32.c | 27 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/dlls/xaudio2_7/tests/xaudio2.c b/dlls/xaudio2_7/tests/xaudio2.c index ea7e2ec121a..9821553166e 100644 --- a/dlls/xaudio2_7/tests/xaudio2.c +++ b/dlls/xaudio2_7/tests/xaudio2.c @@ -940,7 +940,6 @@ static UINT32 test_DeviceDetails(IXAudio27 *xa) else ok(dd.Role == NotDefaultDevice, "Got wrong role for index %u: 0x%x\n", i, dd.Role);
- todo_wine ok(IsEqualGUID(&dd.OutputFormat.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM), "got format %s\n", debugstr_guid(&dd.OutputFormat.SubFormat)); } diff --git a/libs/faudio/src/FAudio_platform_win32.c b/libs/faudio/src/FAudio_platform_win32.c index ccb8d8abbbf..d99bae044a4 100644 --- a/libs/faudio/src/FAudio_platform_win32.c +++ b/libs/faudio/src/FAudio_platform_win32.c @@ -364,13 +364,14 @@ uint32_t FAudio_PlatformGetDeviceDetails( uint32_t index, FAudioDeviceDetails *details ) { + WAVEFORMATEX *format, *obtained; WAVEFORMATEXTENSIBLE *ext; - WAVEFORMATEX *format; IAudioClient *client; IMMDevice *device; uint32_t ret = 0; HRESULT hr; WCHAR *str; + GUID sub;
FAudio_memset(details, 0, sizeof(FAudioDeviceDetails)); if (index > 0) return FAUDIO_E_INVALID_CALL; @@ -406,6 +407,28 @@ uint32_t FAudio_PlatformGetDeviceDetails( hr = IAudioClient_GetMixFormat(client, &format); FAudio_assert(!FAILED(hr) && "Failed to get audio client mix format!");
+ if (format->wFormatTag == WAVE_FORMAT_EXTENSIBLE) + { + ext = (WAVEFORMATEXTENSIBLE *)format; + sub = ext->SubFormat; + FAudio_memcpy( + &ext->SubFormat, + &DATAFORMAT_SUBTYPE_PCM, + sizeof(GUID) + ); + + hr = IAudioClient_IsFormatSupported(client, AUDCLNT_SHAREMODE_SHARED, format, &obtained); + if (FAILED(hr)) + { + ext->SubFormat = sub; + } + else if (obtained) + { + CoTaskMemFree(format); + format = obtained; + } + } + details->OutputFormat.Format.wFormatTag = format->wFormatTag; details->OutputFormat.Format.nChannels = format->nChannels; details->OutputFormat.Format.nSamplesPerSec = format->nSamplesPerSec; @@ -426,6 +449,8 @@ uint32_t FAudio_PlatformGetDeviceDetails( ); }
+ CoTaskMemFree(format); + IAudioClient_Release(client);
IMMDevice_Release(device);