You will receive many events to your callback, so filtering on the name/scope/element arguments is vital. For example, on a stereo device, it is not uncommon to receive a
volm event for each audio channel when the volume changes, or multiple
mute events for channels. Dragging a volume slider in the system Sound preferences will produce a large number of
volm events. Plugging/unplugging headphones may trigger
volm events in addition to
jack ones, etc.