I have developed a kernel module (Android) which provides me:
PCM
16-bit
48000 Hz
2 channel
and I want to stream it to an Apple’s Airport Express (AEX) in java.
The AEX needs 44.1 kHz PCM so I have to resample the PCM-stream.
I have following possibilities, but which is the best?
1. Use the C-program “raop_play” (part of raop-play)
advantages:
high-performant due to native C
already uses libsamplerate to resample wav, mp3, ogg, flac, aac, pls
openssl as static library
usable via command-line from my java-program via Runtime.exec()
disadvantages:
I am relative new to C
overloaded: I don't need wav, mp3.. only PCM
many dependencies with GPL-libraries which I have to compile for Android
only supports PCM already with 44.1 kHz, no resampling for PCM implemented yet
-> have to implement resampling for PCM
2. Resample & stream in java (with libresample JNI-bridge)
advantages:
I CAN java :)
middle-performant due to resamling in C , but streaming in java
just one dependency to LGPL-library
no Runtime.exec() needed
disadvantages:
needs [bouncycastle][3] for AES which is a bit larger than openssl
less performant than solution #1 (but maybe fast enough)
3. Resample already in kernel module
advantages:
most performant
no resampling at higher level
disadvantages:
I am relative new to C
Is it possible to use libsamplerate or libresample in kernel-space?!
I’m a java-guy in heart, but this task (especially on a cpu constrained device, like a handheld) is crying for C. I would suggest simply using the libsamplerate. It has a simple API, and even if you’re new to C you’ll find plenty of examples by just googling around.
of course the java based solution could and would work, it just doesn’t seem polite to the users to eat up their batteries just because your new to C 🙂
EDIT:
I might contradict myself a bit, but even though performance is a serious issue, I would avoid doing anything in kernel-space, unless I know the kernel and the hardware really well. In light of this I would go with a user-space program linked to libsamplerate. After a bit of googling around I’ve found this example (note that the output is the jack interface, obviously it has to be different for you)
This example seems pretty straightforward, I hope you can use it.