@@ -1329,7 +1331,23 @@ MA_API ma_spatializer_config ma_spatializer_config_init(ma_uint32 channelsIn, ma
...
@@ -1329,7 +1331,23 @@ MA_API ma_spatializer_config ma_spatializer_config_init(ma_uint32 channelsIn, ma
typedefstruct
typedefstruct
{
{
ma_spatializer_configconfig;
ma_uint32channelsIn;
ma_uint32channelsOut;
ma_channel*pChannelMapIn;
ma_attenuation_modelattenuationModel;
ma_positioningpositioning;
ma_handednesshandedness;/* Defaults to right. Forward is -1 on the Z axis. In a left handed system, forward is +1 on the Z axis. */
floatminGain;
floatmaxGain;
floatminDistance;
floatmaxDistance;
floatrolloff;
floatconeInnerAngleInRadians;
floatconeOuterAngleInRadians;
floatconeOuterGain;
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. */
The idea of the slot allocator is for it to be used in conjunction with a fixed sized buffer. You use the slot allocator to allocator an index that can be used
as the insertion point for an object.
Slots are reference counted to help mitigate the ABA problem in the lock-free queue we use for tracking jobs.
The slot index is stored in the low 32 bits. The reference counter is stored in the high 32 bits:
+-----------------+-----------------+
| 32 Bits | 32 Bits |
+-----------------+-----------------+
| Reference Count | Slot Index |
+-----------------+-----------------+
*/
typedefstruct
{
ma_uint32capacity;/* The number of slots to make available. */
MA_ATOMIC(4,ma_uint32)bitfield;/* Must be used atomically because the allocation and freeing routines need to make copies of this which must never be optimized away by the compiler. */
}ma_slot_allocator_group;
typedefstruct
{
ma_slot_allocator_group*pGroups;/* Slots are grouped in chunks of 32. */
ma_uint32*pSlots;/* 32 bits for reference counting for ABA mitigation. */
ma_uint16slot;/* Index into a ma_slot_allocator. */
ma_uint32refcount;
}breakup;
ma_uint64allocation;
}toc;/* 8 bytes. We encode the job code into the slot allocation data to save space. */
MA_ATOMIC(8,ma_uint64)next;/* refcount + slot for the next item. Does not include the job code. */
ma_uint32order;/* Execution order. Used to create a data dependency and ensure a job is executed in order. Usage is contextual depending on the job type. */
ma_bool32decode;/* When set to true, the data buffer will be decoded. Otherwise it'll be encoded and will use a decoder for the connector. */
ma_async_notification*pInitNotification;/* Signalled when the data buffer has been initialized and the format/channels/rate can be retrieved. */
ma_async_notification*pDoneNotification;/* Signalled when the data buffer has been fully decoded. Will be passed through to MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE when decoding. */
ma_fence*pInitFence;/* Released when initialization of the decoder is complete. */
ma_fence*pDoneFence;/* Released if initialization of the decoder fails. Passed through to PAGE_DATA_BUFFER_NODE untouched if init is successful. */
The idea of the slot allocator is for it to be used in conjunction with a fixed sized buffer. You use the slot allocator to allocator an index that can be used
as the insertion point for an object.
Slots are reference counted to help mitigate the ABA problem in the lock-free queue we use for tracking jobs.
The slot index is stored in the low 32 bits. The reference counter is stored in the high 32 bits:
+-----------------+-----------------+
| 32 Bits | 32 Bits |
+-----------------+-----------------+
| Reference Count | Slot Index |
+-----------------+-----------------+
*/
typedefstruct
{
ma_uint32capacity;/* The number of slots to make available. */
MA_ATOMIC(4,ma_uint32)bitfield;/* Must be used atomically because the allocation and freeing routines need to make copies of this which must never be optimized away by the compiler. */
}ma_slot_allocator_group;
typedefstruct
{
ma_slot_allocator_group*pGroups;/* Slots are grouped in chunks of 32. */
ma_uint32*pSlots;/* 32 bits for reference counting for ABA mitigation. */
MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT=0x00000008/* When set, waits for initialization of the underlying data source before returning from ma_resource_manager_data_source_init(). */
MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT=0x00000008/* When set, waits for initialization of the underlying data source before returning from ma_resource_manager_data_source_init(). */
MA_RESOURCE_MANAGER_JOB_CUSTOM=0x00000100/* Number your custom job codes as (MA_RESOURCE_MANAGER_JOB_CUSTOM + 0), (MA_RESOURCE_MANAGER_JOB_CUSTOM + 1), etc. */
}ma_resource_manager_job_type;
/*
/*
Pipeline notifications used by the resource manager. Made up of both an async notification and a fence, both of which are optional.
Pipeline notifications used by the resource manager. Made up of both an async notification and a fence, both of which are optional.
}toc;/* 8 bytes. We encode the job code into the slot allocation data to save space. */
MA_ATOMIC(8,ma_uint64)next;/* refcount + slot for the next item. Does not include the job code. */
ma_uint32order;/* Execution order. Used to create a data dependency and ensure a job is executed in order. Usage is contextual depending on the job type. */
ma_bool32decode;/* When set to true, the data buffer will be decoded. Otherwise it'll be encoded and will use a decoder for the connector. */
ma_async_notification*pInitNotification;/* Signalled when the data buffer has been initialized and the format/channels/rate can be retrieved. */
ma_async_notification*pDoneNotification;/* Signalled when the data buffer has been fully decoded. Will be passed through to MA_RESOURCE_MANAGER_JOB_PAGE_DATA_BUFFER_NODE when decoding. */
ma_fence*pInitFence;/* Released when initialization of the decoder is complete. */
ma_fence*pDoneFence;/* Released if initialization of the decoder fails. Passed through to PAGE_DATA_BUFFER_NODE untouched if init is successful. */
MA_APIma_resultma_resource_manager_job_queue_next(ma_resource_manager_job_queue*pQueue,ma_resource_manager_job*pJob);/* Returns MA_CANCELLED if the next job is a quit job. */
/* Maximum job thread count will be restricted to this, but this may be removed later and replaced with a heap allocation thereby removing any limitation. */
/* Maximum job thread count will be restricted to this, but this may be removed later and replaced with a heap allocation thereby removing any limitation. */
ma_resource_manager*pResourceManager;/* A pointer to the resource manager that owns this data stream. */
ma_resource_manager*pResourceManager;/* A pointer to the resource manager that owns this data stream. */
ma_uint32flags;/* The flags that were passed used to initialize the stream. */
ma_uint32flags;/* The flags that were passed used to initialize the stream. */
ma_decoderdecoder;/* Used for filling pages with data. This is only ever accessed by the job thread. The public API should never touch this. */
ma_decoderdecoder;/* Used for filling pages with data. This is only ever accessed by the job thread. The public API should never touch this. */
ma_bool32isDecoderInitialized;/* Required for determining whether or not the decoder should be uninitialized in MA_RESOURCE_MANAGER_JOB_FREE_DATA_STREAM. */
ma_bool32isDecoderInitialized;/* Required for determining whether or not the decoder should be uninitialized in MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_STREAM. */
ma_uint64totalLengthInPCMFrames;/* This is calculated when first loaded by the MA_RESOURCE_MANAGER_JOB_LOAD_DATA_STREAM. */
ma_uint64totalLengthInPCMFrames;/* This is calculated when first loaded by the MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_STREAM. */
ma_uint32relativeCursor;/* The playback cursor, relative to the current page. Only ever accessed by the public API. Never accessed by the job thread. */
ma_uint32relativeCursor;/* The playback cursor, relative to the current page. Only ever accessed by the public API. Never accessed by the job thread. */
MA_ATOMIC(8,ma_uint64)absoluteCursor;/* The playback cursor, in absolute position starting from the start of the file. */
MA_ATOMIC(8,ma_uint64)absoluteCursor;/* The playback cursor, in absolute position starting from the start of the file. */
ma_uint32currentPageIndex;/* Toggles between 0 and 1. Index 0 is the first half of pPageData. Index 1 is the second half. Only ever accessed by the public API. Never accessed by the job thread. */
ma_uint32currentPageIndex;/* Toggles between 0 and 1. Index 0 is the first half of pPageData. Index 1 is the second half. Only ever accessed by the public API. Never accessed by the job thread. */
...
@@ -6250,7 +6435,7 @@ typedef struct
...
@@ -6250,7 +6435,7 @@ typedef struct
ma_uint32decodedChannels;/* The decoded channel count to use. Set to 0 (default) to use the file's native channel count. */
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_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. */
ma_uint32jobThreadCount;/* Set to 0 if you want to self-manage your job threads. Defaults to 1. */
ma_uint32jobQueueCapacity;/* The maximum number of jobs that can fit in the queue at a time. Defaults to MA_RESOURCE_MANAGER_JOB_QUEUE_CAPACITY. Cannot be zero. */
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_uint32flags;
ma_vfs*pVFS;/* Can be NULL in which case defaults will be used. */
ma_vfs*pVFS;/* Can be NULL in which case defaults will be used. */
MA_APIma_resultma_resource_manager_process_job(ma_resource_manager*pResourceManager,ma_job*pJob);/* DEPRECATED. Use ma_job_process(). Will be removed in version 0.12. */
MA_APIma_resultma_resource_manager_process_next_job(ma_resource_manager*pResourceManager);/* Returns MA_CANCELLED if a MA_RESOURCE_MANAGER_JOB_QUIT job is found. In non-blocking mode, returns MA_NO_DATA_AVAILABLE if no jobs are available. */
MA_APIma_resultma_resource_manager_process_next_job(ma_resource_manager*pResourceManager);/* Returns MA_CANCELLED if a MA_JOB_TYPE_QUIT job is found. In non-blocking mode, returns MA_NO_DATA_AVAILABLE if no jobs are available. */