3

I'm discovering Android >4.0 at the moment and have some questions I cannot figure out by myself, maybe you can help me.

I found out, that some market-apps, like "AlsaMixer" or "MixGet with ALSA", put a library called "libaudio.so" into "/system/lib/" (with user-assistance).

I wondered what's happening and after searching a while, it seems that every Android-company can create a libaudio.so which implemented a certain C++-interface and put it into that path.

Android then takes this library for audio-handling (there exist implementations for ALSA, TinyALSA and others)?

But: On my phone is no such libaudio.so - how does this work? What is taken otherwise? I found out that I have a "libasound.so" in that directory, is that the default?

If I would try to implement my own libaudio.so (with my little knowledge at the moment), can I reference the "default"-library in it?

I think "hey, there exists a working audio-implementation on every phone in the world and I just want to extend it and not re-engineer (re-configure) the wheel?"

I mean:

AudioFlinger -> my custom libaudio.so -> default-library (libasound.so?) -> speakers

And what if there is already a libaudio.so on my phone?

I would be really thankful about every helpful answer. Maybe someone has an address for me, understandable for a beginner?

Thanks in advance & kind regards!

Martin L.
  • 3,006
  • 6
  • 36
  • 60
  • 1
    Sorry! You would have to roll your own ROM to take advantage of the custom library as the entire Android system uses call-backs and interacts with the audio library internally in the context of AudioFlinger that is... – t0mm13b Jan 21 '13 at 20:49
  • But, how's e.g. that "AlsaMixer" from the market working which installs /system/lib/libaudio.so and a alsa-config-file on my phone (and works permanently and without a reboot!)? I have a rooted device - if that matters, let's assume I would like to create a library for rooted devices. Because of that AlsaMixer-app, I'm sure there must be a way without a custom ROM. – Martin L. Jan 21 '13 at 21:14
  • For that [AlsaMixer](https://play.google.com/store/apps/details?id=com.skvalex.alsamixer&hl=en) to work, it says it **ROOT & BUSYBOX REQUIRED.** in uppercase! That's how it was able to do it! Meaning handset has to be rooted. Just noticed on the play store, its only on limited devices (btw what is your device?), some have alsa compiled into it (notably CM) and probably exploits that.... – t0mm13b Jan 21 '13 at 21:18
  • Oh, yes my phone is a Galaxy Nexus. I've already asked the author why it requires "BusyBox" (it's just a toolbox?) but got now answer yet. Rooting was clear to me because it needs to put that library into the system-path. Ok, let's assume I will try to find a way to stream outgoing audio to remote-speakers (the Apple Airplay in my kitchen), but I will share my work with others, so not just do it for my phone. I've already accepted the problem that it will require a rooted phone - no problem for me. What do I have for opportunities? I'm sure, there is a way (searching for almost 1 year) :) – Martin L. Jan 21 '13 at 21:28
  • Busybox is a shell alternative replacement for the user-space tools in the embedded world (can also be used on desktop) such as `busybox rm -rf...` or `busybox cp -R ...` its more adaptable than the standard userspace tools that is available on Android. – t0mm13b Jan 21 '13 at 21:31
  • Yes, that's what I thought, means BusyBox could be avoided. If I now understand (you) the right way, it IS possible to implement and use a libaudio.so at runtime (oh, I read something about it: http://www.kandroid.org/online-pdk/guide/audio.html). Sure, I could "use" that libaudio.so from AlsaMixer (means the users of my app must also install that app and BusyBox), but that's not what I wanted *Ugh*! :) I don't need that full ALSA, just a simple point in the audio-route where I could put my anchor on. – Martin L. Jan 21 '13 at 21:43

1 Answers1

1

I now found a good & understandable graphic with great descriptions, how e.g. the audio is routed through an Android:

Android Services Black Magic - Marakana (Page 10+11)

But also many thanks to t0mm13b who prevented me from going the wrong way with libaudio.so.

Martin L.
  • 3,006
  • 6
  • 36
  • 60