e***@gmail.com
2015-03-02 02:25:57 UTC
I saw Glenn Kasten's video in YouTube about android5.0 audio latency
improvement, thatâs an amazing short latency!
Recently, I met an issue like this: Audio latency is very serious at
our device. Use openSLES, thereâs about 200+ms delay.
So I wonder how to gain a low latency audio in Android4.4 ?
----------------------------------------------------------
My idea as below:
There're three buffers: 1. share buffer used by client(AudioTrack) and
server(AudioFlinger); 2. mainBuffer for audio mix; 3. buffer in alsa
driver
So I think low latency can be get by reducing size of these three buffers.
XRUN would happen if buffer size is too small, so there must be a balance
value.
-----------------------------------------------------------
Now my method as below:
1. Set period size and count in HAL;
Output: 256 * 8
InputïŒ256 * 6
2. Set kMinNormalMixBufferSizeMs and kMaxNormalMixBufferSizeMs to 5
and 6 respectively in Threads.cpp;
3. Set minBufCount = 1 in both PlaybackThread::createTrack_l and
RecordThread::createRecordTrack_l;
4. Don't double input buffer in AudioRecord::getMinFrameCount;
-----------------------------------------------------------
My local test result:
Local loopback test: direct HAL read and write.
stream read/write, I open a direct API in AudioFlinger to invoke
PlaybackThread->mOutputSink->write; and
RecordThread->getInputStream()->stream->read.
In theory, HAL read/write should not be longer than pcm read write, I
donât know why it cost 30ms more. Maybe by Vendorâs resample in HAL
and IPC, need more investigation.
57 ~ 60ms delay.
Local loopback test: direct pcm device read and write. DO NOT use
android API, operate on alsa pcm device directly.
20 ~ 30ms delay.
Test method:
Use laptop computer to record sound before enter Mic and out from
speaker, then analysis pcm wave by CoolEditor.
Thank you so much for your help!
Evan.Xu
improvement, thatâs an amazing short latency!
Recently, I met an issue like this: Audio latency is very serious at
our device. Use openSLES, thereâs about 200+ms delay.
So I wonder how to gain a low latency audio in Android4.4 ?
----------------------------------------------------------
My idea as below:
There're three buffers: 1. share buffer used by client(AudioTrack) and
server(AudioFlinger); 2. mainBuffer for audio mix; 3. buffer in alsa
driver
So I think low latency can be get by reducing size of these three buffers.
XRUN would happen if buffer size is too small, so there must be a balance
value.
-----------------------------------------------------------
Now my method as below:
1. Set period size and count in HAL;
Output: 256 * 8
InputïŒ256 * 6
2. Set kMinNormalMixBufferSizeMs and kMaxNormalMixBufferSizeMs to 5
and 6 respectively in Threads.cpp;
3. Set minBufCount = 1 in both PlaybackThread::createTrack_l and
RecordThread::createRecordTrack_l;
4. Don't double input buffer in AudioRecord::getMinFrameCount;
-----------------------------------------------------------
My local test result:
Local loopback test: direct HAL read and write.
stream read/write, I open a direct API in AudioFlinger to invoke
PlaybackThread->mOutputSink->write; and
RecordThread->getInputStream()->stream->read.
In theory, HAL read/write should not be longer than pcm read write, I
donât know why it cost 30ms more. Maybe by Vendorâs resample in HAL
and IPC, need more investigation.
57 ~ 60ms delay.
Local loopback test: direct pcm device read and write. DO NOT use
android API, operate on alsa pcm device directly.
20 ~ 30ms delay.
Test method:
Use laptop computer to record sound before enter Mic and out from
speaker, then analysis pcm wave by CoolEditor.
Thank you so much for your help!
Evan.Xu
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk.
For more options, visit https://groups.google.com/d/optout.