3
votes

I'm working on custom board running Android 4.2.1. I have almost all things working except of proper audio routing.

I have an audio codec there (WM8960 connected in I2S bus) and it works well servicing speakers, built-in microphone, headphones and headphones-mic. The HAL is implemented through tinyAlsa in audio_hw.c like usual and works perfectly in whole system.

There is also second audio device (actually a USB sound card) with GSM modem audio connected. It is detected by ALSA without problems and I can use it on kernel level using aplay/arecord.

Now I need to set proper routing when an audio call is established -- that means that I have to play the sound from microphone to second audio device and vice versa. Can please someone give me an advice or example how to handle this using tinyAlsa API?

regards Jan

1
Write a program to capture audio data from one device and play it to the other device. How is this ALSA or Android specific?CL.
I have not problem with alsa (arecord ... | aplay ...) works. But I'm not sure how to add it into existing Android framework, to be able to use that from top level Android applications.Honza
This is going to be very expensive to process at the user level. I would try to match pcm parameters and then use splice() or something similar to at least avoid all the context switching. Some hardware (IMX) has an audmux module and via hardware you can route the signals directly without CPU intervention. Then you just need to make a widget that toggles the routes appropriately. Good luck with feedback; software cann't fix that easily, so your mic/speaker physics better be good.artless noise
Thanks, we will probably fix it by hardware redesign.Honza

1 Answers

1
votes

I think you can solve this problem in Audio HAL.

Assuming second audio device you meant is second audio card

When a call usecase is detected, change the playback sound card to the second audio card.

i.e if Card0 - WM8960; Card1 - USB sound card

change card number in pcm_open API

pcm_open(0, ..) change to pcm_open(1, ..)

you might also need to set corresponding mixer commands before invoking pcm_open.