How to listen to mic with Adl_Audio

Hi,
I’m trying to listen to the mic audio (raw pcm stream) using the Adl_Audio functions included in the OpenAT 4.20.

Using the following code I’ve correctly(?) subscribed to Irq and Audio Handler, but I don’t see any activities on trace 2 and 3…

Any suggestion?

Best regards
Pietro

Follows code extract:

s32 s_handle; // audio resource handle
static s32 s_IRQHandle; // irq handle
static void *s_StreamBuffer; // audio stream buffer

// Low level interruption handler
bool vocLowLevelIRQHandler(adl_irqID_e a_Source, adl_irqNotificationLevel_e a_NotificationLevel, adl_irqEventData_t *a_pData )
{
    adl_audioStreamDataBuffer_u *pStream = s_StreamBuffer;
	
    TRACE((2, "PCM received : %d, %d ", pStream->PCMData[0], pStream->PCMData[1]));
      
	return TRUE;
}

// audio event call-back function
void vocAudioEventHandler ( s32 audioHandle, adl_audioEvents_e Event )
{
    TRACE((3, "vocAudioEventHandler"));
}
  
void vocSubscribe(void)
{  
    s32     Ret;
    s32     BufferSize;
  
    // Subscribe to IRQ
    s_IRQHandle = adl_irqSubscribe ( vocLowLevelIRQHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, ADL_IRQ_PRIORITY_HIGH_LEVEL, ADL_IRQ_OPTION_AUTO_READ );
    
    TRACE((1, "s_IRQHandle = 0x%08X\r\n", s_IRQHandle));
      
    // Subscribe to the current microphone
    s_handle = adl_audioSubscribe ( ADL_AUDIO_MICROPHONE, vocAudioEventHandler , ADL_AUDIO_RESOURCE_OPTION_FORBID_PREEMPTION );
  
    TRACE((1, "s_handle = 0x%08X\r\n", s_handle));
      
    // Memory allocation
    Ret = adl_audioGetOption ( s_handle, ADL_AUDIO_PCM_8K_16B_MONO_BUFFER_SIZE, &BufferSize );

    TRACE((1, "BufferSize = %d\r\n", BufferSize));
      
    s_StreamBuffer = adl_memGet( BufferSize );   // release memory after audio stream listening
      
    TRACE((1, "s_StreamBuffer = 0x%08X\r\n", (u32)s_StreamBuffer));
      
    // Listen to audio PCM stream
    Ret = adl_audioStreamListen(s_handle, ADL_AUDIO_PCM_MONO_8K_16B, s_IRQHandle, 0, s_StreamBuffer);

    TRACE((1, "Ret = %d\r\n", Ret));
 }

Hi,

I don’t know, if the code is correct…

What is the error you get? I believe for LowLevel Interruption stuff you need a separately paid feature to be enabled. Are you sure this is enabled in the module?

Best Regards,
Jan

Hi jan,
thanks for the reply.

I don’t get any error, I simply don’t see any activities in the Irq handler (where I supposed to receive a PCM stream).

I’ve already enabled the “Real Time Operating System” with the AT+WCFM command with no problem and Traces from the subscription procedures have good values:

s_IRQHandle = 403529832
s_handle = 403530056
BufferSize = 320
Ret = 0

BTW I recall the subscription function after receiveing WIND:4 signaling (just to be sure phone is all setup).

Best regards
Pietro

Just to add a couple of info:

  • Mic is not powered after the adl_audio subscription (power to the mic is on only during call).

  • a Note in the documentation make me ring a bell: “DTMF tone listening on the microphone is reserved for a future use.” May be that this is why I can’t see the PCM stream from the mic?

Best regards
Pietro