Re: AudioQueueNewOutput causes gui to lock up
Re: AudioQueueNewOutput causes gui to lock up
- Subject: Re: AudioQueueNewOutput causes gui to lock up
- From: Chris Adamson <email@hidden>
- Date: Tue, 25 Sep 2012 08:39:06 -0400
Just to clarify, the only reason Kevin and I do the CFRunLoop stuff in the "Learning Core Audio" book is to keep a process around that would otherwise terminate by reaching the end of the main() function, which would mean you'd never hear/record any audio because it would all be over and done too quickly.
As Kyle points out, this isn't a concern in a Cocoa app, since the rest of the application architecture will keep the program running (until the user quits, or the program calls exit(), etc.)
If you're writing a Cocoa or Cocoa Touch app, just don't copy over the CFRunLoop stuff.
Honestly, our goal with doing command-line applications instead of AppKit examples was that by not spending any time on an OS X GUI, we figured we'd *only* be showing Core Audio code, and readers wouldn't be confused by irrelevant stuff (someone copy-and-pasting an NSColor into an iOS app, for example). But the little bits where we have to attend to the nature of being a command-line application -- pulling out arguments to main() or looping to avoid termination -- are one place where we end up with that problem anyways.
--Chris
Sent from my iPad
On Sep 24, 2012, at 9:25 PM, Brian Hall <email@hidden> wrote:
> I'm trying to write a cocoa app based on the command line sample
> "CH05_Player" in "Learning Core Audio"
>
> From what I've read in AudioQueueStart(audioQueue, NULL) should get it
> going but nothing happens unless I call CFRunLoopRun(), then the gui
> is unresponsive and the audio plays fine.
>
> CheckError(AudioQueueNewOutput(&dataFormat, // ASBD
> MyAQOutputCallback, // Callback
> &player, // user data
> NULL, // run loop
> NULL, // run loop mode
> 0, // flags (always 0)
> &queue), // output: reference to AudioQueue object
> "AudioQueueNewOutput failed");
>
> The class is just doing audio. I don't understand why it locks up the
> gui. I guess this is a simple problem to do with threads but I'm
> completely lost at the moment. The docs say "If you specify NULL, the
> callback is invoked on one of the audio queue’s internal threads"
> which wouldn't seem to cause this problem.
>
> _______________________________________________
> 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
_______________________________________________
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