• 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
How to safely remove an IOProc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to safely remove an IOProc


  • Subject: How to safely remove an IOProc
  • From: "Paul Sanders" <email@hidden>
  • Date: Sun, 7 Feb 2010 19:41:24 -0000

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.
 
 _______________________________________________
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: How to safely remove an IOProc
      • From: Jeff Moore <email@hidden>
  • Prev by Date: Re: OT: USB multichannel was: Outputting multichannel sound through the optical link??
  • Next by Date: Re: How to safely remove an IOProc
  • Previous by thread: Re: Sidechains in 32 bit AU running in 64 bit Logic 9.1 Bit Bridge
  • Next by thread: Re: How to safely remove an IOProc
  • Index(es):
    • Date
    • Thread