From d7a017ff2529cf7e7f41e1f52d33266853897da2 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Tue, 8 Nov 2022 12:25:24 +0100 Subject: [PATCH] report most significant audio device properties (#792) --- src/i_sound.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/i_sound.c b/src/i_sound.c index 0fb8cba5..4e03d31b 100644 --- a/src/i_sound.c +++ b/src/i_sound.c @@ -707,13 +707,11 @@ void I_InitSound(void) { if(!nosfxparm || !nomusicparm) { - int audio_buffers; + Uint16 mix_format; + int mix_channels; printf("I_InitSound: "); - /* Initialize variables */ - audio_buffers = GetSliceSize(); - // haleyjd: the docs say we should do this // In SDL2, SDL_InitSubSystem() and SDL_Init() are interchangeable. if (SDL_Init(SDL_INIT_AUDIO) < 0) @@ -722,7 +720,7 @@ void I_InitSound(void) return; } - if (Mix_OpenAudioDevice(snd_samplerate, AUDIO_S16SYS, 2, audio_buffers, NULL, + if (Mix_OpenAudioDevice(snd_samplerate, AUDIO_S16SYS, 2, GetSliceSize(), NULL, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_SAMPLES_CHANGE) < 0) { printf("Couldn't open audio with desired format.\n"); @@ -730,11 +728,16 @@ void I_InitSound(void) } // [FG] feed actual sample frequency back into config variable - Mix_QuerySpec(&snd_samplerate, NULL, NULL); + Mix_QuerySpec(&snd_samplerate, &mix_format, &mix_channels); + printf("Configured audio device with %.1f kHz (%s%d%s), %d channels.\n", + (float)snd_samplerate / 1000, + SDL_AUDIO_ISFLOAT(mix_format) ? "F" : SDL_AUDIO_ISSIGNED(mix_format) ? "S" : "U", + (int)SDL_AUDIO_BITSIZE(mix_format), + SDL_AUDIO_ISBIGENDIAN(mix_format) ? "MSB" : "LSB", + mix_channels); // [FG] let SDL_Mixer do the actual sound mixing Mix_AllocateChannels(MAX_CHANNELS); - printf("Configured audio device with %d samples/slice.\n", audio_buffers); I_AtExit(I_ShutdownSound, true);