diff options
author | Chris Robinson <[email protected]> | 2007-12-26 23:29:32 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2007-12-26 23:29:32 -0800 |
commit | 8011ad97b558fae4fb3c5fc44912dd7e99eed4e5 (patch) | |
tree | 1fe70d140dc06cf95d9f09118c7875431d07b3ee | |
parent | ab8d342df06fdfcc1b630e318e121bcfb6a1cdfa (diff) |
Don't check explicitly against formats, but rather their byte/channel count
-rw-r--r-- | Alc/ALu.c | 14 | ||||
-rw-r--r-- | Alc/alsa.c | 10 | ||||
-rw-r--r-- | Alc/dsound.c | 2 | ||||
-rw-r--r-- | Alc/oss.c | 20 |
4 files changed, 15 insertions, 31 deletions
@@ -327,28 +327,24 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, //6. Convert normalized position into pannings, then into channel volumes aluNormalize(Position); - switch(OutputFormat) + switch(aluChannelsFromFormat(OutputFormat)) { - case AL_FORMAT_MONO8: - case AL_FORMAT_MONO16: + case 1: drysend[0] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f); //Direct drysend[1] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f); //Direct wetsend[0] = ListenerGain * WetMix * aluSqrt(1.0f); //Room wetsend[1] = ListenerGain * WetMix * aluSqrt(1.0f); //Room break; - case AL_FORMAT_STEREO8: - case AL_FORMAT_STEREO16: + case 2: PanningLR = 0.5f + 0.5f*Position[0]; drysend[0] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f-PanningLR); //L Direct drysend[1] = ConeVolume * ListenerGain * DryMix * aluSqrt( PanningLR); //R Direct wetsend[0] = ListenerGain * WetMix * aluSqrt(1.0f-PanningLR); //L Room wetsend[1] = ListenerGain * WetMix * aluSqrt( PanningLR); //R Room break; - case AL_FORMAT_QUAD8: - case AL_FORMAT_QUAD16: + case 4: /* TODO: Add center/lfe channel in spatial calculations? */ - case AL_FORMAT_51CHN8: - case AL_FORMAT_51CHN16: + case 6: // Apply a scalar so each individual speaker has more weight PanningLR = 0.5f + (0.5f*Position[0]*1.41421356f); PanningLR = __min(1.0f, PanningLR); @@ -324,16 +324,12 @@ open_alsa: return ALC_FALSE; } - switch(device->Format) + switch(aluBytesFromFormat(device->Format)) { - case AL_FORMAT_MONO8: - case AL_FORMAT_STEREO8: - case AL_FORMAT_QUAD8: + case 1: data->format = SND_PCM_FORMAT_U8; break; - case AL_FORMAT_MONO16: - case AL_FORMAT_STEREO16: - case AL_FORMAT_QUAD16: + case 2: data->format = SND_PCM_FORMAT_S16; break; default: diff --git a/Alc/dsound.c b/Alc/dsound.c index a2b036a1..90a422a2 100644 --- a/Alc/dsound.c +++ b/Alc/dsound.c @@ -129,7 +129,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam memset(&OutputType, 0, sizeof(WAVEFORMATEX)); OutputType.wFormatTag = WAVE_FORMAT_PCM; OutputType.nChannels = device->Channels; - OutputType.wBitsPerSample = (((device->Format==AL_FORMAT_MONO16)||(device->Format==AL_FORMAT_STEREO16)||(device->Format==AL_FORMAT_QUAD16))?16:8); + OutputType.wBitsPerSample = aluBytesFromFormat(device->Format) * 8; OutputType.nBlockAlign = OutputType.nChannels*OutputType.wBitsPerSample/8; OutputType.nSamplesPerSec = device->Frequency; OutputType.nAvgBytesPerSec = OutputType.nSamplesPerSec*OutputType.nBlockAlign; @@ -174,17 +174,13 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName return ALC_FALSE; } - switch(device->Format) + switch(aluBytesFromFormat(device->Format)) { - case AL_FORMAT_MONO8: - case AL_FORMAT_STEREO8: - case AL_FORMAT_QUAD8: + case 1: data->silence = 0x80; ossFormat = AFMT_U8; break; - case AL_FORMAT_MONO16: - case AL_FORMAT_STEREO16: - case AL_FORMAT_QUAD16: + case 2: data->silence = 0; ossFormat = AFMT_S16_NE; break; @@ -337,17 +333,13 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName, return ALC_FALSE; } - switch(format) + switch(aluBytesFromFormat(format)) { - case AL_FORMAT_MONO8: - case AL_FORMAT_STEREO8: - case AL_FORMAT_QUAD8: + case 1: data->silence = 0x80; ossFormat = AFMT_U8; break; - case AL_FORMAT_MONO16: - case AL_FORMAT_STEREO16: - case AL_FORMAT_QUAD16: + case 2: data->silence = 0; ossFormat = AFMT_S16_NE; break; |