• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Exit( ) necessary? (oalTouch sample project)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exit( ) necessary? (oalTouch sample project)


  • Subject: Exit( ) necessary? (oalTouch sample project)
  • From: Philip Mobley <email@hidden>
  • Date: Thu, 27 May 2010 14:37:19 -0700

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Exit( ) necessary? (oalTouch sample project)
      • From: Luke the Hiesterman <email@hidden>
  • Prev by Date: Re: removeObjectAtArrangedObjectIndexPath EXC_BAD_ACCESS
  • Next by Date: Re: Exit( ) necessary? (oalTouch sample project)
  • Previous by thread: Re: removeObjectAtArrangedObjectIndexPath EXC_BAD_ACCESS
  • Next by thread: Re: Exit( ) necessary? (oalTouch sample project)
  • Index(es):
    • Date
    • Thread