Add functions to get string names for sample types and channel configs

This commit is contained in:
Chris Robinson 2012-03-19 02:31:40 -07:00
parent 4a0b5b7918
commit dc6354b2f9
3 changed files with 25 additions and 1 deletions

View file

@ -44,7 +44,7 @@ static ALenum getALFormat(ChannelConfig chans, SampleType type)
if(fmtlist[i].chans == chans && fmtlist[i].type == type) if(fmtlist[i].chans == chans && fmtlist[i].type == type)
return fmtlist[i].format; return fmtlist[i].format;
} }
fail("Unsupported sound format"); fail(std::string("Unsupported sound format (")+getChannelConfigName(chans)+", "+getSampleTypeName(type)+")");
return AL_NONE; return AL_NONE;
} }

View file

@ -9,10 +9,13 @@ namespace MWSound
SampleType_UInt8, SampleType_UInt8,
SampleType_Int16 SampleType_Int16
}; };
const char *getSampleTypeName(SampleType type);
enum ChannelConfig { enum ChannelConfig {
ChannelConfig_Mono, ChannelConfig_Mono,
ChannelConfig_Stereo ChannelConfig_Stereo
}; };
const char *getChannelConfigName(ChannelConfig config);
class Sound_Decoder class Sound_Decoder
{ {

View file

@ -464,4 +464,25 @@ namespace MWSound
updateRegionSound(duration); updateRegionSound(duration);
} }
const char *getSampleTypeName(SampleType type)
{
switch(type)
{
case SampleType_UInt8: return "U8";
case SampleType_Int16: return "S16";
}
return "(unknown sample type)";
}
const char *getChannelConfigName(ChannelConfig config)
{
switch(config)
{
case ChannelConfig_Mono: return "Mono";
case ChannelConfig_Stereo: return "Stereo";
}
return "(unknown channel config)";
}
} }