• 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
Re: OSX callback, is this OK?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OSX callback, is this OK?


  • Subject: Re: OSX callback, is this OK?
  • From: Brian Willoughby <email@hidden>
  • Date: Mon, 17 Jan 2011 16:11:15 -0800


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

  • Follow-Ups:
    • Re: OSX callback, is this OK?
      • From: Paul Fredlein <email@hidden>
References: 
 >OSX callback, is this OK? (From: Paul Fredlein <email@hidden>)

  • Prev by Date: OSX callback, is this OK?
  • Next by Date: Re: What sort of timer should I use for my sequencer?
  • Previous by thread: OSX callback, is this OK?
  • Next by thread: Re: OSX callback, is this OK?
  • Index(es):
    • Date
    • Thread