Hi all,
Although this question may sound like more of an OpenAL/ObjectAL, the issue I am having is with the ExtAudioFile API. Here is the problem:
My app downloads small audio files from my server and stores them in the NSTemporaryDirectory(). Then I use ObjectAL (which is an OpenAL wrapper library by Karl Stenerud) to place audio in a 3D space. This library uses the ExtAudioFile API to open and read audio files, etc. The problem is that it appears ExtAudioFileOpenURL() does not allow any files to be read OTHER than local files included in the [NSBundle mainBundle]. Is this in fact true? I can successfully open/play audio files with .mp3, .aif, and .caf formats, as long as the file is included in the -mainBundle.
If that is in fact the case, is there a way to successfully open an audio file using ExtAudioFileOpenURL() that is residing in the NSTemporaryDirectory() (or any other iOS file directories)? The following gives an overview of relevant code:
- (void)setSourceWithSourceURL:(NSString *)urlString type:(CueType)cueType volume:(ALfloat)vol isMono:(BOOL)mono isSFX:(BOOL)isSFX {
ALSource *source = [self sourceForKey:cueType];
ALBuffer *buffer = [self bufferForKey:cueType];
if (!source) {
source = [[ALSource source] retain];
}
if (!buffer) {
NSArray *array = [urlString componentsSeparatedByString:@"/"];
NSURL *furl = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:array.lastObject]];
buffer = [[[OpenALManager sharedInstance] bufferFromUrl:furl reduceToMono:mono] retain];
}
// fails when setting buffer...
}
The NSLog output for furl before making the -bufferFromUrl call is:
file:///private/var/mobile/Applications/08E20AF6-6333-4E24-9F12-20C6D6381C0B/tmp/4_right_turn_cue.aif
I verified that the file does in fact exist...
The -bufferFromUrl: reduceToMono: call essentially calls an internal ObjectAL -init method:
- (id) initWithUrl:(NSURL*) urlIn reduceToMono:(bool) reduceToMonoIn {
if(nil != (self = [super init])) {
url = "">
reduceToMono = reduceToMonoIn;
OSStatus error = 0;
UInt32 size;
if(nil == url)
{
OAL_LOG_ERROR(@"Cannot open NULL file / url");
goto done;
}
// Open the file
if(noErr != (error = ExtAudioFileOpenURL((as_bridge CFURLRef)url, &fileHandle)))
{
REPORT_EXTAUDIO_CALL(error, @"Could not open url %@", url);
goto done;
}
// ...more stuff but opening the URL fails
Once ExtAudioFileOpenURL() is called, I get the following error message:
OAL Error: -[OALAudioFile initWithUrl:reduceToMono:]: Could not open url file:///private/var/mobile/Applications/08E20AF6-6333-4E24-9F12-20C6D6381C0B/tmp/4_right_turn_cue.aif (error code 0x7768743f: Unknown ext audio error)
Any insights as to why this is failing to read an audio file from a file directory? Any ideas or workarounds? Any help is greatly appreciated!
--
Mark Anderson
-----------------------------------------------------------
\-----------------------------------------------------------------------
\-------------------------------------------------------------------------