Hi folks,
I'm a little confused about how to safely shut down a
running device and remove my IOProc. I currently have code that looks
like this:
OSStatus status = AudioDeviceStop (my_device,
MyIOProc); while (status == noErr)
{
UInt32 device_running = 0; UInt32
nbytes = sizeof (device_running);
status = AudioDeviceGetProperty (my_device, 0,
true,
kAudioDevicePropertyDeviceIsRunning, &nbytes,
&device_running); if (status
!= noErr || !device_running)
{ status =
AudioDeviceGetProperty (my_device, 0,
false,
kAudioDevicePropertyDeviceIsRunning, &nbytes,
&device_running);
if (status != noErr ||
!device_running)
break;
} SleepForMilliseconds
(50); // rare, if
ever } status = AudioDeviceRemoveIOProc
(my_device, MyIOProc);
This seems to work fine on all my test machines, but I
have one or two reports from the field of crashes that look like
this:
Thread 12
Crashed: 0
???
0x031c3070 0 + 52179056 1
com.apple.audio.CoreAudio 0x983005b4
HP_IOProc::Call(AudioTimeStamp const&, AudioTimeStamp const&,
AudioBufferList const*, AudioTimeStamp const&, AudioBufferList*) +
374 2
com.apple.audio.CoreAudio 0x9830031a
IOA_Device::CallIOProcs(AudioTimeStamp const&, AudioTimeStamp const&,
AudioTimeStamp const&) + 370 3
com.apple.audio.CoreAudio 0x98300116
HP_IOThread::PerformIO(AudioTimeStamp const&, double) +
620 4
com.apple.audio.CoreAudio 0x982fd4fa
HP_IOThread::WorkLoop() + 2506 5
com.apple.audio.CoreAudio 0x982fcb2b
HP_IOThread::ThreadEntry(HP_IOThread*) + 17 6
com.apple.audio.CoreAudio 0x982fca42
CAPThread::Entry(CAPThread*) + 140 7
libSystem.B.dylib
0x98442fbd _pthread_start + 345 8
libSystem.B.dylib
0x98442e42 thread_start + 34
In once case (on a customer's machine to which I have no
access) I am told that this is 100% reproducible when shutting down the
device. He has a Griffin iMic, Snow Leopard 10.6.2 and a
quad core MacPro, but I have tested with an iMic on my 2009 dual core MacBook
and it works fine.
So, what am I doing wrong?
Many thanks,
Paul Sanders.
|