views:

196

answers:

1

I have a step in my application where a user repeatedly hears three spoken digits.

If I leave this step running for a while (for certain undefined values of "while"), my debug logs show this (irrelevant log entries removed):

2010-03-01 13:44:21.283 iPhoneHearChk[1236:207] AudioFileOpenURL returned 0
 (for <file://localhost/var/mobile/Applications/3A28F975-EAD5-4A5B-AFE6-FA1C6EE95732/iPhoneHearChk.app/5b3.ima4>)
2010-03-01 13:44:35.493 iPhoneHearChk[1236:207] AudioFileOpenURL returned 0
 (for <file://localhost/var/mobile/Applications/3A28F975-EAD5-4A5B-AFE6-FA1C6EE95732/iPhoneHearChk.app/5b3.ima4>)
2010-03-01 13:45:17.916 iPhoneHearChk[1236:207] AudioFileOpenURL returned 0
 (for <file://localhost/var/mobile/Applications/3A28F975-EAD5-4A5B-AFE6-FA1C6EE95732/iPhoneHearChk.app/5b3.ima4>)
2010-03-01 13:47:00.408 iPhoneHearChk[1236:207] AudioFileOpenURL returned -43
 (for <file://localhost/var/mobile/Applications/3A28F975-EAD5-4A5B-AFE6-FA1C6EE95732/iPhoneHearChk.app/5b3.ima4>)

From what I've read, MacErrors.h defines -43 as fnErr, File Not Found. But clearly the file does exist, because I've successfully opened it before. What gives?

How I open the file:

NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: name ofType: type];
if (!soundFilePath) { NSLog(@"No path found for sound file %@.%@", name, type); }
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
rc = AudioFileOpenURL((CFURLRef) fileURL, kAudioFileReadPermission, 0, &file);

where file is an AudioFileID instvar and name and type are NSString * parameters.

+2  A: 

Is it possible that you are running out of file handles? Do you close the files you open after you are finished with them?

Kristopher Johnson
I had checked, but I will recheck. Certainly the call to AudioFileClose() is in the dealloc method, but I will check that the necessary object is indeed being released.
Frank Shearar
Indeed, an object holding an NSMutableArray holding the objects opening the files released the array, but not the items IN the array. Thus, none of the objects called AudioFileClose(). Thanks!
Frank Shearar