/* If we're not already seeking and we're sitting on the same frame, just make this a no-op. */
if (c89atomic_load_32(&pDataStream->seekCounter) == 0) {
if (c89atomic_load_64(&pDataStream->absoluteCursor) == frameIndex) {
return MA_SUCCESS;
}
}
/* Increment the seek counter first to indicate to read_paged_pcm_frames() and map_paged_pcm_frames() that we are in the middle of a seek and MA_BUSY should be returned. */
if (dataSupplyType != ma_resource_manager_data_supply_type_unknown) {
/* We can now initialize the connector. If this fails, we need to abort. It's very rare for this to fail. */
result = ma_resource_manager_data_buffer_init_connector(pDataBuffer, pJob->data.resourceManager.loadDataBuffer.pInitNotification, pJob->data.resourceManager.loadDataBuffer.pInitFence);
ma_resource_manager_data_source_config dataSourceConfig; /* For setting initial looping state and range. */
result = ma_resource_manager_data_buffer_init_connector(pDataBuffer, &dataSourceConfig, pJob->data.resourceManager.loadDataBuffer.pInitNotification, pJob->data.resourceManager.loadDataBuffer.pInitFence);
if (result != MA_SUCCESS) {
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to initialize connector for data buffer. %s.\n", ma_result_description(result));
ma_uint64(*onGetOutputLatency)(void*pUserData,constma_resampling_backend*pBackend);/* Optional. Latency will be reported as 0. */
ma_result(*onGetRequiredInputFrameCount)(void*pUserData,constma_resampling_backend*pBackend,ma_uint64outputFrameCount,ma_uint64*pInputFrameCount);/* Optional. Latency mitigation will be disabled. */
ma_result(*onGetExpectedOutputFrameCount)(void*pUserData,constma_resampling_backend*pBackend,ma_uint64inputFrameCount,ma_uint64*pOutputFrameCount);/* Optional. Latency mitigation will be disabled. */
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_uint32flags;/* Resource manager data source flags that were used when initializing the data buffer. */
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. */
...
...
@@ -2327,6 +2345,11 @@ struct ma_job
ma_async_notification*pDoneNotification;/* Signalled when the data buffer has been fully decoded. */
ma_fence*pInitFence;/* Released when the data buffer has been initialized and the format/channels/rate can be retrieved. */
ma_fence*pDoneFence;/* Released when the data buffer has been fully decoded. */
constvoid*pData;/* If set to NULL, will allocate a block of memory for you. */
ma_allocation_callbacksallocationCallbacks;
...
...
@@ -6253,7 +6278,8 @@ typedef enum
MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM=0x00000001,/* When set, does not load the entire data source in memory. Disk I/O will happen on job threads. */
MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE=0x00000002,/* Decode data before storing in memory. When set, decoding is done at the resource manager level rather than the mixing thread. Results in faster mixing, but higher memory usage. */
MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC=0x00000004,/* When set, the resource manager will load the data source asynchronously. */
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_DATA_SOURCE_FLAG_UNKNOWN_LENGTH=0x00000010/* Gives the resource manager a hint that the length of the data source is unknown and calling `ma_data_source_get_length_in_pcm_frames()` should be avoided. */
}ma_resource_manager_data_source_flags;
...
...
@@ -7123,7 +7149,7 @@ struct ma_sound
{
ma_engine_nodeengineNode;/* Must be the first member for compatibility with the ma_node API. */
ma_data_source*pDataSource;
ma_uint64seekTarget;/* The PCM frame index to seek to in the mixing thread. Set to (~(ma_uint64)0) to not perform any seeking. */
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. */