Re: OSX callback, is this OK?
Re: OSX callback, is this OK?
- Subject: Re: OSX callback, is this OK?
- From: Paul Fredlein <email@hidden>
- Date: Wed, 19 Jan 2011 09:03:16 +1000
Hi,
Thanks for the help.
If I use a global variable then I suppose I should use NSNotificationCenter - would that be the way to go?
Regards,
Paul
On 18/01/2011, at 10:11 AM, Brian Willoughby wrote: On Jan 17, 2011, at 15:55, Paul Fredlein wrote: I'm recording to a single buffer as I need to only capture x seconds of audio. I've determined the buffer size by the number of seconds I need to record so when the buffer is full it stops recording. The maximum recording duration varies from 1 second to about 5 seconds maximum.
The file is called audioAppDelegate.m and in my callback I'm using 'self' as the 'inUserData'.
// set record callback AudioQueueNewInput(&asbdRecord, recordCallback, self, NULL, NULL, 0, &queueRecord);
In my callback, I need to stop recording when the single buffer is full.
[(audioAppDelegate*)inUserData performSelectorOnMainThread:@selector(stopRecording:) withObject:nil waitUntilDone:NO];
This works but there must be a better way. Any help appreciated, thanks.
Why not just create a global variable - or, better yet, pass in the address of an instance variable as your inUserData - and set this variable when your recording data has been completely captured. In your App delegate, you can set up a timer to periodically poll this BOOL, and then call the -stopRecording: method when the flag changes. You don't need to set the timer to repeat very fast - in fact, you don't even need a repeating timer. If you do end up looping on the flag, make sure you call sleep() or the equivalent so that you don't end up with a busy wait and spinning cursor.
It's generally best to create standard C mechanisms for communication between the CoreAudio callbacks and the non-time-critical parts of your application.
Brian Willoughby Sound Consulting
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden