5

I'm writing a small call recording library for my rooted phone.
I saw in some application that recording is done through ALSA or CAF on rooted phones.
I couldn't find any example / tutorial on how to use ALSA or CAF for call recording (or even for audio recording for that matter).
I saw tinyAlsa lib project, but I couldn't figure how to use it in an android app. Can someone please show me some tutorial or code example on how to integrate ALSA or CAF in an Android application?

Update I managed to wrap tinyAlsa with JNI calls. However, calls like mixer_open(0) returns null pointers, and calls like pcm_open(...) returns a pointer but subsequent call to is_pcm_ready(pcm) always returns false.
Am I doing something wrong? Am I missing something?

Oren
  • 937
  • 1
  • 10
  • 34
  • _"recording is done through ALSA or CAF on rooted phones"_. For what purpose? Why not use Android's regular audio recording APIs (`MediaRecorder` or `AudioRecord`)? – Michael Jan 20 '15 at 12:57
  • Both for academic purposes (gain more knowledge) and for practical ones - using standard api call recording is poor on my device (nexus 5), which apparently doesn't support standard api – Oren Jan 20 '15 at 13:03
  • I would like to add that I looking for a way to record direct system audio, whether it is ALSA / CAF or anything else is less important – Oren Jan 25 '15 at 09:29

1 Answers1

0
  • Here's how to build ALSA lib using the Android's toolchain.
  • and here you can find another repo mentioning ALSA for android

I suggest you to read this post on order to understand what are your choices and the current platform situation.

EDIT after comments:

I think that you need to implement your solution with tinyalsa assuming by you are using the base ALSA implementation. If the tiny version is missing something then you may need to ask the author (but it sounds strange to me, because you are doing basic operations). After reading this post, we can get some clues about why root is needed (accessing protected mount points).

Keep us updated with your progress, it's an interesting topic!

Community
  • 1
  • 1
bonnyz
  • 13,458
  • 5
  • 46
  • 70
  • Thanks for the details. I am actually focusing on tinyalsa / tinyalsa-ndk libs, and what I am missing is how to use the generated libtinyalsa.so in order to port it to my android app (besides native calls) in order to record audio - and specifically, record calls. I know the basic flow - pcm-open, loop pcm-read and pcm-close. what I'm trying to understand are for example how to retrieve valid cards and devices instead of the default 0,0, and also - as I plan to use it on a rooted phone - where in the flow is the root necessary. thanks for the help – Oren Jan 28 '15 at 18:51
  • Thanks for the references, I'm still trying to figure how to use tinyAlsa from java code to record native audio (with focus on call recording) – Oren Feb 01 '15 at 17:09
  • I managed to wrap tinyAlsa with JNI calls. However, calls like mixer_open(0) returns null pointers, and calls like pcm_open(...) returns a pointer but subsequent call to is_pcm_ready(pcm) always returns false. Am I doing something wrong? Am I missing something? – Oren Feb 01 '15 at 19:56
  • Looking for the same , but have not fond anything helpful , are you done with this ? – user2028 Jan 20 '17 at 10:57
  • @Oren I want to record calls while mic is muted. For example in an incoming call I just want to record caller's sound while the mic is muted. As you familiar with tinyalsa, Do you think it's possible to use tinyalsa for implementing this? – Fahime Ghasemi Aug 02 '22 at 10:53