Commit 6ec9a1c1 authored by David Reid's avatar David Reid

Minor code restructure.

parent 9f446079
...@@ -7000,20 +7000,29 @@ MA_API void ma_resource_manager_uninit(ma_resource_manager* pResourceManager) ...@@ -7000,20 +7000,29 @@ MA_API void ma_resource_manager_uninit(ma_resource_manager* pResourceManager)
} }
static ma_result ma_resource_manager__init_decoder(ma_resource_manager* pResourceManager, const char* pFilePath, const wchar_t* pFilePathW, ma_decoder* pDecoder) static ma_decoder_config ma_resource_manager__init_decoder_config(ma_resource_manager* pResourceManager)
{ {
ma_decoder_config config; ma_decoder_config config;
MA_ASSERT(pResourceManager != NULL);
MA_ASSERT(pFilePath != NULL || pFilePathW != NULL);
MA_ASSERT(pDecoder != NULL);
config = ma_decoder_config_init(pResourceManager->config.decodedFormat, pResourceManager->config.decodedChannels, pResourceManager->config.decodedSampleRate); config = ma_decoder_config_init(pResourceManager->config.decodedFormat, pResourceManager->config.decodedChannels, pResourceManager->config.decodedSampleRate);
config.allocationCallbacks = pResourceManager->config.allocationCallbacks; config.allocationCallbacks = pResourceManager->config.allocationCallbacks;
config.ppCustomBackendVTables = pResourceManager->config.ppCustomDecodingBackendVTables; config.ppCustomBackendVTables = pResourceManager->config.ppCustomDecodingBackendVTables;
config.customBackendVTableCount = pResourceManager->config.customDecodingBackendVTableCount; config.customBackendVTableCount = pResourceManager->config.customDecodingBackendVTableCount;
config.pCustomBackendUserData = pResourceManager->config.pCustomDecodingBackendUserData; config.pCustomBackendUserData = pResourceManager->config.pCustomDecodingBackendUserData;
return config;
}
static ma_result ma_resource_manager__init_decoder(ma_resource_manager* pResourceManager, const char* pFilePath, const wchar_t* pFilePathW, ma_decoder* pDecoder)
{
ma_decoder_config config;
MA_ASSERT(pResourceManager != NULL);
MA_ASSERT(pFilePath != NULL || pFilePathW != NULL);
MA_ASSERT(pDecoder != NULL);
config = ma_resource_manager__init_decoder_config(pResourceManager);
if (pFilePath != NULL) { if (pFilePath != NULL) {
return ma_decoder_init_vfs(pResourceManager->config.pVFS, pFilePath, &config, pDecoder); return ma_decoder_init_vfs(pResourceManager->config.pVFS, pFilePath, &config, pDecoder);
} else { } else {
...@@ -7043,14 +7052,9 @@ static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_mana ...@@ -7043,14 +7052,9 @@ static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_mana
{ {
case ma_resource_manager_data_supply_type_encoded: /* Connector is a decoder. */ case ma_resource_manager_data_supply_type_encoded: /* Connector is a decoder. */
{ {
ma_decoder_config configOut; ma_decoder_config config;
configOut = ma_decoder_config_init(pDataBuffer->pResourceManager->config.decodedFormat, pDataBuffer->pResourceManager->config.decodedChannels, pDataBuffer->pResourceManager->config.decodedSampleRate); config = ma_resource_manager__init_decoder_config(pDataBuffer->pResourceManager);
configOut.allocationCallbacks = pDataBuffer->pResourceManager->config.allocationCallbacks; result = ma_decoder_init_memory(pDataBuffer->pNode->data.encoded.pData, pDataBuffer->pNode->data.encoded.sizeInBytes, &config, &pDataBuffer->connector.decoder);
configOut.ppCustomBackendVTables = pDataBuffer->pResourceManager->config.ppCustomDecodingBackendVTables;
configOut.customBackendVTableCount = pDataBuffer->pResourceManager->config.customDecodingBackendVTableCount;
configOut.pCustomBackendUserData = pDataBuffer->pResourceManager->config.pCustomDecodingBackendUserData;
result = ma_decoder_init_memory(pDataBuffer->pNode->data.encoded.pData, pDataBuffer->pNode->data.encoded.sizeInBytes, &configOut, &pDataBuffer->connector.decoder);
} break; } break;
case ma_resource_manager_data_supply_type_decoded: /* Connector is an audio buffer. */ case ma_resource_manager_data_supply_type_decoded: /* Connector is an audio buffer. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment