mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:56:43 +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(mSndFile)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if(info.channels == 1)
 | 
					        if(info.channels == 1)
 | 
				
			||||||
            mChanConfig = MonoChannels;
 | 
					            mChanConfig = ChannelConfig_Mono;
 | 
				
			||||||
        else if(info.channels == 2)
 | 
					        else if(info.channels == 2)
 | 
				
			||||||
            mChanConfig = StereoChannels;
 | 
					            mChanConfig = ChannelConfig_Stereo;
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            sf_close(mSndFile);
 | 
					            sf_close(mSndFile);
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ void MpgSnd_Decoder::open(const std::string &fname)
 | 
				
			||||||
                fail("Unsupported encoding in "+fname);
 | 
					                fail("Unsupported encoding in "+fname);
 | 
				
			||||||
            if(channels != 1 && channels != 2)
 | 
					            if(channels != 1 && channels != 2)
 | 
				
			||||||
                fail("Unsupported channel count in "+fname);
 | 
					                fail("Unsupported channel count in "+fname);
 | 
				
			||||||
            mChanConfig = ((channels==2)?StereoChannels:MonoChannels);
 | 
					            mChanConfig = ((channels==2)?ChannelConfig_Stereo:ChannelConfig_Mono);
 | 
				
			||||||
            mSampleRate = rate;
 | 
					            mSampleRate = rate;
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -88,7 +88,7 @@ void MpgSnd_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    *samplerate = mSampleRate;
 | 
					    *samplerate = mSampleRate;
 | 
				
			||||||
    *chans = mChanConfig;
 | 
					    *chans = mChanConfig;
 | 
				
			||||||
    *type = Int16Sample;
 | 
					    *type = SampleType_Int16;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t MpgSnd_Decoder::read(char *buffer, size_t bytes)
 | 
					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;
 | 
					            return AL_FORMAT_MONO16;
 | 
				
			||||||
        else if(type == Sound_Decoder::UInt8Sample)
 | 
					        else if(type == SampleType_UInt8)
 | 
				
			||||||
            return AL_FORMAT_MONO8;
 | 
					            return AL_FORMAT_MONO8;
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            fail("Unsupported sample type");
 | 
					            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;
 | 
					            return AL_FORMAT_STEREO16;
 | 
				
			||||||
        else if(type == Sound_Decoder::UInt8Sample)
 | 
					        else if(type == SampleType_UInt8)
 | 
				
			||||||
            return AL_FORMAT_STEREO8;
 | 
					            return AL_FORMAT_STEREO8;
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            fail("Unsupported sample type");
 | 
					            fail("Unsupported sample type");
 | 
				
			||||||
| 
						 | 
					@ -51,8 +51,8 @@ static ALenum getALFormat(Sound_Decoder::ChannelConfig chans, Sound_Decoder::Sam
 | 
				
			||||||
ALuint LoadBuffer(DecoderPtr decoder)
 | 
					ALuint LoadBuffer(DecoderPtr decoder)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int srate;
 | 
					    int srate;
 | 
				
			||||||
    Sound_Decoder::ChannelConfig chans;
 | 
					    ChannelConfig chans;
 | 
				
			||||||
    Sound_Decoder::SampleType type;
 | 
					    SampleType type;
 | 
				
			||||||
    ALenum format;
 | 
					    ALenum format;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    decoder->getInfo(&srate, &chans, &type);
 | 
					    decoder->getInfo(&srate, &chans, &type);
 | 
				
			||||||
| 
						 | 
					@ -136,8 +136,8 @@ OpenAL_SoundStream::OpenAL_SoundStream(DecoderPtr decoder)
 | 
				
			||||||
    try
 | 
					    try
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        int srate;
 | 
					        int srate;
 | 
				
			||||||
        Sound_Decoder::ChannelConfig chans;
 | 
					        ChannelConfig chans;
 | 
				
			||||||
        Sound_Decoder::SampleType type;
 | 
					        SampleType type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        mDecoder->getInfo(&srate, &chans, &type);
 | 
					        mDecoder->getInfo(&srate, &chans, &type);
 | 
				
			||||||
        mFormat = getALFormat(chans, type);
 | 
					        mFormat = getALFormat(chans, type);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,22 @@
 | 
				
			||||||
#ifndef GAME_SOUND_SOUND_DECODER_H
 | 
					#ifndef GAME_SOUND_SOUND_DECODER_H
 | 
				
			||||||
#define GAME_SOUND_SOUND_DECODER_H
 | 
					#define GAME_SOUND_SOUND_DECODER_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace MWSound
 | 
					namespace MWSound
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    enum SampleType {
 | 
				
			||||||
 | 
					        SampleType_UInt8,
 | 
				
			||||||
 | 
					        SampleType_Int16
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    enum ChannelConfig {
 | 
				
			||||||
 | 
					        ChannelConfig_Mono,
 | 
				
			||||||
 | 
					        ChannelConfig_Stereo
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class Sound_Decoder
 | 
					    class Sound_Decoder
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        enum SampleType {
 | 
					 | 
				
			||||||
            UInt8Sample,
 | 
					 | 
				
			||||||
            Int16Sample
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        enum ChannelConfig {
 | 
					 | 
				
			||||||
            MonoChannels,
 | 
					 | 
				
			||||||
            StereoChannels
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        virtual void open(const std::string &fname) = 0;
 | 
					        virtual void open(const std::string &fname) = 0;
 | 
				
			||||||
        virtual void close() = 0;
 | 
					        virtual void close() = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue