WillF
WillF

Reputation: 665

AudioServicesCreateSystemSoundID memory leak?

I just started using Instruments and its Leak detection feature. I was monitoring my code and I noticed there is a leak when I call the method:

AudioServicesCreateSystemSoundID

I am basically using the SoundEffect.m file from the Metronome sample code. I am using a soundfile that was originally a .wav and I converted it using Itunes to a aif and renamed it a caf. It plays just fine and it wasn't until I ran Instruments that I realized there was a leak.

The odd thing is that, when I use a different sound file (tick.caf - from Mentronome sample project) - there is no leak. The same issue is described here with no real answer as to why:

http://discussions.apple.com/thread.jspa?messageID=8360344

Anyways, is there any reason why my sound file would cause a leak? Is Audio Toolkit particularly picky about the audio file it is trying to play??

Upvotes: 0

Views: 1662

Answers (2)

user175412
user175412

Reputation:

Use AudioServicesDisposeSystemSoundID to dispose.

Upvotes: 0

rpetrich
rpetrich

Reputation: 32326

I don't see why it would cause a leak, but perhaps there is a bug in AudioServices when playing an aiff file named as caf. Try converting using afconvert to produce a real caf file from your mac:

afconvert -f caff -d ima4 input.mp3 output.caf

Upvotes: 2

Related Questions