Module: wine Branch: master Commit: 9cd13ecb3067f373c5d5f35a4ee07331901a60e9 URL: https://gitlab.winehq.org/wine/wine/-/commit/9cd13ecb3067f373c5d5f35a4ee0733...
Author: Davide Beatrici git@davidebeatrici.dev Date: Thu Jun 8 08:23:35 2023 +0200
winepulse: Move AudioClient's GetDevicePeriod, GetMixFormat, IsFormatSupported into mmdevapi.
---
dlls/mmdevapi/client.c | 117 ++++++++++++++++++++++++++++++++++++++++++ dlls/winepulse.drv/mmdevdrv.c | 93 ++++----------------------------- 2 files changed, 126 insertions(+), 84 deletions(-)
diff --git a/dlls/mmdevapi/client.c b/dlls/mmdevapi/client.c index 9755dd2d8ef..78873234eec 100644 --- a/dlls/mmdevapi/client.c +++ b/dlls/mmdevapi/client.c @@ -80,6 +80,40 @@ static inline struct audio_client *impl_from_IAudioStreamVolume(IAudioStreamVolu return CONTAINING_RECORD(iface, struct audio_client, IAudioStreamVolume_iface); }
+static void dump_fmt(const WAVEFORMATEX *fmt) +{ + TRACE("wFormatTag: 0x%x (", fmt->wFormatTag); + switch (fmt->wFormatTag) { + case WAVE_FORMAT_PCM: + TRACE("WAVE_FORMAT_PCM"); + break; + case WAVE_FORMAT_IEEE_FLOAT: + TRACE("WAVE_FORMAT_IEEE_FLOAT"); + break; + case WAVE_FORMAT_EXTENSIBLE: + TRACE("WAVE_FORMAT_EXTENSIBLE"); + break; + default: + TRACE("Unknown"); + break; + } + TRACE(")\n"); + + TRACE("nChannels: %u\n", fmt->nChannels); + TRACE("nSamplesPerSec: %lu\n", fmt->nSamplesPerSec); + TRACE("nAvgBytesPerSec: %lu\n", fmt->nAvgBytesPerSec); + TRACE("nBlockAlign: %u\n", fmt->nBlockAlign); + TRACE("wBitsPerSample: %u\n", fmt->wBitsPerSample); + TRACE("cbSize: %u\n", fmt->cbSize); + + if (fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { + WAVEFORMATEXTENSIBLE *fmtex = (void *)fmt; + TRACE("dwChannelMask: %08lx\n", fmtex->dwChannelMask); + TRACE("Samples: %04x\n", fmtex->Samples.wReserved); + TRACE("SubFormat: %s\n", wine_dbgstr_guid(&fmtex->SubFormat)); + } +} + static DWORD CALLBACK timer_loop_func(void *user) { struct timer_loop_params params; @@ -210,6 +244,89 @@ const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl = capture_GetNextPacketSize };
+HRESULT WINAPI client_IsFormatSupported(IAudioClient3 *iface, AUDCLNT_SHAREMODE mode, + const WAVEFORMATEX *fmt, WAVEFORMATEX **out) +{ + struct audio_client *This = impl_from_IAudioClient3(iface); + struct is_format_supported_params params; + + TRACE("(%p)->(%x, %p, %p)\n", This, mode, fmt, out); + + if (fmt) + dump_fmt(fmt); + + params.device = This->device_name; + params.flow = This->dataflow; + params.share = mode; + params.fmt_in = fmt; + params.fmt_out = NULL; + + if (out) { + *out = NULL; + if (mode == AUDCLNT_SHAREMODE_SHARED) + params.fmt_out = CoTaskMemAlloc(sizeof(*params.fmt_out)); + } + + WINE_UNIX_CALL(is_format_supported, ¶ms); + + if (params.result == S_FALSE) + *out = ¶ms.fmt_out->Format; + else + CoTaskMemFree(params.fmt_out); + + return params.result; +} + +HRESULT WINAPI client_GetMixFormat(IAudioClient3 *iface, WAVEFORMATEX **pwfx) +{ + struct audio_client *This = impl_from_IAudioClient3(iface); + struct get_mix_format_params params; + + TRACE("(%p)->(%p)\n", This, pwfx); + + if (!pwfx) + return E_POINTER; + + *pwfx = NULL; + + params.device = This->device_name; + params.flow = This->dataflow; + params.fmt = CoTaskMemAlloc(sizeof(WAVEFORMATEXTENSIBLE)); + if (!params.fmt) + return E_OUTOFMEMORY; + + WINE_UNIX_CALL(get_mix_format, ¶ms); + + if (SUCCEEDED(params.result)) { + *pwfx = ¶ms.fmt->Format; + dump_fmt(*pwfx); + } else + CoTaskMemFree(params.fmt); + + return params.result; +} + +HRESULT WINAPI client_GetDevicePeriod(IAudioClient3 *iface, REFERENCE_TIME *defperiod, + REFERENCE_TIME *minperiod) +{ + struct audio_client *This = impl_from_IAudioClient3(iface); + struct get_device_period_params params; + + TRACE("(%p)->(%p, %p)\n", This, defperiod, minperiod); + + if (!defperiod && !minperiod) + return E_POINTER; + + params.device = This->device_name; + params.flow = This->dataflow; + params.def_period = defperiod; + params.min_period = minperiod; + + WINE_UNIX_CALL(get_device_period, ¶ms); + + return params.result; +} + HRESULT WINAPI client_Start(IAudioClient3 *iface) { struct audio_client *This = impl_from_IAudioClient3(iface); diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index b8b0eff3116..f6663c8d467 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -853,90 +853,15 @@ static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface, return params.result; }
-static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient3 *iface, +extern HRESULT WINAPI client_IsFormatSupported(IAudioClient3 *iface, AUDCLNT_SHAREMODE mode, const WAVEFORMATEX *fmt, - WAVEFORMATEX **out) -{ - ACImpl *This = impl_from_IAudioClient3(iface); - struct is_format_supported_params params; - - TRACE("(%p)->(%x, %p, %p)\n", This, mode, fmt, out); - - if (fmt) - dump_fmt(fmt); - - params.device = This->device_name; - params.flow = This->dataflow; - params.share = mode; - params.fmt_in = fmt; - params.fmt_out = NULL; + WAVEFORMATEX **out);
- if (out) { - *out = NULL; - if (mode == AUDCLNT_SHAREMODE_SHARED) - params.fmt_out = CoTaskMemAlloc(sizeof(*params.fmt_out)); - } - - pulse_call(is_format_supported, ¶ms); +extern HRESULT WINAPI client_GetMixFormat(IAudioClient3 *iface, + WAVEFORMATEX **pwfx);
- if (params.result == S_FALSE) - *out = ¶ms.fmt_out->Format; - else - CoTaskMemFree(params.fmt_out); - - return params.result; -} - -static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient3 *iface, - WAVEFORMATEX **pwfx) -{ - ACImpl *This = impl_from_IAudioClient3(iface); - struct get_mix_format_params params; - - TRACE("(%p)->(%p)\n", This, pwfx); - - if (!pwfx) - return E_POINTER; - *pwfx = NULL; - - params.device = This->device_name; - params.flow = This->dataflow; - params.fmt = CoTaskMemAlloc(sizeof(WAVEFORMATEXTENSIBLE)); - if (!params.fmt) - return E_OUTOFMEMORY; - - pulse_call(get_mix_format, ¶ms); - - if (SUCCEEDED(params.result)) { - *pwfx = ¶ms.fmt->Format; - dump_fmt(*pwfx); - } else { - CoTaskMemFree(params.fmt); - } - - return params.result; -} - -static HRESULT WINAPI AudioClient_GetDevicePeriod(IAudioClient3 *iface, - REFERENCE_TIME *defperiod, REFERENCE_TIME *minperiod) -{ - struct get_device_period_params params; - ACImpl *This = impl_from_IAudioClient3(iface); - - TRACE("(%p)->(%p, %p)\n", This, defperiod, minperiod); - - if (!defperiod && !minperiod) - return E_POINTER; - - params.flow = This->dataflow; - params.device = This->device_name; - params.def_period = defperiod; - params.min_period = minperiod; - - pulse_call(get_device_period, ¶ms); - - return params.result; -} +extern HRESULT WINAPI client_GetDevicePeriod(IAudioClient3 *iface, + REFERENCE_TIME *defperiod, REFERENCE_TIME *minperiod);
extern HRESULT WINAPI client_Start(IAudioClient3 *iface);
@@ -980,9 +905,9 @@ static const IAudioClient3Vtbl AudioClient3_Vtbl = AudioClient_GetBufferSize, AudioClient_GetStreamLatency, AudioClient_GetCurrentPadding, - AudioClient_IsFormatSupported, - AudioClient_GetMixFormat, - AudioClient_GetDevicePeriod, + client_IsFormatSupported, + client_GetMixFormat, + client_GetDevicePeriod, client_Start, client_Stop, client_Reset,