That's good and bad news... good because it's how I want it to work, and bad because it isn't working in my code. I built a very simple program that just installed a listener, then fprintfed a message when the callback was triggered. That worked fine. Then in my actual, much more complicated and multithreaded application I do the same thing, fprintf's and all, only with multiple calls of the registration with different inClientData values, and the callback never once gets called. The registration code below will not necessarily be called in the main thread, but in my testing case, it always it.
register: AudioObjectPropertyAddress prop; prop.mSelector = kAudioHardwarePropertyDevices; prop.mScope = kAudioObjectPropertyScopeGlobal; prop.mElement = kAudioObjectPropertyElementMaster; err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &prop, &audioOutDevListChangedProc, this);
err is zero when I break on the last line, every time through.
The callback is very simple at the moment:
OSStatus audioOutDevListChangedProc(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress inAddresses[], void*inClientData) { fprintf(stdout, "Device List changed.\n"); return noErr; }
Is there something obvious I am missing? Why no error returned when I register? The same code, with a more complicated and useful callback function, worked fine under OS 10.5/PPC, but not under 10.6/Intel... no compiler warnings (in this area of the code) either.
Thanks, Ethan... On Mar 5, 2010, at 3:22 PM, Jeff Moore wrote: Part of the reason for the creation of AudioObjectAddPropertyListener/AudioObjectRemovePropertyListener was to allow the same function to be registered as a listener multiple times provided that the client data argument is different each time. This obviates the need for things like CATink, for example. On Mar 5, 2010, at 12:55 PM, Ethan Funk wrote: If I call AudioObjectAddPropertyListener multiple time with the same inProc values but different inClientData values what happens? Will by listener proc get called multiple times with each of the various inClientData values passes when the requested listening event occurs, or just once with the last inClientValue passed?
|