Browse Source

libpulseaudio: support float and 24-bit packed output in sles sink

android-5
Tom Yan 6 years ago
committed by Fredrik Fornwall
parent
commit
6d523df764
  1. 2
      packages/libpulseaudio/build.sh
  2. 21
      packages/libpulseaudio/module-sles-sink.c

2
packages/libpulseaudio/build.sh

@ -1,7 +1,7 @@
TERMUX_PKG_HOMEPAGE=https://www.freedesktop.org/wiki/Software/PulseAudio TERMUX_PKG_HOMEPAGE=https://www.freedesktop.org/wiki/Software/PulseAudio
TERMUX_PKG_DESCRIPTION="A featureful, general-purpose sound server - shared libraries" TERMUX_PKG_DESCRIPTION="A featureful, general-purpose sound server - shared libraries"
TERMUX_PKG_VERSION=12.2 TERMUX_PKG_VERSION=12.2
TERMUX_PKG_REVISION=8 TERMUX_PKG_REVISION=9
TERMUX_PKG_SHA256=809668ffc296043779c984f53461c2b3987a45b7a25eb2f0a1d11d9f23ba4055 TERMUX_PKG_SHA256=809668ffc296043779c984f53461c2b3987a45b7a25eb2f0a1d11d9f23ba4055
TERMUX_PKG_SRCURL=https://www.freedesktop.org/software/pulseaudio/releases/pulseaudio-${TERMUX_PKG_VERSION}.tar.xz TERMUX_PKG_SRCURL=https://www.freedesktop.org/software/pulseaudio/releases/pulseaudio-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_DEPENDS="libltdl, libsndfile, libandroid-glob, libsoxr" TERMUX_PKG_DEPENDS="libltdl, libsndfile, libandroid-glob, libsoxr"

21
packages/libpulseaudio/module-sles-sink.c

@ -42,6 +42,7 @@
#include <pulsecore/rtpoll.h> #include <pulsecore/rtpoll.h>
#include <SLES/OpenSLES.h> #include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
PA_MODULE_AUTHOR("Lennart Poettering, Nathan Martynov"); PA_MODULE_AUTHOR("Lennart Poettering, Nathan Martynov");
PA_MODULE_DESCRIPTION("Android OpenSL ES sink"); PA_MODULE_DESCRIPTION("Android OpenSL ES sink");
@ -125,10 +126,15 @@ static int pa_init_sles_player(struct userdata *u, pa_sample_spec *ss) {
locator_bufferqueue.locatorType = SL_DATALOCATOR_BUFFERQUEUE; locator_bufferqueue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
locator_bufferqueue.numBuffers = 8; locator_bufferqueue.numBuffers = 8;
SLDataFormat_PCM pcm; SLAndroidDataFormat_PCM_EX pcm;
if (ss->format == PA_SAMPLE_FLOAT32LE) {
pcm.formatType = SL_ANDROID_DATAFORMAT_PCM_EX;
pcm.representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT;
} else {
pcm.formatType = SL_DATAFORMAT_PCM; pcm.formatType = SL_DATAFORMAT_PCM;
}
pcm.numChannels = ss->channels; pcm.numChannels = ss->channels;
pcm.samplesPerSec = ss->rate * 1000; pcm.sampleRate = ss->rate * 1000;
pcm.bitsPerSample = pcm.containerSize = pa_sample_size(ss) * 8; pcm.bitsPerSample = pcm.containerSize = pa_sample_size(ss) * 8;
pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT; pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
pcm.endianness = SL_BYTEORDER_LITTLEENDIAN; pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
@ -249,7 +255,16 @@ int pa__init(pa_module*m) {
ss = m->core->default_sample_spec; ss = m->core->default_sample_spec;
pa_channel_map_init_stereo(&map); pa_channel_map_init_stereo(&map);
ss.format = ss.format > PA_SAMPLE_S16BE ? PA_SAMPLE_S32LE : PA_SAMPLE_S16LE; switch (ss.format) {
case PA_SAMPLE_S16LE:
case PA_SAMPLE_S24LE:
case PA_SAMPLE_S32LE:
case PA_SAMPLE_FLOAT32LE:
break;
default:
pa_log("Sample format not supported");
goto fail;
}
pa_modargs_get_sample_rate(ma, &ss.rate); pa_modargs_get_sample_rate(ma, &ss.rate);
ss.channels = map.channels; ss.channels = map.channels;

Loading…
Cancel
Save