/* TEMP FOR COMPATIBILITY: If it's a stopped notification, fire the onStop callback as well. This is only for backwards compatibility and will be removed. */
if (notification.pDevice->onStop != NULL && notification.type == ma_device_notification_type_stopped) {
for (;;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
for (;;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
ma_result startResult;
ma_result startResult;
ma_result stopResult; /* <-- This will store the result from onDeviceStop(). If it returns an error, we don't fire the onStop callback. */
ma_result stopResult; /* <-- This will store the result from onDeviceStop(). If it returns an error, we don't fire the stopped notification callback. */
/* We wait on an event to know when something has requested that the device be started and the main loop entered. */
/* We wait on an event to know when something has requested that the device be started and the main loop entered. */
DEPRECATED. Use ma_device_notification_proc instead.
The callback for when the device has been stopped.
The callback for when the device has been stopped.
This will be called when the device is stopped explicitly with `ma_device_stop()` and also called implicitly when the device is stopped through external forces
This will be called when the device is stopped explicitly with `ma_device_stop()` and also called implicitly when the device is stopped through external forces
...
@@ -2202,7 +2298,7 @@ Remarks
...
@@ -2202,7 +2298,7 @@ Remarks
-------
-------
Do not restart or uninitialize the device from the callback.
Do not restart or uninitialize the device from the callback.
*/
*/
typedefvoid(*ma_stop_proc)(ma_device*pDevice);
typedefvoid(*ma_stop_proc)(ma_device*pDevice);/* DEPRECATED. Use ma_device_notification_proc instead. */
typedefenum
typedefenum
{
{
...
@@ -2381,6 +2477,7 @@ struct ma_device_config
...
@@ -2381,6 +2477,7 @@ struct ma_device_config
ma_bool8noClip;/* When set to true, the contents of the output buffer passed into the data callback will be clipped after returning. Only applies when the playback sample format is f32. */
ma_bool8noClip;/* When set to true, the contents of the output buffer passed into the data callback will be clipped after returning. Only applies when the playback sample format is f32. */
ma_bool8noDisableDenormals;/* Do not disable denormals when firing the data callback. */
ma_bool8noDisableDenormals;/* Do not disable denormals when firing the data callback. */
ma_device_data_procdataCallback;
ma_device_data_procdataCallback;
ma_device_notification_procnotificationCallback;
ma_stop_procstopCallback;
ma_stop_procstopCallback;
void*pUserData;
void*pUserData;
ma_resampler_configresampling;
ma_resampler_configresampling;
...
@@ -2812,6 +2909,7 @@ struct ma_context
...
@@ -2812,6 +2909,7 @@ struct ma_context
ma_procpa_stream_set_write_callback;
ma_procpa_stream_set_write_callback;
ma_procpa_stream_set_read_callback;
ma_procpa_stream_set_read_callback;
ma_procpa_stream_set_suspended_callback;
ma_procpa_stream_set_suspended_callback;
ma_procpa_stream_set_moved_callback;
ma_procpa_stream_is_suspended;
ma_procpa_stream_is_suspended;
ma_procpa_stream_flush;
ma_procpa_stream_flush;
ma_procpa_stream_drain;
ma_procpa_stream_drain;
...
@@ -2827,6 +2925,8 @@ struct ma_context
...
@@ -2827,6 +2925,8 @@ struct ma_context
/*pa_mainloop**/ma_ptrpMainLoop;
/*pa_mainloop**/ma_ptrpMainLoop;
/*pa_context**/ma_ptrpPulseContext;
/*pa_context**/ma_ptrpPulseContext;
char*pApplicationName;/* Set when the context is initialized. Used by devices for their local pa_context objects. */
char*pServerName;/* Set when the context is initialized. Used by devices for their local pa_context objects. */
}pulse;
}pulse;
#endif
#endif
#ifdef MA_SUPPORT_JACK
#ifdef MA_SUPPORT_JACK
...
@@ -3037,21 +3137,22 @@ struct ma_device
...
@@ -3037,21 +3137,22 @@ struct ma_device
ma_device_typetype;
ma_device_typetype;
ma_uint32sampleRate;
ma_uint32sampleRate;
MA_ATOMIC(4,ma_device_state)state;/* The state of the device is variable and can change at any time on any thread. Must be used atomically. */
MA_ATOMIC(4,ma_device_state)state;/* The state of the device is variable and can change at any time on any thread. Must be used atomically. */
ma_device_data_proconData;/* Set once at initialization time and should not be changed after. */
ma_device_data_proconData;/* Set once at initialization time and should not be changed after. */
ma_stop_proconStop;/* Set once at initialization time and should not be changed after. */
ma_device_notification_proconNotification;/* Set once at initialization time and should not be changed after. */
void*pUserData;/* Application defined data. */
ma_stop_proconStop;/* DEPRECATED. Use the notification callback instead. Set once at initialization time and should not be changed after. */
void*pUserData;/* Application defined data. */
ma_mutexstartStopLock;
ma_mutexstartStopLock;
ma_eventwakeupEvent;
ma_eventwakeupEvent;
ma_eventstartEvent;
ma_eventstartEvent;
ma_eventstopEvent;
ma_eventstopEvent;
ma_threadthread;
ma_threadthread;
ma_resultworkResult;/* This is set by the worker thread after it's finished doing a job. */
ma_resultworkResult;/* This is set by the worker thread after it's finished doing a job. */
ma_bool8isOwnerOfContext;/* When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). */
ma_bool8isOwnerOfContext;/* When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). */
ma_bool8noPreSilencedOutputBuffer;
ma_bool8noPreSilencedOutputBuffer;
ma_bool8noClip;
ma_bool8noClip;
ma_bool8noDisableDenormals;
ma_bool8noDisableDenormals;
MA_ATOMIC(4,float)masterVolumeFactor;/* Linear 0..1. Can be read and written simultaneously by different threads. Must be used atomically. */
MA_ATOMIC(4,float)masterVolumeFactor;/* Linear 0..1. Can be read and written simultaneously by different threads. Must be used atomically. */
ma_duplex_rbduplexRB;/* Intermediary buffer for duplex device on asynchronous backends. */
ma_duplex_rbduplexRB;/* Intermediary buffer for duplex device on asynchronous backends. */
struct
struct
{
{
ma_resample_algorithmalgorithm;
ma_resample_algorithmalgorithm;
...
@@ -3180,6 +3281,8 @@ struct ma_device
...
@@ -3180,6 +3281,8 @@ struct ma_device
#ifdef MA_SUPPORT_PULSEAUDIO
#ifdef MA_SUPPORT_PULSEAUDIO
struct
struct
{
{
/*pa_mainloop**/ma_ptrpMainLoop;
/*pa_context**/ma_ptrpPulseContext;
/*pa_stream**/ma_ptrpStreamPlayback;
/*pa_stream**/ma_ptrpStreamPlayback;
/*pa_stream**/ma_ptrpStreamCapture;
/*pa_stream**/ma_ptrpStreamCapture;
}pulse;
}pulse;
...
@@ -3212,7 +3315,7 @@ struct ma_device
...
@@ -3212,7 +3315,7 @@ struct ma_device
ma_bool32isDefaultCaptureDevice;
ma_bool32isDefaultCaptureDevice;
ma_bool32isSwitchingPlaybackDevice;/* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
ma_bool32isSwitchingPlaybackDevice;/* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
ma_bool32isSwitchingCaptureDevice;/* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
ma_bool32isSwitchingCaptureDevice;/* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
void*pRouteChangeHandler;/* Only used on mobile platforms. Obj-C object for handling route changes. */
void*pNotificationHandler;/* Only used on mobile platforms. Obj-C object for handling route changes. */
}coreaudio;
}coreaudio;
#endif
#endif
#ifdef MA_SUPPORT_SNDIO
#ifdef MA_SUPPORT_SNDIO
...
@@ -3928,9 +4031,8 @@ then be set directly on the structure. Below are the members of the `ma_device_c
...
@@ -3928,9 +4031,8 @@ then be set directly on the structure. Below are the members of the `ma_device_c
dataCallback
dataCallback
The callback to fire whenever data is ready to be delivered to or from the device.
The callback to fire whenever data is ready to be delivered to or from the device.
stopCallback
notificationCallback
The callback to fire whenever the device has stopped, either explicitly via `ma_device_stop()`, or implicitly due to things like the device being
The callback to fire when something has changed with the device, such as whether or not it has been started or stopped.
disconnected.
pUserData
pUserData
The user data pointer to use with the device. You can access this directly from the device object like `device.pUserData`.
The user data pointer to use with the device. You can access this directly from the device object like `device.pUserData`.