0

I am developing an Android App which runs a lot of intensive audio tasks using libpd. Libpd's audio thread has the priority Process.THREAD_PRIORITY_URGENT_AUDIO.

The cpu load stays constantly between 20% and 30% on a Samsung Galaxy S3. This seems reasonable for me, however, opening another app while the audio service is running in background with about 30% cpu load causes a lot of dropouts in audio.

Can someone explain this behaviour? I thought the max load on a quadcore phone like the S3 would be 400% (displayed using "top" in the adb shell). Therefore, I do not understand why such a highly priorized Thread as libpd's audio thread does not get enough CPU resources when using only 30% of the CPU.

Any advice would be much appreciated, thank you ;)

janfreymann
  • 61
  • 1
  • 4
  • Use larger buffers - it won't substantially reduce the load, but it will lessen the chance of high loading resulting in dropouts, by making scheduling of the audio calculations less critical. – Chris Stratton May 12 '14 at 19:24

1 Answers1

0

Well I am not 100% sure on how Android's Kernel does its OS Task Assignments however I can tell you that a max CPU load (100% or whatever it may be) isn't something thats really achievable. There are several ways of task scheduling however most recommend you stay to 70-80% of your CPU's max in order to guarantee tasks complete on time.

That doesn't seem to be of a major concern because your only using 30%, but keep in mind that the UI thread needs to run, the normal background apps are running (SMS, BBM, Whatsapp, Facebook, etc) and you have now run another app which may also be intensive. The OS will decide what gets executed when, and though the user priority is considered the OS will always take priority. Your dropouts might come out when the app gets launched, or when someone is hammering on the home or back button. This is just the nature of the beast, smartphones, though getting better, are still relatively low in terms of processing power.

I know this doesn't exactly help you, as I am not sure how to override/increase the priority above the OS tasks (if its even possible), but I do hope it explains why this happens. Kernels are pretty interesting if you ever have time to read up on them.