I have a question about the oalTouch example project.

Specifically the sample code uses the exit( ) function after encountering an 
error such as in the sample code below.  

I looked up the OpenAL documentation for alGetError( ) and no where does the 
OpenAL documentation for alGetError( ) mention that an error returned is 
considered fatal and the program must exit.

So what I am wondering is if this is simply a "lazy" example from Apple 
(without any "nice" UI warning errors), and should not actually affect the 
performance of the app.  Obviously if there is an error loading the sound 
resource, the sound cannot play.  

But I am asking this here anyways in the case that there is actually an issue 
where exit( ) is required.



------------------------------------------------ Excerpt from oalTouch sample 
project
- (void) initBuffer
{
   ALenum  error = AL_NO_ERROR;
   ALenum  format;
   ALsizei size;
   ALsizei freq;

   NSBundle*               bundle = [NSBundle mainBundle];

   // get some audio data from a wave file
   CFURLRef fileURL = (CFURLRef)[[NSURL fileURLWithPath:[bundle 
pathForResource:@"sound" ofType:@"caf"]] retain];

   if (fileURL)
   {   
       data = MyGetOpenALAudioData(fileURL, &size, &format, &freq);
       CFRelease(fileURL);

       if((error = alGetError()) != AL_NO_ERROR) {
           NSLog(@"error loading sound: %x\n", error);
           exit(1);
       }

       // use the static buffer data API
       alBufferDataStaticProc(buffer, format, data, size, freq);

       if((error = alGetError()) != AL_NO_ERROR) {
           NSLog(@"error attaching audio to buffer: %x\n", error);
       }       
   }
   else
       NSLog(@"Could not find file!\n");
}_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to