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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

2,174件の閲覧回数
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

ラベル(3)
タグ(2)
2 返答(返信)

1,880件の閲覧回数
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 件の賞賛
返信

1,880件の閲覧回数
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.