Dmacpro
Dmacpro

Reputation: 491

Iphone thread priorities

My application processes audio in its own thread and uses AudioUnits to play the buffers.

When my app enters the background I start to hear quiet a few glitches from my audio.
Now this isn't the worst part.

Before I enter the background I can scroll through my apps UIScrollView with no issues in my audio thread, but after I return from the background any scrolling causes glitches in my audio.

I've checked my thread priorities using [[NSThread currentThread] threadPriority] before and after the backgrounding and those don't seem to be any different.

What might be the issue?

Upvotes: 0

Views: 538

Answers (2)

Dmacpro
Dmacpro

Reputation: 491

Figured it out. I rebuilt the app under the release setting and everything works and sounds amazing now.

Upvotes: 1

bbum
bbum

Reputation: 162722

What might be the issue?

Most likely, your audio processing is compute intensive and there aren't enough CPU cycles left for the system to both remain responsive to the user's input and allow your computation to run full throttle. The system is attempting to keep the UI responsive and throttling your computation, leading to skips.

The fix is probably going to be to make your computation use less CPU, either by increasing efficiency or doing less work.

Upvotes: 1

Related Questions