From 7f3be7bf14eddcec82e89e01f0a25b83b1a64ea1 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 28 Jun 2014 01:25:25 -0700 Subject: [PATCH] Show the name of unsupported sound formats with OpenAL --- src/sound/i_sound.cpp | 21 +++++++++++++++++++++ src/sound/i_soundinternal.h | 3 +++ src/sound/oalsound.cpp | 6 ++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index 97267d62c..852d50a6b 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -304,6 +304,27 @@ void I_ShutdownSound() } } +const char *GetSampleTypeName(enum SampleType type) +{ + switch(type) + { + case SampleType_UInt8: return "Unsigned 8-bit"; + case SampleType_Int16: return "Signed 16-bit"; + } + return "(invalid sample type)"; +} + +const char *GetChannelConfigName(enum ChannelConfig chan) +{ + switch(chan) + { + case ChannelConfig_Mono: return "Mono"; + case ChannelConfig_Stereo: return "Stereo"; + } + return "(invalid channel config)"; +} + + CCMD (snd_status) { GSnd->PrintStatus (); diff --git a/src/sound/i_soundinternal.h b/src/sound/i_soundinternal.h index 218c6724b..4f4c62b93 100644 --- a/src/sound/i_soundinternal.h +++ b/src/sound/i_soundinternal.h @@ -119,6 +119,9 @@ enum ChannelConfig ChannelConfig_Stereo }; +const char *GetSampleTypeName(enum SampleType type); +const char *GetChannelConfigName(enum ChannelConfig chan); + struct SoundDecoder { virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0; diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 131d41e6f..24ca27aa4 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -545,7 +545,8 @@ public: if(Format == AL_NONE) { - Printf("Unsupported audio format (0x%x / 0x%x)\n", chans, type); + Printf("Unsupported audio format: %s, %s\n", GetChannelConfigName(chans), + GetSampleTypeName(type)); return false; } SampleRate = srate; @@ -1019,7 +1020,8 @@ SoundHandle OpenALSoundRenderer::LoadSound(BYTE *sfxdata, int length) if(format == AL_NONE) { - Printf("Unsupported audio format (0x%x / 0x%x)\n", chans, type); + Printf("Unsupported audio format: %s, %s\n", GetChannelConfigName(chans), + GetSampleTypeName(type)); return retval; }