/* Spinlocks are 32-bit for compatibility reasons. */
typedefma_uint32ma_spinlock;
#ifndef MA_NO_THREADING
/* Thread priorities should be ordered such that the default priority of the worker thread is 0. */
typedefenum
{
ma_thread_priority_idle=-5,
ma_thread_priority_lowest=-4,
ma_thread_priority_low=-3,
ma_thread_priority_normal=-2,
ma_thread_priority_high=-1,
ma_thread_priority_highest=0,
ma_thread_priority_realtime=1,
ma_thread_priority_default=0
}ma_thread_priority;
#if defined(MA_WIN32)
typedefma_handlema_thread;
#endif
#if defined(MA_POSIX)
typedefma_pthread_tma_thread;
#endif
/* Thread priorities should be ordered such that the default priority of the worker thread is 0. */
typedefenum
{
ma_thread_priority_idle=-5,
ma_thread_priority_lowest=-4,
ma_thread_priority_low=-3,
ma_thread_priority_normal=-2,
ma_thread_priority_high=-1,
ma_thread_priority_highest=0,
ma_thread_priority_realtime=1,
ma_thread_priority_default=0
}ma_thread_priority;
#if defined(MA_POSIX)
typedefma_pthread_tma_thread;
#elif defined(MA_WIN32)
typedefma_handlema_thread;
#endif
#if defined(MA_WIN32)
typedefma_handlema_mutex;
#endif
#if defined(MA_POSIX)
typedefma_pthread_mutex_tma_mutex;
#endif
#if defined(MA_POSIX)
typedefma_pthread_mutex_tma_mutex;
#elif defined(MA_WIN32)
typedefma_handlema_mutex;
#endif
#if defined(MA_WIN32)
typedefma_handlema_event;
#endif
#if defined(MA_POSIX)
typedefstruct
{
ma_uint32value;
ma_pthread_mutex_tlock;
ma_pthread_cond_tcond;
}ma_event;
#endif /* MA_POSIX */
#if defined(MA_POSIX)
typedefstruct
{
ma_uint32value;
ma_pthread_mutex_tlock;
ma_pthread_cond_tcond;
}ma_event;
#elif defined(MA_WIN32)
typedefma_handlema_event;
#endif
#if defined(MA_WIN32)
typedefma_handlema_semaphore;
#endif
#if defined(MA_POSIX)
typedefstruct
{
intvalue;
ma_pthread_mutex_tlock;
ma_pthread_cond_tcond;
}ma_semaphore;
#endif /* MA_POSIX */
#if defined(MA_POSIX)
typedefstruct
{
intvalue;
ma_pthread_mutex_tlock;
ma_pthread_cond_tcond;
}ma_semaphore;
#elif defined(MA_WIN32)
typedefma_handlema_semaphore;
#endif
#else
/* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */
#ifndef MA_NO_DEVICE_IO
#error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO";
#endif
/* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */
#ifndef MA_NO_DEVICE_IO
#error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO";
#endif
#endif /* MA_NO_THREADING */
...
...
@@ -627,7 +721,7 @@ Logging
#endif
#endif
#ifndef MA_ATTRIBUTE_FORMAT
#define MA_ATTRIBUTE_FORMAT(fmt,va)
#define MA_ATTRIBUTE_FORMAT(fmt,va)
#endif
#ifndef MA_MAX_LOG_CALLBACKS
...
...
@@ -658,11 +752,6 @@ logLevel (in)
pMessage (in)
The log message.
Remarks
-------
Do not modify the state of the device from inside the callback.
ma_vec3fposition;/* The absolute position of the listener. */
ma_vec3fdirection;/* The direction the listener is facing. The world up vector is config.worldUp. */
ma_vec3fvelocity;
ma_atomic_vec3fposition;/* The absolute position of the listener. */
ma_atomic_vec3fdirection;/* The direction the listener is facing. The world up vector is config.worldUp. */
ma_atomic_vec3fvelocity;
ma_bool32isEnabled;
/* Memory management. */
...
...
@@ -1333,6 +1431,7 @@ typedef struct
floatconeOuterGain;
floatdopplerFactor;/* Set to 0 to disable doppler effect. */
floatdirectionalAttenuationFactor;/* Set to 0 to disable directional attenuation. */
floatminSpatializationChannelGain;/* The minimal scaling factor to apply to channel gains when accounting for the direction of the sound relative to the listener. Must be in the range of 0..1. Smaller values means more aggressive directional panning, larger values means more subtle directional panning. */
ma_uint32gainSmoothTimeInFrames;/* When the gain of a channel changes during spatialization, the transition will be linearly interpolated over this number of frames. */
}ma_spatializer_config;
...
...
@@ -1358,10 +1457,11 @@ typedef struct
floatdopplerFactor;/* Set to 0 to disable doppler effect. */
floatdirectionalAttenuationFactor;/* Set to 0 to disable directional attenuation. */
ma_uint32gainSmoothTimeInFrames;/* When the gain of a channel changes during spatialization, the transition will be linearly interpolated over this number of frames. */
ma_vec3fposition;
ma_vec3fdirection;
ma_vec3fvelocity;/* For doppler effect. */
ma_atomic_vec3fposition;
ma_atomic_vec3fdirection;
ma_atomic_vec3fvelocity;/* For doppler effect. */
floatdopplerPitch;/* Will be updated by ma_spatializer_process_pcm_frames() and can be used by higher level functions to apply a pitch shift for doppler effect. */
floatminSpatializationChannelGain;
ma_gainergainer;/* For smooth gain transitions. */
float*pNewChannelGainsOut;/* An offset of _pHeap. Used by ma_spatializer_process_pcm_frames() to store new channel gains. The number of elements in this array is equal to config.channelsOut. */
...
...
@@ -1375,6 +1475,8 @@ MA_API ma_result ma_spatializer_init_preallocated(const ma_spatializer_config* p
#if !defined(MA_ANDROID) /* ALSA is not supported on Android. */
#if !defined(MA_ANDROID) && !defined(__COSMOPOLITAN__) /* ALSA is not supported on Android. */
#define MA_SUPPORT_ALSA
#endif
#endif
...
...
@@ -2592,6 +2699,9 @@ typedef enum
ma_device_state_stopping=4/* Transitioning from a started state to stopped. */
}ma_device_state;
MA_ATOMIC_SAFE_TYPE_DECL(i32,4,device_state)
#ifdef MA_SUPPORT_WASAPI
/* We need a IMMNotificationClient object for WASAPI. */
typedefstruct
...
...
@@ -2784,7 +2894,7 @@ DEPRECATED. Use ma_device_notification_proc instead.
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
such as being unplugged or an internal error occuring.
such as being unplugged or an internal error occurring.
wchar_twasapi[64];/* WASAPI uses a wchar_t string for identification. */
ma_wchar_win32wasapi[64];/* WASAPI uses a wchar_t string for identification. */
ma_uint8dsound[16];/* DirectSound uses a GUID for identification. */
/*UINT_PTR*/ma_uint32winmm;/* When creating a device, WinMM expects a Win32 UINT_PTR for device identification. In practice it's actually just a UINT. */
charalsa[256];/* ALSA uses a name string for identification. */
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_device_statestate;/* 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_notification_proconNotification;/* Set once at initialization time and should not be changed after. */
ma_stop_proconStop;/* DEPRECATED. Use the notification callback instead. Set once at initialization time and should not be changed after. */
...
...
@@ -3672,7 +3779,7 @@ struct ma_device
ma_bool8noClip;
ma_bool8noDisableDenormals;
ma_bool8noFixedSizedCallback;
MA_ATOMIC(4,float)masterVolumeFactor;/* Linear 0..1. Can be read and written simultaneously by different threads. Must be used atomically. */
ma_atomic_floatmasterVolumeFactor;/* 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. */
struct
{
...
...
@@ -3760,8 +3867,8 @@ struct ma_device
void*pMappedBufferPlayback;
ma_uint32mappedBufferPlaybackCap;
ma_uint32mappedBufferPlaybackLen;
MA_ATOMIC(4,ma_bool32)isStartedCapture;/* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
MA_ATOMIC(4,ma_bool32)isStartedPlayback;/* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
ma_atomic_bool32isStartedCapture;/* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
ma_atomic_bool32isStartedPlayback;/* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
ma_uint32loopbackProcessID;
ma_bool8loopbackProcessExclude;
ma_bool8noAutoConvertSRC;/* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
ma_bool32seekToCursorOnNextRead;/* On the next read we need to seek to the frame cursor. */
MA_ATOMIC(4,ma_result)result;/* Keeps track of a result of decoding. Set to MA_BUSY while the buffer is still loading. Set to MA_SUCCESS when loading is finished successfully. Otherwise set to some other code. */
MA_ATOMIC(4,ma_bool32)isLooping;/* Can be read and written by different threads at the same time. Must be used atomically. */
ma_bool32isConnectorInitialized;/* Used for asynchronous loading to ensure we don't try to initialize the connector multiple times while waiting for the node to fully load. */
ma_atomic_bool32isConnectorInitialized;/* Used for asynchronous loading to ensure we don't try to initialize the connector multiple times while waiting for the node to fully load. */
union
{
ma_decoderdecoder;/* Supply type is ma_resource_manager_data_supply_type_encoded */
...
...
@@ -6522,6 +6656,7 @@ typedef struct
ma_uint32decodedChannels;/* The decoded channel count to use. Set to 0 (default) to use the file's native channel count. */
ma_uint32decodedSampleRate;/* the decoded sample rate to use. Set to 0 (default) to use the file's native sample rate. */
ma_uint32jobThreadCount;/* Set to 0 if you want to self-manage your job threads. Defaults to 1. */
size_tjobThreadStackSize;
ma_uint32jobQueueCapacity;/* The maximum number of jobs that can fit in the queue at a time. Defaults to MA_JOB_TYPE_RESOURCE_MANAGER_QUEUE_CAPACITY. Cannot be zero. */
ma_uint32flags;
ma_vfs*pVFS;/* Can be NULL in which case defaults will be used. */
...
...
@@ -6730,7 +6865,7 @@ struct ma_node_output_bus
ma_uint8channels;/* The number of channels in the audio stream for this bus. */
/* Mutable via multiple threads. Must be used atomically. The weird ordering here is for packing reasons. */
MA_ATOMIC(1,ma_uint8)inputNodeInputBusIndex;/* The index of the input bus on the input. Required for detaching. */
ma_uint8inputNodeInputBusIndex;/* The index of the input bus on the input. Required for detaching. Will only be used within the spinlock so does not need to be atomic. */
MA_ATOMIC(4,ma_uint32)flags;/* Some state flags for tracking the read state of the output buffer. A combination of MA_NODE_OUTPUT_BUS_FLAG_*. */
MA_ATOMIC(4,ma_uint32)refCount;/* Reference count for some thread-safety when detaching. */
MA_ATOMIC(4,ma_bool32)isAttached;/* This is used to prevent iteration of nodes that are in the middle of being detached. Used for thread safety. */
...
...
@@ -6754,7 +6889,7 @@ struct ma_node_input_bus
MA_ATOMIC(4,ma_spinlock)lock;/* Unfortunate lock, but significantly simplifies the implementation. Required for thread-safe attaching and detaching. */
/* Set once at startup. */
ma_uint8channels;/* The number of channels in the audio stream for this bus. */
ma_uint8channels;/* The number of channels in the audio stream for this bus. */
ma_node_graph*pNodeGraph;/* The graph this node belongs to. */
ma_node_graph*pNodeGraph;/* The graph this node belongs to. */
constma_node_vtable*vtable;
float*pCachedData;/* Allocated on the heap. Fixed size. Needs to be stored on the heap because reading from output buses is done in separate function calls. */
ma_uint16cachedDataCapInFramesPerBus;/* The capacity of the input data cache in frames, per bus. */
/* Splitter Node. 1 input, 2 outputs. Used for splitting/copying a stream so it can be as input into two separate output nodes. */
/* Splitter Node. 1 input, many outputs. Used for splitting/copying a stream so it can be as input into two separate output nodes. */
typedefstruct
{
ma_node_confignodeConfig;
...
...
@@ -7137,7 +7272,7 @@ typedef struct
ma_uint32channelsOut;
ma_uint32sampleRate;/* Only used when the type is set to ma_engine_node_type_sound. */
ma_mono_expansion_modemonoExpansionMode;
ma_bool8isPitchDisabled;/* Pitching can be explicitly disable with MA_SOUND_FLAG_NO_PITCH to optimize processing. */
ma_bool8isPitchDisabled;/* Pitching can be explicitly disabled with MA_SOUND_FLAG_NO_PITCH to optimize processing. */
ma_bool8isSpatializationDisabled;/* Spatialization can be explicitly disabled with MA_SOUND_FLAG_NO_SPATIALIZATION. */
ma_uint8pinnedListenerIndex;/* The index of the listener this node should always use for spatialization. If set to MA_LISTENER_INDEX_CLOSEST the engine will use the closest listener. */
constchar*pFilePath;/* Set this to load from the resource manager. */
...
...
@@ -7193,7 +7331,12 @@ typedef struct
ma_uint64loopPointBegInPCMFrames;
ma_uint64loopPointEndInPCMFrames;
ma_bool32isLooping;
ma_fence*pDoneFence;/* Released when the resource manager has finished decoding the entire sound. Not used with streams. */
ma_sound_end_procendCallback;/* Fired when the sound reaches the end. Will be fired from the audio thread. Do not restart, uninitialize or otherwise change the state of the sound from here. Instead fire an event or set a variable to indicate to a different thread to change the start of the sound. Will not be fired in response to a scheduled stop with ma_sound_set_stop_time_*(). */
ma_fence*pDoneFence;/* Deprecated. Use initNotifications instead. Released when the resource manager has finished decoding the entire sound. Not used with streams. */
}ma_sound_config;
MA_APIma_sound_configma_sound_config_init(void);/* Deprecated. Will be removed in version 0.12. Use ma_sound_config_2() instead. */
...
...
@@ -7205,6 +7348,8 @@ struct ma_sound
ma_data_source*pDataSource;
MA_ATOMIC(8,ma_uint64)seekTarget;/* The PCM frame index to seek to in the mixing thread. Set to (~(ma_uint64)0) to not perform any seeking. */