About FMOD system threads

We are making a rhythm game for Android, and as you may know, the latency issues are real on Android.
We did everything we could to reduce the latency and it seemed great until we faced random audio popping issues.
We think it’s caused by multiple factors, but hard to narrow down because it happens very randomly.

For example, the game works great without any problem in the morning for hours, but it’s impossible to play due to severe random hiccups and noises, and even sudden pauses (like when GC is triggered) from the beginning at night before bed.
And noises suddenly get very subtle and happen very rarely when I start to analyze them.
(I personally think this has something to do with the system’s background job. The system may be given most of the CPU power for such as updating and backing up when it thinks their user wouldn’t touch the device as much.)

Anyway, we thought one of causing factors was Thread Priority.
We gave all our threads high priorities, we assumed these were disturbing FMOD’s threads.
We tried lowering the priorities, but as said earlier, it’s so random that we don’t know if it’s helping or not.
We didn’t want to keep them low without any strong reason, so we googled and found this page.

It’s about FMOD Ex, which is the older API, and it doesn’t even include Android-related info.
But anyway, we had a look at them and found FMOD threads use higher priorities than normal.
But if I’m not wrong, Android doesn’t have thread-priority-related functions like sched_setattr() and pthread_setschedprio() yet.
Also, it only allows us to set SCHED_OTHER and all others are prohibited.
That means setting niceness using setpriority() or nice() is user-level apps’ only way to control thread priorities.

Here are my questions:

  1. What are the niceness values of FMOD threads on Android?
  2. Do you think it’s a bad idea to use higher (or equal) niceness for our main logic and user interaction threads than FMOD’s? (Our niceness: -18, -17, -12, -10)

You can see the mappings of FMOD priority to nice levels for Android in our docs here.

You can see the mappings of FMOD threads to FMOD priority here.

Android threading isn’t an exact science so I’d be wary of how you apply your nice levels. Be especially careful about interrupting the FMOD feeder and mixer threads, delays for them will cause stuttering.

1 Like

Wow, thank you very much!