Question

The following code:

ExtAudioFileRef *file = nil;
NSURL *path = [[NSBundle mainBundle] URLForResource:@"beep" withExtension:@"wav"];
OSErr errorCode = ExtAudioFileOpenURL((__bridge CFURLRef)path, file);

leaves file null and errorCode is -50 ("error in user parameter list"). If file is not initialized to nil, like so:

ExtAudioFileRef *file;

I get a EXC_BAD_ACCESS (code=2, address={garbage value of file}).

How am I supposed to do this? I know the path is correct, because it works for playing the sound elsewhere in the application.

Was it helpful?

Solution

Check with this:

ExtAudioFileRef file = NULL;
NSURL *path = [[NSBundle mainBundle] URLForResource:@"beep" withExtension:@"wav"];
OSErr errorCode = ExtAudioFileOpenURL((__bridge CFURLRef)path, &file);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top