Remarks
Callback delegate invoked each time an event generated by CoreAudio devices occurs: this callback can be set through a call to the CallbackForCoreAudioEventsSet method.
This delegate is only intended for usage with Windows Vista and later versions: further information about management of audio devices in Windows Vista and later versions can be found inside the How to access settings of audio devices in Windows Vista and later versions tutorial.
For further details about callback delegates see the How to synchronize the container application with the API tutorial.
Syntax
[Visual Basic]
Public Delegate Sub CallbackForCoreAudioEvents (
ByVal nEvent as enumCoreAudioEvents,
ByVal nData1 as Int32,
ByVal nData2 as Int32,
ByVal nData3 as Int32
)
|
|
[C#]
public delegate void CallbackForCoreAudioEvents (
enumCoreAudioEvents nEvent,
Int32 nData1,
Int32 nData2,
Int32 nData3
)
|
|
[C++]
public delegate void CallbackForCoreAudioEvents (
enumCoreAudioEvents nEvent,
Int32 nData1,
Int32 nData2,
Int32 nData3
)
|
|
Parameter
|
Description
|
|
|
nEvent
|
Event reported by the CoreAudio device.
Supported values are the following:
Mnemonic constant
|
Value
|
Meaning with data parameters
|
EV_COREAUDIO_DEVICE_STATE_CHANGED
|
0
|
Occurs when the state of an audio endpoint device changes. The current status of an audio endpoint device could be also queried using the CoreAudioDevices.StatusGet method..
Involved data parameters:
nData1: Zero-based index of the audio endpoint device which generated the event. The total number of audio endpoint devices can be obtained through the CoreAudioDevices.CountGet method.
When this parameter is set to -1 the application is notified about the fact that the status of one of the audio endpoint devices not previously enumerated through the call to the CoreAudioDevices.Enum method (for example a disabled device which become active and ready) has now changed its status so it could be worth calling again the CoreAudioDevices.Enum method in order to update the list of available audio endpoint devices.
nData2: Direction in which audio data flows between an audio endpoint device and an application. Supported values are the following:
Mnemonic Value
|
Value
|
Meaning
|
DEVICE_DATA_FLOW_RENDER
|
0
|
Audio rendering stream. Audio data flows from the application to the audio endpoint device, which renders the stream
|
DEVICE_DATA_FLOW_CAPTURE
|
1
|
Audio capture stream. Audio data flows from the audio endpoint device that captures the stream, to the application.
|
nData3: New status assumed by the audio endpoint device. The returned value can be a combination of the following flags:
Mnemonic Value
|
Value
|
Meaning
|
DEVICE_STATE_ACTIVE
|
1
|
The device is active
|
DEVICE_STATE_DISABLED
|
2
|
The device is disabled
|
DEVICE_STATE_NOTPRESENT
|
4
|
The device is not present: the audio endpoint device is considered "not present" when the audio adapter has been installed and configured inside the system but it was physically removed at a later time: quite typical situation with devices connected through USB.
|
DEVICE_STATE_UNPLUGGED
|
8
|
The device is unplugged: the audio endpoint device is considered "unplugged" when the audio adapter that contains the jack for the endpoint device is present and enabled, but the endpoint device is not plugged into the jack
|
|
EV_COREAUDIO_DEVICE_ADDED
|
1
|
Occurs when a new audio endpoint device is added to the system. After catching this event you can get the updated list of available audio endpoint devices by calling again the CoreAudioDevices.Enum method.
Involved data parameters: none.
|
EV_COREAUDIO_DEVICE_REMOVED
|
2
|
Occurs when a new audio endpoint device is removed from the system. After catching this event you can get the updated list of available audio endpoint devices by calling again the CoreAudioDevices.Enum method.
Involved data parameters: none.
|
EV_COREAUDIO_DEVICE_DEFAULT_CHANGE
|
3
|
Occurs when the system defined default audio endpoint device changes. The current system default device can be also queried using the CoreAudioDevices.DefaultGet method..
By design this event is only sent to the first instance of the component.
Involved data parameters:
nData1: Zero-based index of the audio endpoint which is now the system default for the role set into the nRole parameter. The total number of audio endpoint devices can be obtained through the CoreAudioDevices.CountGet method.
This parameter may be set to -1 in case the device should have been unplugged from the system when the previous enumeration occurred, for example because an USB device was installed but not plugged in.
nData2: Direction in which audio data flows between an audio endpoint device and an application. Supported values are the following:
Mnemonic Value
|
Value
|
Meaning
|
DEVICE_DATA_FLOW_RENDER
|
0
|
Audio rendering stream. Audio data flows from the application to the audio endpoint device, which renders the stream
|
DEVICE_DATA_FLOW_CAPTURE
|
1
|
Audio capture stream. Audio data flows from the audio endpoint device that captures the stream, to the application.
|
nData3: The role that the system has assigned to the audio endpoint device that became the new system default. Supported values are the following:
Mnemonic Value
|
Value
|
Meaning
|
DEVICE_ROLE_CONSOLE
|
0
|
Games, system notification sounds, and voice commands
|
DEVICE_ROLE_MULTIMEDIA
|
1
|
Music, movies, narration, and live music recording
|
DEVICE_ROLE_COMMUNICATIONS
|
2
|
Voice communications
|
|
EV_COREAUDIO_DEVICE_VOLUME_CHANGE
|
4
|
Occurs when the volume level of an audio endpoint device changes. After receiving this event you can query current volume through the CoreAudioDevices.ChannelVolumeGet and CoreAudioDevices.MasterVolumeGet methods.
Involved data parameters:
nData1: Zero-based index of the audio endpoint device which generated the event. The total number of audio endpoint devices can be obtained through the CoreAudioDevices.CountGet method.
nData2: Direction in which audio data flows between an audio endpoint device and an application. Supported values are the following:
Mnemonic Value
|
Value
|
Meaning
|
DEVICE_DATA_FLOW_RENDER
|
0
|
Audio rendering stream. Audio data flows from the application to the audio endpoint device, which renders the stream
|
DEVICE_DATA_FLOW_CAPTURE
|
1
|
Audio capture stream. Audio data flows from the audio endpoint device that captures the stream, to the application.
|
|
EV_COREAUDIO_DEVICE_VUMETER_CHANGE
|
5
|
Occurs when the VU-Meter level of an audio endpoint device changes. After receiving this event you can query current peak values through the CoreAudioDevices.VuMeterMasterPeakValueGet and CoreAudioDevices.VuMeterChannelPeakValueGet methods.
Involved data parameters:
nData1: Zero-based index of the audio endpoint device which generated the event. The total number of audio endpoint devices can be obtained through the CoreAudioDevices.CountGet method.
nData2: Direction in which audio data flows between an audio endpoint device and an application. Supported values are the following:
Mnemonic Value
|
Value
|
Meaning
|
DEVICE_DATA_FLOW_RENDER
|
0
|
Audio rendering stream. Audio data flows from the application to the audio endpoint device, which renders the stream
|
DEVICE_DATA_FLOW_CAPTURE
|
1
|
Audio capture stream. Audio data flows from the audio endpoint device that captures the stream, to the application.
|
|
|
nData1
|
First 32 bits integer value containing event specific data; its value and meaning depends upon the specific event received: see the table above for possible values.
|
nData2
|
Second 32 bits integer value containing event specific data; its value and meaning depends upon the specific event received: see the table above for possible values.
|
nData3
|
Third 32 bits integer value containing event specific data; its value and meaning depends upon the specific event received: see the table above for possible values.
|