mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 09:14:04 +02:00
Resource Manager: Cleanup from some previous refactoring.
This commit is contained in:
+6
-24
@@ -2052,7 +2052,7 @@ static ma_data_source* ma_resource_manager_data_buffer_get_connector(ma_resource
|
||||
}
|
||||
}
|
||||
|
||||
static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 hashedName32, ma_uint32 flags, ma_resource_manager_memory_buffer* pExistingData, ma_async_notification* pNotification, ma_resource_manager_data_buffer* pDataBuffer)
|
||||
static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 hashedName32, ma_uint32 flags, ma_async_notification* pNotification, ma_resource_manager_data_buffer* pDataBuffer)
|
||||
{
|
||||
ma_result result;
|
||||
ma_resource_manager_data_buffer_node* pInsertPoint;
|
||||
@@ -2123,27 +2123,10 @@ static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager
|
||||
}
|
||||
|
||||
/*
|
||||
The new data buffer has been inserted into the BST. If the data for the item is owned by the application we don't need to do anything except
|
||||
set the necessary data pointers. Otherwise we need to load the data. If we are loading synchronously we need to load everything from the
|
||||
calling thread because we may be in a situation where there are no job threads running and therefore the data will never get loaded. If we
|
||||
are loading asynchronously, we can assume at least one job thread exists and we can do everything from there.
|
||||
*/
|
||||
if (pExistingData != NULL) {
|
||||
/* We don't need to do anything if the data is owned by the application except set the necessary data pointers. */
|
||||
MA_ASSERT(dataBufferType == pExistingData->type);
|
||||
|
||||
pDataBuffer->pNode->isDataOwnedByResourceManager = MA_FALSE;
|
||||
pDataBuffer->pNode->data = *pExistingData;
|
||||
pDataBuffer->pNode->result = MA_SUCCESS;
|
||||
|
||||
/* Fire the event if we have one. */
|
||||
if (pNotification != NULL) {
|
||||
ma_async_notification_signal(pNotification);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
The data needs to be loaded. If we're loading synchronously we need to do everything here on the calling thread. Otherwise we post
|
||||
a job and get one of the job threads to do it for us.
|
||||
The new data buffer has been inserted into the BST. We now need to load the data. If we are loading synchronously we need to load
|
||||
everything from the calling thread because we may be in a situation where there are no job threads running and therefore the data
|
||||
will never get loaded. If we are loading asynchronously, we can assume at least one job thread exists and we can do everything
|
||||
from there.
|
||||
*/
|
||||
pDataBuffer->pNode->isDataOwnedByResourceManager = MA_TRUE;
|
||||
pDataBuffer->pNode->result = MA_BUSY;
|
||||
@@ -2315,7 +2298,6 @@ static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager
|
||||
ma__free_from_callbacks(pDataBuffer->pNode, &pResourceManager->config.allocationCallbacks/*, MA_ALLOCATION_TYPE_RESOURCE_MANAGER_DATA_BUFFER*/);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/* It's not really necessary, but for completeness we'll want to fire the event if we have one in synchronous mode. */
|
||||
if (async == MA_FALSE) {
|
||||
@@ -2347,7 +2329,7 @@ MA_API ma_result ma_resource_manager_data_buffer_init(ma_resource_manager* pReso
|
||||
/* At this point we can now enter the critical section. */
|
||||
ma_mutex_lock(&pResourceManager->dataBufferLock);
|
||||
{
|
||||
result = ma_resource_manager_data_buffer_init_nolock(pResourceManager, pFilePath, hashedName32, flags, NULL, pNotification, pDataBuffer);
|
||||
result = ma_resource_manager_data_buffer_init_nolock(pResourceManager, pFilePath, hashedName32, flags, pNotification, pDataBuffer);
|
||||
}
|
||||
ma_mutex_unlock(&pResourceManager->dataBufferLock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user