Skip to content

Commit

Permalink
Shared: Add missing audio format types for newer SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
ensiform committed Mar 9, 2018
1 parent 15e38f8 commit da0dc70
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions shared/sdl/sdl_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,23 @@ static void SNDDMA_AudioCallback(void *userdata, Uint8 *stream, int len)

static struct
{
Uint16 enumFormat;
char *stringFormat;
Uint16 enumFormat;
const 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" }
{ AUDIO_S16MSB, "AUDIO_S16MSB" },
{ AUDIO_S32LSB, "AUDIO_S32LSB" },
{ AUDIO_S32MSB, "AUDIO_S32MSB" },
{ AUDIO_F32LSB, "AUDIO_F32LSB" },
{ AUDIO_F32MSB, "AUDIO_F32MSB" }
};

static int formatToStringTableSize = ARRAY_LEN( formatToStringTable );
static const size_t formatToStringTableSize = ARRAY_LEN( formatToStringTable );

/*
===============
Expand All @@ -107,12 +111,11 @@ SNDDMA_PrintAudiospec
*/
static void SNDDMA_PrintAudiospec(const char *str, const SDL_AudioSpec *spec)
{
int i;
char *fmt = NULL;
const char *fmt = NULL;

Com_Printf("%s:\n", str);
Com_Printf( "%s:\n", str );

for( i = 0; i < formatToStringTableSize; i++ ) {
for( size_t i = 0; i < formatToStringTableSize; i++ ) {
if( spec->format == formatToStringTable[ i ].enumFormat ) {
fmt = formatToStringTable[ i ].stringFormat;
}
Expand All @@ -121,7 +124,7 @@ static void SNDDMA_PrintAudiospec(const char *str, const SDL_AudioSpec *spec)
if( fmt ) {
Com_Printf( " Format: %s\n", fmt );
} else {
Com_Printf( " Format: " S_COLOR_RED "UNKNOWN\n");
Com_Printf( " Format: " S_COLOR_RED "UNKNOWN (%d)\n", (int)spec->format);
}

Com_Printf( " Freq: %d\n", (int) spec->freq );
Expand Down

0 comments on commit da0dc70

Please sign in to comment.