From 24a1108834247efca60a98a01d491477ff8d7a24 Mon Sep 17 00:00:00 2001 From: David Reid Date: Thu, 23 Jul 2020 17:01:04 +1000 Subject: [PATCH] Minor updates to the resource_manager example. --- research/_examples/resource_manager.c | 12 ++++++++---- research/ma_engine.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/research/_examples/resource_manager.c b/research/_examples/resource_manager.c index 452c6041..e29434ee 100644 --- a/research/_examples/resource_manager.c +++ b/research/_examples/resource_manager.c @@ -16,7 +16,7 @@ In this example we show how you can create a data source, mix them with other da threads to manage internally and how to implement your own custom job thread. */ #define MA_NO_ENGINE /* We're intentionally not using the ma_engine API here. */ -#define MA_IMPLEMENTATION +#define MINIAUDIO_IMPLEMENTATION #include "../../miniaudio.h" #include "../ma_engine.h" @@ -149,7 +149,11 @@ int main(int argc, char** argv) return -1; } - /* Now that we have a resource manager we can set up our custom job thread. */ + /* + Now that we have a resource manager we can set up our custom job thread. This is optional. Normally when doing self-managed job threads + you would set the internal job thread count to zero. We're doing both internal and self-managed job threads in this example just for + demonstration purposes. + */ ma_thread_create(&jobThread, ma_thread_priority_default, 0, custom_job_thread, &resourceManager); /* Create each data source from the resource manager. Note that the caller is the owner. */ @@ -180,7 +184,7 @@ int main(int argc, char** argv) ma_resource_manager_post_job_quit(&resourceManager); ma_thread_wait(&jobThread); /* Wait for the custom job thread to finish before uninitializing the resource manager. */ - /* Out data sources need to be explicitly uninitialized. ma_resource_manager_uninit() will not do it for us. */ + /* Our data sources need to be explicitly uninitialized. ma_resource_manager_uninit() will not do it for us. */ for (iFile = 0; (size_t)iFile < g_dataSourceCount; iFile += 1) { ma_resource_manager_data_source_uninit(&resourceManager, &g_dataSources[iFile]); } @@ -188,7 +192,7 @@ int main(int argc, char** argv) /* Uninitialize the resource manager after each data source. */ ma_resource_manager_uninit(&resourceManager); - /* We're uninitializing the mixer last, but it doesn't really when it's done, so long as it's after the device has been stopped/uninitialized. */ + /* We're uninitializing the mixer last, but it doesn't really matter when it's done, so long as it's after the device has been stopped/uninitialized. */ ma_mixer_uninit(&g_mixer); return 0; diff --git a/research/ma_engine.h b/research/ma_engine.h index 9aab03c7..ed7e166a 100644 --- a/research/ma_engine.h +++ b/research/ma_engine.h @@ -2632,7 +2632,7 @@ static ma_result ma_resource_manager_data_source_init_connector(ma_resource_mana movement overhead. */ if (pDataBuffer->data.type == ma_resource_manager_data_buffer_encoding_decoded) { - if (pDataBuffer->data.decoded.format == pResourceManager->config.decodedFormat && + if (pDataBuffer->data.decoded.format == pResourceManager->config.decodedFormat && pDataBuffer->data.decoded.sampleRate == pResourceManager->config.decodedSampleRate) { pDataSource->dataBuffer.connectorType = ma_resource_manager_data_buffer_connector_buffer; } else {