Skip to content

Commit c6bb4e2

Browse files
giomasceflibitijibibo
authored andcommitted
win32: Use AUTOCONVERTPCM when initializing the audio client.
Right now, on Wine, IsFormatSupported() advertises every (extensible) format as supported, and correspondingly Initialize() accepts every (extensible) format. However that behavior is not what happen on Windows, where both IsFormatSupported() and Initialize() rejects format the differ from the current mmdevapi mix format for anything other than the sample format. This might be rectified at some point in Wine. To maintain the current behavior in FAudio, we stop querying with IsFormatSupported() and pass flag AUTOCONVERTPCM to Initialize().
1 parent 730ae9e commit c6bb4e2

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

src/FAudio_platform_win32.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ void FAudio_PlatformInit(
352352
struct FAudioAudioClientThreadArgs *args;
353353
struct FAudioWin32PlatformData *data;
354354
REFERENCE_TIME duration;
355-
WAVEFORMATEX *closest;
356355
IMMDevice *device = NULL;
357356
HRESULT hr;
358357
HANDLE audioEvent = NULL;
@@ -419,25 +418,10 @@ void FAudio_PlatformInit(
419418
if (flags & FAUDIO_1024_QUANTUM) duration = 213333;
420419
else duration = 100000;
421420

422-
hr = IAudioClient_IsFormatSupported(
423-
data->client,
424-
AUDCLNT_SHAREMODE_SHARED,
425-
&args->format.Format,
426-
&closest
427-
);
428-
FAudio_assert(!FAILED(hr) && "Failed to find supported audio format!");
429-
430-
if (closest)
431-
{
432-
if (closest->wFormatTag != WAVE_FORMAT_EXTENSIBLE) args->format.Format = *closest;
433-
else args->format = *(WAVEFORMATEXTENSIBLE *)closest;
434-
CoTaskMemFree(closest);
435-
}
436-
437421
hr = IAudioClient_Initialize(
438422
data->client,
439423
AUDCLNT_SHAREMODE_SHARED,
440-
AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
424+
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM,
441425
duration * 3,
442426
0,
443427
&args->format.Format,

0 commit comments

Comments
 (0)