Vincent Zgueb
Vincent Zgueb

Reputation: 1491

Unable to fully teardown AVAudioPlayer

On iOS after using AVAudioPlayer to play a sound I observe that a thread continues to run and consume around 3% CPU. It seems related to the HAL stuff (Hardware Abstraction Layer). How to achieve a full cleanup and get my app idle ? It is referenced in a local var and properly deallocated after the play is ended. I've noticed that If I just instantiate the AVAudioPlayer but never call the play method, that thread is not created. And the app is idle. Any ideas?

Notice: I deprecate this question since I've realised that this issue is only on Simulator. Found the explanation here http://lists.apple.com/archives/coreaudio-api/2006/Jul/msg00022.html

Upvotes: 0

Views: 358

Answers (2)

S. Chand
S. Chand

Reputation: 209

Try below code and set your audio player object to nil.

NSError *error;
[[AVAudioSession sharedInstance] setActive:NO withFlags:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&error];

Upvotes: 0

Bersaelor
Bersaelor

Reputation: 2577

How is the exact name of the object which is using 3% cpu?

Have you tried running the App in instruments?

Instruments Usage Manual

Especially check for leaks and where they are created.

Upvotes: 1

Related Questions