alsa recording

1,042 views
Skip to first unread message

Scott Sibley

unread,
Jan 31, 2012, 10:10:14 PM1/31/12
to andro...@googlegroups.com
Hello. I have a working implementation that samples audio input via the tinyalsa API through NDK. However, it appears permissions for /dev/snd/* aren't consistent across devices, and the directory doesn't seem to exist at all on an emulator.

I've looked into AudioRecorder through Java, but it only deals with microphone and phone call audio. I'm interesting in microphone audio, but only secondarily to media audio, so this route isn't viable.

Is there a way to use tinyalsa consistently across various devices and emulators? Is there another approach to accessing raw PCM data?

Thanks.

Scott

Glenn Kasten

unread,
Feb 1, 2012, 12:43:22 AM2/1/12
to android-ndk
This is far off-topic for NDK, but I'll give a brief answer here and
suggest android-porting for follow-up and further discussion of low-
level audio and tinyalsa.

Android low-level audio is handled by AudioFlinger service within
mediaserver process. AudioFlinger does not assume ALSA drivers.
Instead it accesses the audio drivers via a user-mode hardware
abstraction library called the "audio HAL". So not all Android devices
have ALSA device nodes. Even when there is ALSA present, mediaserver
owns the audio devices, so what you're describing would likely require
stopping mediaserver.

mic _

unread,
Feb 1, 2012, 2:06:43 AM2/1/12
to andro...@googlegroups.com
You want to record what's being played back on the phone? As Glenn mentioned that would probably require modifying AudioFlinger or AudioHardware (i.e. a custom Android version, which isn't something you can do with the NDK). The AudioFlinger takes all the decoded (PCM) AudioTracks belonging to each output thread, applies effects, mixes them together, and writes them to the corresponding output stream in AudioHardware. Actually, on some platforms it might not always be PCM; it could be e.g. an AC3/DTS bistream going to the HDMI output, but that's a special case.

If you take an Android phone released before the last quarter of 2011 my guess is that a fairly low percentage of those have ALSA drivers. It's starting to get more common though. 

/Michael

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Paul Kalebu

unread,
Jul 10, 2018, 9:23:27 PM7/10/18
to android-ndk
How did you go about routing the audio through tinymix? I'm trying to do the same thing but can't find any reliable documentation out there.

Glenn Kasten

unread,
Jul 11, 2018, 8:26:36 PM7/11/18
to android-ndk
tinyalsa is not an NDK API, so this android-ndk group might not be the best place.
But tinyalsa is sometimes discussed on android-porting. Here is one recent post:

Paul Kalebu

unread,
Jul 11, 2018, 8:50:11 PM7/11/18
to andro...@googlegroups.com
Thanks, I'll take a look!

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.

To post to this group, send email to andro...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages