From 36172fb391daf7d9695d94bf212d9cfceccb9dc6 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 16 Jan 2011 16:26:53 -0700 Subject: [PATCH] Print SDL sound format. From ioquake3. --- Quake/snd_sdl.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Quake/snd_sdl.c b/Quake/snd_sdl.c index 80769024..42b1fb32 100644 --- a/Quake/snd_sdl.c +++ b/Quake/snd_sdl.c @@ -71,6 +71,23 @@ static void paint_audio (void *unused, Uint8 *stream, int len) shm->samplepos = 0; } +static struct +{ + Uint16 enumFormat; + char *stringFormat; +} formatToStringTable[ ] = +{ + { AUDIO_U8, "AUDIO_U8" }, + { AUDIO_S8, "AUDIO_S8" }, + { AUDIO_U16LSB, "AUDIO_U16LSB" }, + { AUDIO_S16LSB, "AUDIO_S16LSB" }, + { AUDIO_U16MSB, "AUDIO_U16MSB" }, + { AUDIO_S16MSB, "AUDIO_S16MSB" } +}; + +static int formatToStringTableSize = +sizeof( formatToStringTable ) / sizeof( formatToStringTable[ 0 ] ); + qboolean SNDDMA_Init (void) { SDL_AudioSpec desired, obtained; @@ -142,8 +159,19 @@ qboolean SNDDMA_Init (void) shm->samplepos = 0; shm->submission_chunk = 1; - Con_Printf ("SDL audio spec : %d Hz, %d samples, %d channels\n", - obtained.freq, obtained.samples, obtained.channels); + { + int i; + char *fmt = NULL; + for( i = 0; i < formatToStringTableSize; i++ ) { + if( obtained.format == formatToStringTable[ i ].enumFormat ) { + fmt = formatToStringTable[ i ].stringFormat; + } + } + + Con_Printf ("SDL audio spec : %s, %d Hz, %d samples, %d channels\n", + fmt, obtained.freq, obtained.samples, obtained.channels); + } + if (SDL_AudioDriverName(drivername, sizeof(drivername)) == NULL) strcpy(drivername, "(UNKNOWN)"); buffersize = shm->samples * (shm->samplebits / 8);