aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-03-01 23:05:44 +0100
committerMax Kellermann <max@duempel.org>2014-03-01 23:05:44 +0100
commitb059ba69d68afac4010ed0a2a629da3339f99678 (patch)
tree232b16f49b29e246afc259a170312dfca86c87a1
parent36ca57a54ebcbdfb2fa4374378280867a089bb91 (diff)
downloadmpd-b059ba69d68afac4010ed0a2a629da3339f99678.tar.gz
mpd-b059ba69d68afac4010ed0a2a629da3339f99678.tar.xz
mpd-b059ba69d68afac4010ed0a2a629da3339f99678.zip
output/sles: support stereo
-rw-r--r--src/output/plugins/sles/SlesOutputPlugin.cxx12
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;
}