Bug in AudioHardwareServiceRemovePropertyListener? It doesn't seem to have any effect (sample code as separate download)
Bug in AudioHardwareServiceRemovePropertyListener? It doesn't seem to have any effect (sample code as separate download)
- Subject: Bug in AudioHardwareServiceRemovePropertyListener? It doesn't seem to have any effect (sample code as separate download)
- From: Felix Schwarz <email@hidden>
- Date: Mon, 6 Sep 2010 11:32:02 +0200
Hello,
I try to use property listeners in my application running under OS X 10.6.4. This is what I do:
1) I first define a volume change property address (globally so it always has the same address - just to be sure):
static const AudioObjectPropertyAddress sVolumePropertyListener = { kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
2) I define a callback
static OSStatus MyPropertyListener( AudioObjectID inObjectID,
UInt32 inNumberAddresses,
const AudioObjectPropertyAddress inAddresses[],
void *inClientData)
{
NSLog(@"Volume changed - object: %@", (id)inClientData);
return (0); // Should always return zero
}
3) I then add a property listener proc (with retValue being noErr upon return) via
retValue = AudioHardwareServiceAddPropertyListener(audioDeviceID, &sVolumePropertyListener, MyPropertyListener, self);
4) Subsequently I remove it (with retValue being noErr upon return) via
retValue = AudioHardwareServiceRemovePropertyListener(audioDeviceID, &sVolumePropertyListener, MyPropertyListener, self);
5) If I now change the volume of the device, my MyPropertyListener callback is still called. Since I passed an Obj-C object as clientData and use it inside the callback, my application crashes since that object no longer exists.
I've written a tiny sample app showing the issue (it logs everything to the Console via NSLog). You can download the Xcode project at
http://www.wapapp.de/AudioToolboxPropertyListenerIssue.zip
Q: Is there anything I missed - or is AudioHardwareServiceRemovePropertyListener currently not working?
Thanks in advance for any insight you can provide!
Cheers,
Felix
_______________________________________________
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