mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-02 03:15:35 +00:00
Move the sample type and channel config enums to MWSound and give use appropriate names for the values
This commit is contained in:
parent
efae7dfe83
commit
403e51cef3
3 changed files with 26 additions and 23 deletions
|
@ -21,9 +21,9 @@ void MpgSnd_Decoder::open(const std::string &fname)
|
|||
if(mSndFile)
|
||||
{
|
||||
if(info.channels == 1)
|
||||
mChanConfig = MonoChannels;
|
||||
mChanConfig = ChannelConfig_Mono;
|
||||
else if(info.channels == 2)
|
||||
mChanConfig = StereoChannels;
|
||||
mChanConfig = ChannelConfig_Stereo;
|
||||
else
|
||||
{
|
||||
sf_close(mSndFile);
|
||||
|
@ -47,7 +47,7 @@ void MpgSnd_Decoder::open(const std::string &fname)
|
|||
fail("Unsupported encoding in "+fname);
|
||||
if(channels != 1 && channels != 2)
|
||||
fail("Unsupported channel count in "+fname);
|
||||
mChanConfig = ((channels==2)?StereoChannels:MonoChannels);
|
||||
mChanConfig = ((channels==2)?ChannelConfig_Stereo:ChannelConfig_Mono);
|
||||
mSampleRate = rate;
|
||||
return;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ void MpgSnd_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *
|
|||
|
||||
*samplerate = mSampleRate;
|
||||
*chans = mChanConfig;
|
||||
*type = Int16Sample;
|
||||
*type = SampleType_Int16;
|
||||
}
|
||||
|
||||
size_t MpgSnd_Decoder::read(char *buffer, size_t bytes)
|
||||
|
|
|
@ -22,22 +22,22 @@ static void throwALerror()
|
|||
}
|
||||
|
||||
|
||||
static ALenum getALFormat(Sound_Decoder::ChannelConfig chans, Sound_Decoder::SampleType type)
|
||||
static ALenum getALFormat(ChannelConfig chans, SampleType type)
|
||||
{
|
||||
if(chans == Sound_Decoder::MonoChannels)
|
||||
if(chans == ChannelConfig_Mono)
|
||||
{
|
||||
if(type == Sound_Decoder::Int16Sample)
|
||||
if(type == SampleType_Int16)
|
||||
return AL_FORMAT_MONO16;
|
||||
else if(type == Sound_Decoder::UInt8Sample)
|
||||
else if(type == SampleType_UInt8)
|
||||
return AL_FORMAT_MONO8;
|
||||
else
|
||||
fail("Unsupported sample type");
|
||||
}
|
||||
else if(chans == Sound_Decoder::StereoChannels)
|
||||
else if(chans == ChannelConfig_Stereo)
|
||||
{
|
||||
if(type == Sound_Decoder::Int16Sample)
|
||||
if(type == SampleType_Int16)
|
||||
return AL_FORMAT_STEREO16;
|
||||
else if(type == Sound_Decoder::UInt8Sample)
|
||||
else if(type == SampleType_UInt8)
|
||||
return AL_FORMAT_STEREO8;
|
||||
else
|
||||
fail("Unsupported sample type");
|
||||
|
@ -51,8 +51,8 @@ static ALenum getALFormat(Sound_Decoder::ChannelConfig chans, Sound_Decoder::Sam
|
|||
ALuint LoadBuffer(DecoderPtr decoder)
|
||||
{
|
||||
int srate;
|
||||
Sound_Decoder::ChannelConfig chans;
|
||||
Sound_Decoder::SampleType type;
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
ALenum format;
|
||||
|
||||
decoder->getInfo(&srate, &chans, &type);
|
||||
|
@ -136,8 +136,8 @@ OpenAL_SoundStream::OpenAL_SoundStream(DecoderPtr decoder)
|
|||
try
|
||||
{
|
||||
int srate;
|
||||
Sound_Decoder::ChannelConfig chans;
|
||||
Sound_Decoder::SampleType type;
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
|
||||
mDecoder->getInfo(&srate, &chans, &type);
|
||||
mFormat = getALFormat(chans, type);
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
#ifndef GAME_SOUND_SOUND_DECODER_H
|
||||
#define GAME_SOUND_SOUND_DECODER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
enum SampleType {
|
||||
SampleType_UInt8,
|
||||
SampleType_Int16
|
||||
};
|
||||
enum ChannelConfig {
|
||||
ChannelConfig_Mono,
|
||||
ChannelConfig_Stereo
|
||||
};
|
||||
|
||||
class Sound_Decoder
|
||||
{
|
||||
public:
|
||||
enum SampleType {
|
||||
UInt8Sample,
|
||||
Int16Sample
|
||||
};
|
||||
enum ChannelConfig {
|
||||
MonoChannels,
|
||||
StereoChannels
|
||||
};
|
||||
virtual void open(const std::string &fname) = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue