diff options
author | Chris Robinson <[email protected]> | 2011-06-14 01:48:13 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-06-14 01:48:13 -0700 |
commit | 823f5779e182bf81843c6ed42fa6c15d6f300b41 (patch) | |
tree | 99de456bd6270bf4801e2a5ae96c3c16fac3dd20 /Alc/opensl.c | |
parent | 96a18ba1d50d76ec417c1777e825b8c67cd2e884 (diff) |
Set format_pcm according to the device format
Diffstat (limited to 'Alc/opensl.c')
-rw-r--r-- | Alc/opensl.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/Alc/opensl.c b/Alc/opensl.c index 96fb3a0e..b5fccf36 100644 --- a/Alc/opensl.c +++ b/Alc/opensl.c @@ -105,6 +105,32 @@ typedef struct { static const ALCchar opensl_device[] = "OpenSL"; +static SLuint32 GetChannelMask(enum DevFmtChannels chans) +{ + switch(chans) + { + case DevFmtMono: return SL_SPEAKER_FRONT_CENTER; + case DevFmtStereo: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT; + case DevFmtQuad: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| + SL_SPEAKER_BACK_LEFT|SL_SPEAKER_BACK_RIGHT; + case DevFmtX51: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| + SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| + SL_SPEAKER_BACK_LEFT|SL_SPEAKER_BACK_RIGHT; + case DevFmtX61: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| + SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| + SL_SPEAKER_BACK_CENTER| + SL_SPEAKER_SIDE_LEFT|SL_SPEAKER_SIDE_RIGHT; + case DevFmtX71: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| + SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| + SL_SPEAKER_BACK_LEFT|SL_SPEAKER_BACK_RIGHT| + SL_SPEAKER_SIDE_LEFT|SL_SPEAKER_SIDE_RIGHT; + case DevFmtX51Side: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| + SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| + SL_SPEAKER_SIDE_LEFT|SL_SPEAKER_SIDE_RIGHT; + } + return 0; +} + static const char *res_str(SLresult result) { switch(result) @@ -262,11 +288,11 @@ static ALCboolean opensl_reset_playback(ALCdevice *Device) loc_bufq.numBuffers = Device->NumUpdates; format_pcm.formatType = SL_DATAFORMAT_PCM; - format_pcm.numChannels = 2; - format_pcm.samplesPerSec = SL_SAMPLINGRATE_44_1; - format_pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16; - format_pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16; - format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT; + format_pcm.numChannels = ChannelsFromDevFmt(Device->FmtChans); + format_pcm.samplesPerSec = Device->Frequency * 1000; + format_pcm.bitsPerSample = BytesFromDevFmt(Device->FmtType) * 8; + format_pcm.containerSize = format_pcm.bitsPerSample; + format_pcm.channelMask = GetChannelMask(Device->FmtChans); format_pcm.endianness = SL_BYTEORDER_NATIVE; audioSrc.pLocator = &loc_bufq; |