• 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
Bug in AudioHardwareServiceRemovePropertyListener? It doesn't seem to have any effect (sample code as separate download)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Bug in AudioHardwareServiceRemovePropertyListener? It doesn't seem to have any effect (sample code as separate download)
      • From: Jeff Moore <email@hidden>
  • Prev by Date: Re: resetting session category behaviour under 3.x and 4.0 - solved
  • Next by Date: AudioQueue sample time
  • Previous by thread: Re: resetting session category behaviour under 3.x and 4.0 - solved
  • Next by thread: Re: Bug in AudioHardwareServiceRemovePropertyListener? It doesn't seem to have any effect (sample code as separate download)
  • Index(es):
    • Date
    • Thread