[PATCH 0/3] MR10224: winmm: Initialize the audio client with AUTOCONVERTPCM.
Currently nothing changes, but eventually the audio client will start rejecting formats that require channel or sample rate conversion if AUTOCONVERTPCM is not specified. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10224
From: Giovanni Mascellani <gmascellani@codeweavers.com> --- dlls/winmm/tests/wave.c | 2 -- dlls/winmm/waveform.c | 10 +++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dlls/winmm/tests/wave.c b/dlls/winmm/tests/wave.c index b23209541da..e1f7bf0768c 100644 --- a/dlls/winmm/tests/wave.c +++ b/dlls/winmm/tests/wave.c @@ -2088,7 +2088,6 @@ static void test_format(WAVEFORMATEXTENSIBLE *fmt) /* Native seems to largely ignore when the channel mask has nonsensical values, while Wine is more picky. */ || (fmt->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE && __popcnt(fmt->dwChannelMask) != fmt->Format.nChannels))) ok(mmr == expected || broken(channel_mismatch), "waveOutOpen(0) got result %#08x, expected %#08x\n", mmr, expected); - todo_wine_if((mmr == MMSYSERR_NOERROR) != !!hwo) ok((mmr == MMSYSERR_NOERROR) == !!hwo, "Unexpected waveout %p\n", hwo); if (hwo && hwo != (void *)0xdeadf00d) @@ -2108,7 +2107,6 @@ static void test_format(WAVEFORMATEXTENSIBLE *fmt) || (fmt->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE && __popcnt(fmt->dwChannelMask) != fmt->Format.nChannels))) ok(mmr == expected || (mmr == MMSYSERR_INVALPARAM && expected == WAVERR_BADFORMAT) || broken(channel_mismatch), "waveOutOpen(DIRECT) got result %#08x, expected %#08x\n", mmr, expected); - todo_wine_if((mmr == MMSYSERR_NOERROR) != !!hwo) ok((mmr == MMSYSERR_NOERROR) == !!hwo, "Unexpected waveout %p\n", hwo); if (hwo && hwo != (void *)0xdeadf00d) diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c index 8ede1282c8d..56ff56ea6d0 100644 --- a/dlls/winmm/waveform.c +++ b/dlls/winmm/waveform.c @@ -2742,8 +2742,16 @@ MMRESULT WINAPI waveOutOpen(LPHWAVEOUT lphWaveOut, UINT uDeviceID, res = SendMessageW(g_devices_hwnd, WODM_OPEN, (DWORD_PTR)&info, 0); InterlockedDecrement(&g_devthread_token); - if(res != MMSYSERR_NOERROR || (dwFlags & WAVE_FORMAT_QUERY)) + + if (dwFlags & WAVE_FORMAT_QUERY) + return res; + + if (res != MMSYSERR_NOERROR) + { + if (lphWaveOut) + *lphWaveOut = 0; return res; + } if(lphWaveOut) *lphWaveOut = (HWAVEOUT)info.handle; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10224
From: Giovanni Mascellani <gmascellani@codeweavers.com> Currently nothing changes, but eventually the audio client will start rejecting formats that require channel or sample rate conversion if AUTOCONVERTPCM is not specified. --- dlls/winmm/waveform.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c index 56ff56ea6d0..f3fd0f6d5b5 100644 --- a/dlls/winmm/waveform.c +++ b/dlls/winmm/waveform.c @@ -928,7 +928,8 @@ static MMRESULT WINMM_TryDeviceMapping(WINMM_Device *device, WAVEFORMATEX *fmt, } hr = IAudioClient_Initialize(device->client, AUDCLNT_SHAREMODE_SHARED, - AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST, + AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST + | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM, AC_BUFLEN, 0, &target, &device->parent->session); if(hr != S_OK){ WARN("Initialize failed: %08lx\n", hr); @@ -1139,8 +1140,10 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_OpenInfo *info, } hr = IAudioClient_Initialize(device->client, AUDCLNT_SHAREMODE_SHARED, - AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST, + AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST + | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM, AC_BUFLEN, 0, device->orig_fmt, &device->parent->session); + if(FAILED(hr)){ if(hr == AUDCLNT_E_UNSUPPORTED_FORMAT && !(info->flags & WAVE_FORMAT_DIRECT)){ ret = WINMM_MapDevice(device, FALSE, is_out); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10224
From: Giovanni Mascellani <gmascellani@codeweavers.com> It means that the format is supported, but it requires sample rate or channel count conversion. Since we're now using AUTOCONVERTPCM such conversion will be done automatically. --- dlls/winmm/waveform.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c index f3fd0f6d5b5..a5729d17ae0 100644 --- a/dlls/winmm/waveform.c +++ b/dlls/winmm/waveform.c @@ -906,7 +906,7 @@ static MMRESULT WINMM_TryDeviceMapping(WINMM_Device *device, WAVEFORMATEX *fmt, hr = IAudioClient_IsFormatSupported(device->client, AUDCLNT_SHAREMODE_SHARED, &target, &closer_fmt); CoTaskMemFree(closer_fmt); - if(hr != S_OK) + if(FAILED(hr)) return WAVERR_BADFORMAT; /* device supports our target format, so see if MSACM can @@ -1132,10 +1132,15 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_OpenInfo *info, hr = IAudioClient_IsFormatSupported(device->client, AUDCLNT_SHAREMODE_SHARED, device->orig_fmt, &closer_fmt); CoTaskMemFree(closer_fmt); - if((hr == S_FALSE || hr == AUDCLNT_E_UNSUPPORTED_FORMAT) && !(info->flags & WAVE_FORMAT_DIRECT)) - ret = WINMM_MapDevice(device, TRUE, is_out); + + /* S_FALSE means that the format requires conversion, but AUTOCONVERTPCM will do that for us. */ + if (SUCCEEDED(hr)) + ret = MMSYSERR_NOERROR; + else if (info->flags & WAVE_FORMAT_DIRECT) + ret = hr2mmr(hr); else - ret = hr == S_FALSE ? WAVERR_BADFORMAT : hr2mmr(hr); + ret = WINMM_MapDevice(device, TRUE, is_out); + goto error; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10224
This merge request was approved by Huw Davies. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10224
participants (3)
-
Giovanni Mascellani -
Giovanni Mascellani (@giomasce) -
Huw Davies (@huw)