This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Speech codec integration with OMAP4

Hi All,

I am trying to integrate OMX compliant speech codecs (package from TI) with Stagefright framework on ICS on OMAP4 on Galaxy Nexus (OMXCodec.cpp as base engine for the codec flow).

Say I am integrating G722 Encoder and want to record MIC data with following params.

format = AUDIO_FORMAT_PCM_16_BIT

sampleRate = 16000

channels = 1 (AUDIO_CHANNEL_IN_MONO)

Here, G722 Encoder expects
i/p buffer = 160 Samples & o/p = 40 bytes (@ 1 i/p buffer per 10ms to maintain 16000 sampling rate)

But AudioSource (frameworks/base/media/libstagefright/AudioSource.cpp) in libStagefright with source as MIC gives out
i/p buffer = 352 samples (@ 1 i/p buffer per 22ms to maintain 16000 sampling rate)

I traced it down to device\samsung\tuna\audio\audio_hw.c::get_input_buffer_size() function. This function returns the minimum buffer size as 352 samples i.e. 704 bytes.
The calculation within this function is dependent on following #define in audio_hw.c

        /* number of base blocks in a short period (low latency) */
        #define SHORT_PERIOD_MULTIPLIER 44 /* 22 ms */


Here, does it mean that the Minimum buffer period is fixed to 22ms and cannot be adjusted to lesser period? 

With all above info, my queries are 

Q1. How can I configure AudioSource (MIC) to deliver audio-buffers of 160samples at 10ms period ?
Without this, the audio-buffer (352samples) fed to G722 encoder mismatches with the requirement of input buffer of 160samples. And if I try to increase buffer sizes in G722 encoder, it produces garbage output, since the binary encoder library would be expecting buffer of 160samples.

Q2. Is there any way we can split AudioSource buffer of 352samples into chunks of 160samples and feed G722 encoder, still fitting in and not disturbing the architecture of Stagefright (OMXCodec.cpp) ?

Any code example will be really helpful.