Can iMX53 Alsa controller play and record audio at same time?

cancel
Showing results for 
Search instead for 
Did you mean: 

Can iMX53 Alsa controller play and record audio at same time?

342 Views
RafaelThomasGoz
Contributor III

Hi,

we are using Android on imx53 and we need to keep recording audio permanently. And we need sometime to reproduce audio on that same channel. However sometimes when the recording starts just after the player was initialized, we get the player muted.

Is it really possible to be done (play/record at the same time)? And how could I further debug?

We are using ALSA controller with SGTL5000

Labels (3)
Tags (2)
2 Replies

48 Views
gusarambula
NXP TechSupport
NXP TechSupport

Perhaps you may find the ALSA latency test application useful (link below) where a full-duplex test is performed by playing back recorded (captured) data.

http://www.alsa-project.org/main/index.php/Test_latency.c

Please do let us know of your findings!

0 Kudos

48 Views
RafaelThomasGoz
Contributor III

Hi Gusarambula,

actually it looks like it's a alsa HAL issue on Android. Alsa can successfully record and play files at the same time, the problem is that whenever android opens the MediaRecorder or MediaPlayer, it forces alsa to switch the capture/playback device. And it was switching the playback device to another one, like earphone output, and was making the audio to be "muted". Actually it was not muted, just routed to the wrong device.

Opening AOSP/hardware/mx5x/modules/alsa/alsa_imx5x.cpp file I see that it is always setting alsa controls when the routing function is called, even if alsa is currently using the right device:

static status_t s_route(alsa_handle_t *handle, uint32_t devices, int mode)

{

    status_t status = NO_ERROR;

    LOGD("route called for devices %08x in mode %d...", devices, mode);

    // below Always noting to do, so we open device every time.

#if 0

    if (handle->handle && handle->curDev == devices && handle->curMode == mode)

        ; // Nothing to do

    else if (handle->handle && (handle->devices & devices))

        setAlsaControls(handle, devices, mode);

    else {

        LOGE("Why are we routing to a device that isn't supported by this object?!?!?!?!");

        status = s_open(handle, devices, mode);

    }

#else

    /* fix me if I was wrong here to judge the current sound card. In facat, in s_open, it will reconfig the controls */

  setAlsaControls(handle, devices, mode);

  status = s_open(handle, devices, mode);

#endif

    return status;

}

It seems odd since it would save cpu if it reused the devices. This code is not touched by me, it's vanilla from Freescale Android distribution.

Not sure if that's the problem, but changing setAlsaControls to keep Speaker Function always on, I could avoid the issue.