Skip to content

Commit

Permalink
win32: Always check the return value of GetDefaultAudioEndpoint
Browse files Browse the repository at this point in the history
And don't crash if the computer doesn't have any audio devices.

Fixes #347
  • Loading branch information
alexhenrie authored and flibitijibibo committed May 9, 2024
1 parent 97707e9 commit 893cf51
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/FAudio_platform_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ void FAudio_PlatformInit(
eConsole,
&device
);
if (hr == E_NOTFOUND) {
FAudio_PlatformRelease();
return FAUDIO_E_INVALID_CALL;
}
FAudio_assert(!FAILED(hr) && "Failed to get default audio endpoint!");

hr = IMMDevice_Activate(
Expand Down Expand Up @@ -451,6 +455,10 @@ uint32_t FAudio_PlatformGetDeviceDetails(
eConsole,
&device
);
if (hr == E_NOTFOUND) {
FAudio_PlatformRelease();
return FAUDIO_E_INVALID_CALL;
}
FAudio_assert(!FAILED(hr) && "Failed to get default audio endpoint!");

details->Role = FAudioGlobalDefaultDevice;
Expand Down

0 comments on commit 893cf51

Please sign in to comment.