diff options
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/plugins/sles/SlesOutputPlugin.cxx | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/output/plugins/sles/SlesOutputPlugin.cxx b/src/output/plugins/sles/SlesOutputPlugin.cxx index f846b5cfa..85fd9f2f2 100644 --- a/src/output/plugins/sles/SlesOutputPlugin.cxx +++ b/src/output/plugins/sles/SlesOutputPlugin.cxx @@ -188,15 +188,20 @@ SlesOutput::Open(AudioFormat &audio_format, Error &error) N_BUFFERS, }; + if (audio_format.channels > 2) + audio_format.channels = 1; + SLDataFormat_PCM format_pcm; format_pcm.formatType = SL_DATAFORMAT_PCM; - format_pcm.numChannels = 1; + format_pcm.numChannels = audio_format.channels; /* from the Android NDK docs: "Note that the field samplesPerSec is actually in units of milliHz, despite the misleading name." */ format_pcm.samplesPerSec = audio_format.sample_rate * 1000u; format_pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16; format_pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16; - format_pcm.channelMask = SL_SPEAKER_FRONT_CENTER; + format_pcm.channelMask = audio_format.channels == 1 + ? SL_SPEAKER_FRONT_CENTER + : SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT; format_pcm.endianness = IsLittleEndian() ? SL_BYTEORDER_LITTLEENDIAN : SL_BYTEORDER_BIGENDIAN; @@ -312,9 +317,6 @@ SlesOutput::Open(AudioFormat &audio_format, Error &error) // TODO: support other sample formats audio_format.format = SampleFormat::S16; - // TODO: support stereo - audio_format.channels = 1; - return true; } |