Jinoh Kang (@iamahuman) commented about dlls/windows.media.speech/recognizer.c:
+ if (!(session->audio_buf_event = CreateEventW(NULL, FALSE, FALSE, NULL))) + return HRESULT_FROM_WIN32(GetLastError()); + + if (FAILED(hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void **)&mm_enum))) + goto cleanup; + + if (FAILED(hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(mm_enum, eCapture, eMultimedia, &mm_device))) + goto cleanup; + + if (FAILED(hr = IMMDevice_Activate(mm_device, &IID_IAudioClient, CLSCTX_INPROC_SERVER, NULL, (void **)&session->audio_client))) + goto cleanup; + + if (SUCCEEDED(hr = IMMDevice_GetId(mm_device, &str))) + TRACE("selected capture device ID: %s\n", debugstr_w(str)); + + if (FAILED(hr = IAudioClient_GetMixFormat(session->audio_client, (WAVEFORMATEX **)&wfx))) On second thought, we don't actually need to fetch `WAVEFORMATEX` at all, since we use none of the values set by `IAudioClient::GetMixFormat`. Also ote that for WAVE_FORMAT_PCM formats (and only WAVE_FORMAT_PCM formats), the `cbSize` member is ignored.<sup>[[1]][GetMixFormat]</sup>
Therefore, we can just remove the pointer from `session->capture_wfx`'s type, making it `WAVEFORMATEX capture_wfx;`. That way, we don't have to `CoTaskMemFree(session->capture_wfx)`, and we can write to the structure directly. [GetMixFormat]: https://learn.microsoft.com/en-us/windows/win32/api/mmeapi/ns-mmeapi-wavefor... -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1948#note_21435