Originally posted by spykes
View Post
20 ms is pretty freakin' fantastic. You aren't going to get much better than 20 ms. Even if the DSP is SoC, you need some kind of non-zero buffer for software mixing, and PA software mixes *everything* (whereas AudioFlinger usually does NOT have the software mixer on, for performance/CPU reasons).
I think the minimum latency the hardware is capable of on a complete idle system is something like 6 ms from the time the audio is pushed by the decoder to the time you hear it in your headphones (assuming there is negligible latency in the output hardware, which is the case for analog out). That PA is able to achieve 20 ms -- only slightly more than three times longer than the core pipeline -- is pretty awesome.
Also keep in mind that PA in time-based scheduling mode will produce as much latency as the applications will let it get away with, basically. For a music player, a latency of 2 seconds saves a LOT of CPU time, because the CPU can go into deep sleep states between buffer pushes, then wake up, push a huge buffer, and go to sleep again. And if you decode into RAM before starting playback you can save even more, because you can just do a zero-copy map from the decoded PCM buffer into PA's streaming output DMA buffer.
But for DAW-like programs on a phone (which sounds crazy in the first place but whatever), tsched can tune the latency lower (and increase power consumption accordingly) if the app requests it. But 15 - 20 ms is about as low as you can get, and if you start to multi-task at all you'll get clicks and pops on a single-core CPU (or maybe even a dual-core CPU if you're doing heavy 3d compositing while multi-tasking).
I still think I'd rather have a pipeline that introduces a very small amount of latency but is as flexible and power-saving as PA, over a pipeline that has zero added latency but doesn't have the features or power savings of PA. It's hard to have both (indeed the maintainers of JACK2 recognized that you can't really have both, by recognizing the separate usefulness of PA and JACK.)
Leave a comment: