ma_device_notification_proc typedef

The notification callback for when the application should be notified of a change to the device.

This callback is used for notifying the application of changes such as when the device has started, stopped, rerouted or an interruption has occurred. Note that not all backends will post all notification types. For example, some backends will perform automatic stream routing without any kind of notification to the host program which means miniaudio will never know about it and will never be able to fire the rerouted notification. You should keep this in mind when designing your program.

The stopped notification will not get fired when a device is rerouted.

Parameters

pNotification (in) A pointer to a structure containing information about the event. Use the pDevice member of this object to retrieve the relevant device. The type member can be used to discriminate against each of the notification types.

Remarks

Do not restart or uninitialize the device from the callback.

Not all notifications will be triggered by all backends, however the started and stopped events should be reliable for all backends. Some backends do not have a good way to detect device stoppages due to unplugging the device which may result in the stopped callback not getting fired. This has been observed with at least one BSD variant.

The rerouted notification is fired after the reroute has occurred. The stopped notification will not* get fired when a device is rerouted. The following backends are known to do automatic stream rerouting, but do not have a way to be notified of the change:

DirectSound

The interruption notifications are used on mobile platforms for detecting when audio is interrupted due to things like an incoming phone call. Currently this is only implemented on iOS. None of the Android backends will report this notification.

Implementation

typedef ma_device_notification_proc
    = ffi.Pointer<ffi.NativeFunction<ma_device_notification_procFunction>>;