Re: Exit( ) necessary? (oalTouch sample project)
Re: Exit( ) necessary? (oalTouch sample project)
- Subject: Re: Exit( ) necessary? (oalTouch sample project)
- From: Luke the Hiesterman <email@hidden>
- Date: Thu, 27 May 2010 14:40:49 -0700
That is most likely there for simplicity of the code example. Since Touch is in the name, I'm assuming this example is for iPhoneOS? If so, please remember that exit() should never be called in an iPhone program. Only the user should exit your program.
Luke
On May 27, 2010, at 2:37 PM, Philip Mobley wrote:
> 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
_______________________________________________
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