diskaudio: Use SDL_GetAudioFormatName instead of recreating it from scratch.

This commit is contained in:
Ryan C. Gordon 2025-03-30 19:25:38 -04:00
parent f05bb7aae2
commit 8eb57c5a42
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 5 additions and 13 deletions

View File

@ -102,20 +102,12 @@ static const char *get_filename(const bool recording)
static const char *AudioFormatString(SDL_AudioFormat fmt) static const char *AudioFormatString(SDL_AudioFormat fmt)
{ {
switch (fmt) { const char *str = SDL_GetAudioFormatName(fmt);
#define CHECK_FMT(x) case SDL_AUDIO_##x: return #x SDL_assert(str);
CHECK_FMT(U8); if (SDL_strncmp(str, "SDL_AUDIO_", 10) == 0) {
CHECK_FMT(S8); str += 10; // so we return "S8" instead of "SDL_AUDIO_S8", etc.
CHECK_FMT(S16LE);
CHECK_FMT(S16BE);
CHECK_FMT(S32LE);
CHECK_FMT(S32BE);
CHECK_FMT(F32LE);
CHECK_FMT(F32BE);
#undef CHECK_FMT
default: break;
} }
return "[unknown]"; return str;
} }
static bool DISKAUDIO_OpenDevice(SDL_AudioDevice *device) static bool DISKAUDIO_OpenDevice(SDL_AudioDevice *device)