OpenAL and Build Active Architecture Only
Hi folks,
I'm writing an openAL app which works perfectly well...
...unless 'Build Active Architecture Only' is NO, in which case, it can't find the file in the resource folder. :-/
Weird. Anyone else had this case?
I'm writing an openAL app which works perfectly well...
...unless 'Build Active Architecture Only' is NO, in which case, it can't find the file in the resource folder. :-/
Weird. Anyone else had this case?
Code:
- (void)initOpenALSounds
{
bufferStorageArray = [[NSMutableArray alloc] initWithCapacity:16];
soundDictionary = [[NSMutableDictionary alloc] initWithCapacity:16];
[self initOpenAL];
// get the full path of the file
NSString *fileName = [[NSBundle mainBundle] pathForResource: @"sound" ofType: @"caf" inDirectory: @"sound/gui_sounds"];
if(fileName != nil)
{
AudioFileID fileID = [self openAudioFile:fileName]; // first, open the file
UInt32 fileSize = [self audioFileSize:fileID]; // find out how big the actual audio data is
unsigned char * outData = malloc(fileSize); // this is where the audio data will live for the moment
// this where we actually get the bytes from the file and put them into the data buffer
OSStatus result = noErr;
result = AudioFileReadBytes(fileID, false, 0, &fileSize, outData);
if (result != 0)
NSLog(@"cannot load effect: %@",fileName);
NSUInteger bufferID;
// grab a buffer ID from openAL
alGenBuffers(1, &bufferID);
if((alGetError()) != AL_NO_ERROR) {
printf("Error!");
}
// jam the audio data into the new buffer
alBufferData(bufferID,AL_FORMAT_MONO16,outData,fileSize,44100);
if((alGetError()) != AL_NO_ERROR)
{
printf("Error!");
}
[bufferStorageArray addObject:[NSNumber numberWithUnsignedInteger:bufferID]]; // save the buffer so I can release it later
NSUInteger sourceID;
alGenSources(1, &sourceID); // grab a source ID from openAL
alSourcei(sourceID, AL_BUFFER, bufferID); // attach the buffer to the source
alSourcef(sourceID, AL_GAIN, 1.0f); // set some basic source prefs alSourcef(sourceID, AL_PITCH, 1.0f);
//if (loops) alSourcei(sourceID, AL_LOOPING, AL_TRUE);
[soundDictionary setObject:[NSNumber numberWithUnsignedInt:sourceID] forKey:@"neatoSound"]; // store this for future use
// clean up the buffer
if (outData)
{
free(outData);
outData = NULL;
}
}
else
NSLog(@"Can't find resource.");
}Quote:...unless 'Build Active Architecture Only' is NO, in which case, it can't find the file in the resource folder. :-/
Those two things are unrelated. "Finding a file" has nothing to do with the build architecture, so you need to do more investigating. Look in the bundle and see if the file is actually there. Step through the code and figure out what exactly is happening. Maybe there's an error before or after the line you think is the problem that is actually the culprit.
Sorry, I should have been clearer.
In am using two configurations, both identical except for the Build Active Architecture flag (something one can easily check in XCode).
A step-by-step analysis shows that the following line provides a 'nil' result when BAA is set to NO (as in the standard release config):
When BAA is set to 'YES' the line returns the full path name of the required sound.
This strikes me as curious. The file's definitely there (or else BAA being set to 'YES' would have no effect at all) and it's the same project on the same machine. Only that flag appears to be different.
As I said... curious.
In am using two configurations, both identical except for the Build Active Architecture flag (something one can easily check in XCode).
A step-by-step analysis shows that the following line provides a 'nil' result when BAA is set to NO (as in the standard release config):
Code:
NSString *fileName = [[NSBundle mainBundle] pathForResource: @"sound" ofType: @"caf" inDirectory: @"sound/gui_sounds"];When BAA is set to 'YES' the line returns the full path name of the required sound.
This strikes me as curious. The file's definitely there (or else BAA being set to 'YES' would have no effect at all) and it's the same project on the same machine. Only that flag appears to be different.
As I said... curious.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Help With Universal Game Architecture? | Mattonaise | 1 | 2,743 |
Apr 7, 2011 04:06 PM Last Post: Mattonaise |
|
| Core Animation Architecture in Games | Mattonaise | 3 | 4,548 |
Apr 6, 2011 03:56 PM Last Post: Mattonaise |
|
| Checking for architecture? | Bersaelor | 2 | 2,330 |
Sep 20, 2010 11:56 AM Last Post: Rasterman |
|
| How to get number of active touches? | Rasterman | 8 | 5,842 |
Apr 21, 2010 03:56 PM Last Post: longjumper |
|

