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.
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;
}