user2677662
user2677662

Reputation: 3

Can I intercept audio on a rooted Android?

I understand it is not possible to redirect the audio output from a pre-existing Android app - say Spotify - to a USB sound card or a file for instance. I believe this may have had something to do with privacy and recording telephone calls.

I do not understand Linux very well but know that it is very flexible and often read about piping the output of one program to the input of another. I also see that in the dev directory of some Androids some “files” with names like “audio”.

My question is - do any of these correspond to the raw audio output and if the tablet/phone was rooted could the stream be intercepted with some Linux magic?

My motivation is to provide a higher quality audio output than the basic speaker / headphone / bluetooth options.

Upvotes: 0

Views: 1150

Answers (1)

Ross Bencina
Ross Bencina

Reputation: 4173

Short answer is yes, you might be able to hack something together. But the audio implementation on a particular handset is completely up to the manufacturer so there is no guarantee. It is unlikely to be as simple as you think. There is no one-line command line magic for it.

Android doesn't use the usual Linux ALSA user space code so you can not generalize from Linux and say "if I can do it in Linux I can do it on rooted Android".

I think that some Android implementations use TinyALSA but this is not a requirement. If this is the case you might be able to recompile TinyALSA with your own intercept logic or interpose your device some other way. Similarly if you are running an Android mod built from source you could modify it to intercept the audio at other levels such as in the Audio Flinger or at the interface to the HAL. This is less practical if you are just using a rooted device since manufacturers often modify system elements with customization that might make it difficult for you to interpose and intercept (just because you don't know what to substitute if the API has been modified).

Much of the info in this answer I gleaned from reading the Andraudio mailing list. You can check the archives to learn more.

Upvotes: 1

Related Questions