AudioDeviceStart after device stop notification
AudioDeviceStart after device stop notification
- Subject: AudioDeviceStart after device stop notification
- From: Vincent Predoehl <email@hidden>
- Date: Mon, 25 Jun 2001 14:36:57 -0400
Hello, I have added property listeners to my application to listen for
the kAudioDevicePropertyDeviceIsRunning property. After receiving
notification that the device has stopped. My application can almost
immediately turn around and ask it to start playing the next phrase.
I still get the kAudioHardwareIllegalOperationError when I do this, even
though the listener has been fired with the property change. If I enter
a loop and poll the value of kAudioDevicePropertyDeviceIsRunning, and
exit the loop after it returns false, everything works fine. I would
much use the listeners, but I can't get them to work.
I am using this thread function for the run loop. I suspect I may be
doing something wrong here. Can anyone help me get this to work?
Thanks.
void* DoThread(void *argToThreadFunct)
{
CFRunLoopRef loop = CFRunLoopGetCurrent();
// tell the HAL to use this run loop
UInt32 theSize = sizeof(CFRunLoopRef);
OSStatus err =
AudioHardwareSetProperty(kAudioHardwarePropertyRunLoop, theSize, &loop);
if(err) { cerr << "C++ Exception in " <<
__FILE__ << ", Line " << __LINE__ << endl; throw err; }
// loop until we're done
while(true)
{
CFRunLoopRunInMode(kCFRunLoopDefaultMode, timeout,
false);
pthread_testcancel(); // create a cancellation
point, so the thread can be stopped
}
return 0;
}
--
Vincent