output/sles: support floating point samples
According to https://developer.android.com/ndk/guides/audio/opensl/android-extensions This feature was mentioned in https://github.com/MusicPlayerDaemon/MPD/issues/922
This commit is contained in:
parent
64a1386eb6
commit
448b397cb8
2
NEWS
2
NEWS
@ -1,4 +1,6 @@
|
||||
ver 0.21.26 (not yet released)
|
||||
* output
|
||||
- sles: support floating point samples
|
||||
|
||||
ver 0.21.25 (2020/07/06)
|
||||
* protocol:
|
||||
|
@ -173,12 +173,12 @@ SlesOutput::Open(AudioFormat &audio_format)
|
||||
if (audio_format.channels > 2)
|
||||
audio_format.channels = 1;
|
||||
|
||||
SLDataFormat_PCM format_pcm;
|
||||
SLAndroidDataFormat_PCM_EX format_pcm;
|
||||
format_pcm.formatType = SL_DATAFORMAT_PCM;
|
||||
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.sampleRate = audio_format.sample_rate * 1000u;
|
||||
format_pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
|
||||
format_pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16;
|
||||
format_pcm.channelMask = audio_format.channels == 1
|
||||
@ -187,6 +187,7 @@ SlesOutput::Open(AudioFormat &audio_format)
|
||||
format_pcm.endianness = IsLittleEndian()
|
||||
? SL_BYTEORDER_LITTLEENDIAN
|
||||
: SL_BYTEORDER_BIGENDIAN;
|
||||
format_pcm.representation = SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT;
|
||||
|
||||
switch (audio_format.format) {
|
||||
/* note: Android doesn't support
|
||||
@ -201,6 +202,16 @@ SlesOutput::Open(AudioFormat &audio_format)
|
||||
bit */
|
||||
break;
|
||||
|
||||
case SampleFormat::FLOAT:
|
||||
/* Android has an OpenSLES extension for floating
|
||||
point samples:
|
||||
https://developer.android.com/ndk/guides/audio/opensl/android-extensions */
|
||||
format_pcm.formatType = SL_ANDROID_DATAFORMAT_PCM_EX;
|
||||
format_pcm.bitsPerSample = format_pcm.containerSize =
|
||||
SL_PCMSAMPLEFORMAT_FIXED_32;
|
||||
format_pcm.representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* fall back to 16 bit */
|
||||
audio_format.format = SampleFormat::S16;
|
||||
|
Loading…
Reference in New Issue
Block a user