# Restart Q64 when trying to play the AMR data

**URL:** <https://forum.sierrawireless.com/t/restart-q64-when-trying-to-play-the-amr-data/6067>\
**Category:** Legacy AirPrime modules\
**Created:** [January 15, 2013, 12:27pm UTC](https://forum.sierrawireless.com/t/restart-q64-when-trying-to-play-the-amr-data/6067 "2013-01-15T12:27:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ru3dmg](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@ru3dmg](https://forum.sierrawireless.com/u/ru3dmg)\
**Post date:** [January 15, 2013, 12:27pm UTC](https://forum.sierrawireless.com/t/restart-q64-when-trying-to-play-the-amr-data/6067/1 "2013-01-15T12:27:10Z")

</div>

Hello.

I am using Q64 module, Open AT OS version : 6.37.0, Firmware Version: 7.47.0.  
i have tried to modify functions HandleRecordCmd and fnHandlePlayCmd in pcm\_record\_and\_play sample for record and play the AMR data in this way:

```auto
....
[b]static void HandleRecordCmd ( u8 Source )[/b]
{
    ....
    RetVal = adl_audioSetOption ( RecordResourceHandle,
    		ADL_AUDIO_AMR_MIXED_VOICE, FALSE );
    RetVal = adl_audioSetOption ( RecordResourceHandle,
    		ADL_AUDIO_AMR_SPEECH_CODEC_RATE, ADL_AUDIO_AMR_RATE_5_15 );
    BufferSizeListen = 14;
    RetVal = adl_audioSetOption ( RecordResourceHandle,
    		ADL_AUDIO_AMR_BUFFER_SIZE, BufferSizeListen );
    ....
        StreamBufferListen = adl_memGet ( BufferSizeListen );
    ....
        PcmBufDelete ( &ListenPlayBuffer );

        /* Initialize the common buffer */
        if ( PcmBufInit ( &ListenPlayBuffer, (5*50*14) ) == FALSE )
        {
            TRACE ( ( PCM_TRACE_LEVEL,
                      "cbAppRecordCmdHandler: fnPcmBufInit failed" ) );
        }

        /* Start listening */
        RetVal = adl_audioStreamListen ( RecordResourceHandle,
        				ADL_AUDIO_AMR, AppListenLowIrqHandle,
                        AppListenHighIrqHandle, StreamBufferListen );
    ....
}
....
[b]static void fnHandlePlayCmd ( u8 AudioDestination )[/b]
{
    ....
    RetVal = adl_audioSetOption ( PlayResourceHandle,
    		ADL_AUDIO_AMR_MIXED_VOICE, FALSE );
    RetVal = adl_audioSetOption ( PlayResourceHandle,
    		ADL_AUDIO_AMR_SPEECH_CODEC_RATE, ADL_AUDIO_AMR_RATE_5_15 );
    /* Get Buffer size for Play and initialize a buffer */
    BufferSizePlay = 14;
    RetVal = adl_audioSetOption ( PlayResourceHandle,
    		ADL_AUDIO_AMR_BUFFER_SIZE, BufferSizePlay );
    ....
        StreamBufferPlay = adl_memGet ( BufferSizePlay );
    ....
            RetVal = adl_audioStreamPlay ( PlayResourceHandle,
                            ADL_AUDIO_AMR, AppPlayLowIrqHandle,
                            AppPlayHighIrqHandle, StreamBufferPlay );
    ....
}
```

Recording from the microphone is successfully, but when you try to play the recorded data is the restart of the module.  
These are the traces:

```auto
2013/01/15;16:17:38:796;001;ADL;1;cbAppPlayCmdHandler: SPEAKER
2013/01/15;16:17:38:812;002;ADL;1;cbAppPlayCmdHandler: BufferSizePlay: #14
2013/01/15;16:17:39:359;001;HAC;1;ARM Data Abort caught at 0026059E, Current Task 0x1D by CP15 
2013/01/15;16:17:39:375;001;RTK;1;================== RTK STATUS start ================== 
2013/01/15;16:17:39:375;002;RTK;1;================== RTK STATUS end ================== 
2013/01/15;16:17:41:640;006;ADL;1;Binary header at 00260000
2013/01/15;16:17:41:656;001;ADL;1;PCM_RecordAndPlay: Test Application
2013/01/15;16:17:41:656;002;ADL;1;Jan 15 2013
2013/01/15;16:17:41:656;003;ADL;1;15:04:23
```

Help me, please. Where there may be a bug. Or give an example of the code.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Rex\_alex](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@Rex\_alex](https://forum.sierrawireless.com/u/Rex_alex)\
**Post date:** [January 21, 2013, 9:34am UTC](https://forum.sierrawireless.com/t/restart-q64-when-trying-to-play-the-amr-data/6067/2 "2013-01-21T09:34:00Z")

</div>

Hi,

It should be noted that the size of AMR buffer should be equal to the AMR samples that need to be listened and played.

Please do check in your application that the size of buffer is not small.  
Also the buffer size should match with the codec rate.  
According to the selected codec rate, the buffer has to be defined with a multiple of one speech frame size.

Also you can capture the backtraces and see that what could be the cause of reset.

Thanks.

---

<div class="post-metadata">

**Author:** ![ru3dmg](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@ru3dmg](https://forum.sierrawireless.com/u/ru3dmg)\
**Post date:** [January 22, 2013, 6:10am UTC](https://forum.sierrawireless.com/t/restart-q64-when-trying-to-play-the-amr-data/6067/3 "2013-01-22T06:10:08Z")

</div>

What size buffer should be for codec ADL\_AUDIO\_AMR\_RATE\_12\_20?  
Where can be seen a working example of playing AMR?  
Thanks.
