mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

Add support for GDK (<https://github.com/microsoft/GDK>) #398

Closed thedmd closed 2 years ago

thedmd commented 2 years ago

This add rough on the edges support for building with Microsoft GDK, which enable miniaudio to work on Xbox consoles.

GDK is publicly available https://github.com/microsoft/GDK and Samples using WASAPI (https://github.com/microsoft/Xbox-GDK-Samples/tree/main/Samples/Audio/SimpleWASAPIPlaySound) are publicly available.

Majority of the code is shared with MM_WIN32_DESKTOP. Extra flag is introduced MA_WIN32_GDK, which is defined if application is built with GDK. You may want to keep using one define to control UWP and non-UWP code, like MA_WASAPI_FULL or MA_WASAPI_UWP; I don't know what approach is preferred.

GDK advertise itself with defines:

One of _GAMING_XBOX_XBOXONE (Xbox One) or _GAMING_XBOX_SCARLETT (Xbox Series X/S) is defined when _GAMING_XBOX is present if for some reason there is a need to distinguish between platforms. All this information is available in samples mentioned above.

In PR only check for WINAPI_FAMILY == WINAPI_FAMILY_GAMES is present, since there is a fallback to MA_WIN32_DESKTOP when no other platform is detected, which fit nicely.

In samples I didn't found any ifdefs related to platforms so WASAPI should work exactly like on desktop. Capture and enumerating extra devices I suspect work in same everywhere.

I tested only playback and it works (with and without MA_NO_RUNTIME_LINKING, it has no effect on the build).

mackron commented 2 years ago

Thanks for this! Happy to merge.