• 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: Property listener not working in 10.7
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Property listener not working in 10.7


  • Subject: Re: Property listener not working in 10.7
  • From: Bill Preder <email@hidden>
  • Date: Tue, 07 Feb 2012 12:53:16 -0800

Thanks for the quick response. I modified the code to get the streams and add the listeners to the stream(s).  Working well so far.  Updated code below.

Bill Preder
BIAS, Inc.

// dummy listener callback
OSStatus MyDevicePropertyListenerProc(AudioObjectID                      inObjectID,
                                      UInt32                             inNumberAddresses,
                                      const AudioObjectPropertyAddress   inAddresses[],
                                      void *                             inClientData )
{
    printf("MyDevicePropertyListenerProc() called\n");
    return noErr;
}

// code that adds the listener
OSStatus AddListenerToDefaultInputDevice()
{
    OSStatus result;
    AudioDeviceID deviceID;
    UInt32 propSize = sizeof(AudioDeviceID);

    AudioObjectPropertyAddress propAddr;
    propAddr.mSelector = kAudioHardwarePropertyDefaultInputDevice;
    propAddr.mScope    = kAudioDevicePropertyScopeInput;
    propAddr.mElement  = kAudioObjectPropertyElementMaster;
    
    // get the default input device's ID
    result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &propAddr, 0, NULL, &propSize, &deviceID );
    
    if (result == noErr)
    {
     // get the streams associated with the device
        AudioStreamID *streams = (AudioStreamID*)malloc(propSize);
        if (streams)
        {
            result = AudioObjectGetPropertyData( deviceID, &propAddr, 0, NULL, &propSize, streams );
            if (result == noErr)
            {
// add a property listener for kAudioStreamPropertyPhysicalFormat to each stream
                UInt32 numStreams = propSize / sizeof(AudioStreamID);
                for (UInt32 i = 0; i < numStreams && result == noErr; i++)
                {
                    propAddr.mSelector = kAudioStreamPropertyPhysicalFormat;
                    propAddr.mScope = kAudioObjectPropertyScopeGlobal;
                    result = AudioObjectAddPropertyListener(streams[i], &propAddr, MyDevicePropertyListenerProc, NULL);
                }
            }
            free(streams);
        }
    }
    return result;
}


 _______________________________________________
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

References: 
 >Property listener not working in 10.7 (From: Bill Preder <email@hidden>)
 >Re: Property listener not working in 10.7 (From: Dave Fernandes <email@hidden>)

  • Prev by Date: Re: AU Plugin automation problem
  • Next by Date: Re: AU Plugin automation problem
  • Previous by thread: Re: Property listener not working in 10.7
  • Next by thread: AU Plugin automation problem
  • Index(es):
    • Date
    • Thread