AudioFileOpenURL returns -43 on an existing file

不想你离开。 提交于 2019-12-11 10:14:58

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/2355911/audiofileopenurl-returns-43-on-an-existing-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!