我在我的应用程序中有一个步骤,用户反复听到三个语音数字。
如果我让这一步运行一段时间(对于某些未定义的“while”值),我的调试日志显示了这一点(删除了无关的日志条目):
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>)
根据我的阅读,MacErrors.h将-43定义为fnErr,File Not Found。但显然文件确实存在,因为我之前已成功打开它。是什么给了什么?
我如何打开文件:
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);
其中file是AudioFileID instvar,名称和类型是NSString * parameters。
答案 0 :(得分:3)
你的文件句柄可能用完吗?完成后打开的文件是否关闭?