Hi guys,
As we know, android audio passthrough latency is not good, many devices 
have 150ms-250ms total latency. 
This is unacceptable on realtime applications. And I heard Fastmixer in JB 
didn't get dramatically improvement on it.
So, I tried some ways on ICS to make audio flinger more stable and less 
latency.

1. I changed the audioflinger mixer thread's scheduler class to SCHED_RR. 
The old scheduler class is SCHED_OTHER. Although, audioflinger's mixer got 
the lowset nice value and highest priority, the CFS scheduler can't promise 
it getting enough resource at any critial time. In my opinion, the realtime 
scheduler is helpful for a stable audio renderer. Howerver, I'm not sure is 
this conflicted with the design idea of audioflinger or android arch, any 
comments?

2. The total audio latency is decided by driver buffer size plus cblk 
buffer size(IPC buffer for audiotrack and audioflinger). For alsa driver, 
at least 4 periods were needed for DMA writing,
and 10 milliseconds period was accepted by most devices as I tested. Cblk 
buffer size equals to (driver buffer size)*2, I think it is too large, and 
changed it to the same value as driver buffer allocated(JB brought 
Non-block mode, I'm not sure clbk buffer size could be ingored or not in JB 
Non-block mode).
So the total latency would be (10 * 4 + 40) = 80 milliseconds. If your 
system is reliable in 5 milliseconds level interpret, 40 milliseconds 
latency reachs. For most devcies, 10 millisecods * 6 is recommended, and 
total is 120 ms, big buffer is helpful in busy system case. 

3. Setting different buffer size for different applications. HD movie 
playback gets heavy cpu load and latency is neglectable, big buffer size is 
welcomed. And in MIDI Player, small buffer size brings much better 
experience.I heard some vendors already configed differnet buffer for 
special usage. The side effect is restarting your audio device, since many 
cases don't support buffer size tuning dynamically.

Any way, these steps were not good enough, if you tried this before, please 
reply this thread. Any comments or ideas will be welcomed.

Thanks!
Charlie

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting

Reply via email to