diff options
author | Chris Robinson <[email protected]> | 2008-01-01 06:25:00 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2008-01-01 06:25:00 -0800 |
commit | 7ef623c71d092f696f5bd7f7170ba475728ecccf (patch) | |
tree | 116ec286eac7e97f39565f96d8fe3e7176f60950 /Alc/oss.c | |
parent | 733cd120b35d14f36ec82fd87df9b26b35da2da1 (diff) |
Fail if OSS can't set the requested bit depth and channel count
Diffstat (limited to 'Alc/oss.c')
-rw-r--r-- | Alc/oss.c | 47 |
1 files changed, 9 insertions, 38 deletions
@@ -215,49 +215,20 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName } #undef ok - device->Channels = numChannels; device->Frequency = ossSpeed; - device->Format = 0; - if(ossFormat == AFMT_U8) - { - if(device->Channels == 1) - { - device->Format = AL_FORMAT_MONO8; - device->FrameSize = 1; - } - else if(device->Channels == 2) - { - device->Format = AL_FORMAT_STEREO8; - device->FrameSize = 2; - } - else if(device->Channels == 4) - { - device->Format = AL_FORMAT_QUAD8; - device->FrameSize = 4; - } - } - else if(ossFormat == AFMT_S16_NE) + + if((int)device->Channels != numChannels) { - if(device->Channels == 1) - { - device->Format = AL_FORMAT_MONO16; - device->FrameSize = 2; - } - else if(device->Channels == 2) - { - device->Format = AL_FORMAT_STEREO16; - device->FrameSize = 4; - } - else if(device->Channels == 4) - { - device->Format = AL_FORMAT_QUAD16; - device->FrameSize = 8; - } + AL_PRINT("Could not set %d channels, got %d instead\n", device->Channels, numChannels); + close(data->fd); + free(data); + return ALC_FALSE; } - if(!device->Format) + if(!((ossFormat == AFMT_U8 && aluBytesFromFormat(device->Format) == 1) || + (ossFormat == AFMT_S16_NE && aluBytesFromFormat(device->Format) == 2))) { - AL_PRINT("returned unknown format: %#x %d!\n", ossFormat, numChannels); + AL_PRINT("Could not set %d-bit output, got format %#x\n", aluBytesFromFormat(device->Format)*8, ossFormat); close(data->fd); free(data); return ALC_FALSE; |