Commit 24a11088 authored by David Reid's avatar David Reid

Minor updates to the resource_manager example.

parent 83178a1d
...@@ -16,7 +16,7 @@ In this example we show how you can create a data source, mix them with other da ...@@ -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. 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_NO_ENGINE /* We're intentionally not using the ma_engine API here. */
#define MA_IMPLEMENTATION #define MINIAUDIO_IMPLEMENTATION
#include "../../miniaudio.h" #include "../../miniaudio.h"
#include "../ma_engine.h" #include "../ma_engine.h"
...@@ -149,7 +149,11 @@ int main(int argc, char** argv) ...@@ -149,7 +149,11 @@ int main(int argc, char** argv)
return -1; 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); 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. */ /* 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) ...@@ -180,7 +184,7 @@ int main(int argc, char** argv)
ma_resource_manager_post_job_quit(&resourceManager); ma_resource_manager_post_job_quit(&resourceManager);
ma_thread_wait(&jobThread); /* Wait for the custom job thread to finish before uninitializing the resource manager. */ 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) { for (iFile = 0; (size_t)iFile < g_dataSourceCount; iFile += 1) {
ma_resource_manager_data_source_uninit(&resourceManager, &g_dataSources[iFile]); ma_resource_manager_data_source_uninit(&resourceManager, &g_dataSources[iFile]);
} }
...@@ -188,7 +192,7 @@ int main(int argc, char** argv) ...@@ -188,7 +192,7 @@ int main(int argc, char** argv)
/* Uninitialize the resource manager after each data source. */ /* Uninitialize the resource manager after each data source. */
ma_resource_manager_uninit(&resourceManager); 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); ma_mixer_uninit(&g_mixer);
return 0; return 0;
......
...@@ -2632,7 +2632,7 @@ static ma_result ma_resource_manager_data_source_init_connector(ma_resource_mana ...@@ -2632,7 +2632,7 @@ static ma_result ma_resource_manager_data_source_init_connector(ma_resource_mana
movement overhead. movement overhead.
*/ */
if (pDataBuffer->data.type == ma_resource_manager_data_buffer_encoding_decoded) { 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) { pDataBuffer->data.decoded.sampleRate == pResourceManager->config.decodedSampleRate) {
pDataSource->dataBuffer.connectorType = ma_resource_manager_data_buffer_connector_buffer; pDataSource->dataBuffer.connectorType = ma_resource_manager_data_buffer_connector_buffer;
} else { } else {
......
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