Commit 07ae0be2 authored by David Reid's avatar David Reid

Resource Manager: Fix a bug when reusing an already-loaded data buffer.

parent d83b3886
...@@ -30,6 +30,7 @@ int main(int argc, char** argv) ...@@ -30,6 +30,7 @@ int main(int argc, char** argv)
ma_result result; ma_result result;
ma_engine engine; ma_engine engine;
ma_sound sound; ma_sound sound;
ma_sound sound2;
sound_loaded_notification loadNotification; sound_loaded_notification loadNotification;
...@@ -49,7 +50,14 @@ int main(int argc, char** argv) ...@@ -49,7 +50,14 @@ int main(int argc, char** argv)
loadNotification.cb.onSignal = on_sound_loaded; loadNotification.cb.onSignal = on_sound_loaded;
loadNotification.pSound = &sound; loadNotification.pSound = &sound;
result = ma_sound_init_from_file(&engine, argv[1], MA_DATA_SOURCE_FLAG_DECODE | MA_DATA_SOURCE_FLAG_ASYNC | MA_DATA_SOURCE_FLAG_STREAM, &loadNotification, NULL, &sound); result = ma_sound_init_from_file(&engine, argv[1], MA_DATA_SOURCE_FLAG_DECODE /*| MA_DATA_SOURCE_FLAG_ASYNC | MA_DATA_SOURCE_FLAG_STREAM*/, &loadNotification, NULL, &sound);
if (result != MA_SUCCESS) {
printf("Failed to load sound: %s\n", argv[1]);
ma_engine_uninit(&engine);
return -1;
}
result = ma_sound_init_from_file(&engine, argv[1], MA_DATA_SOURCE_FLAG_DECODE /*| MA_DATA_SOURCE_FLAG_ASYNC | MA_DATA_SOURCE_FLAG_STREAM*/, &loadNotification, NULL, &sound2);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to load sound: %s\n", argv[1]); printf("Failed to load sound: %s\n", argv[1]);
ma_engine_uninit(&engine); ma_engine_uninit(&engine);
...@@ -74,6 +82,9 @@ int main(int argc, char** argv) ...@@ -74,6 +82,9 @@ int main(int argc, char** argv)
ma_sound_set_stop_delay(&sound, 1000); ma_sound_set_stop_delay(&sound, 1000);
ma_sound_start(&sound); ma_sound_start(&sound);
ma_sleep(1000);
ma_sound_start(&sound2);
//ma_sleep(2000); //ma_sleep(2000);
printf("Stopping...\n"); printf("Stopping...\n");
//ma_sound_stop(&sound); //ma_sound_stop(&sound);
......
...@@ -2197,6 +2197,12 @@ static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager ...@@ -2197,6 +2197,12 @@ static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager
return result; /* Should never happen. Failed to increment the reference count. */ return result; /* Should never happen. Failed to increment the reference count. */
} }
result = ma_resource_manager_data_buffer_init_connector(pDataBuffer);
if (result != MA_SUCCESS) {
ma_resource_manager_data_buffer_node_free(pDataBuffer->pResourceManager, pDataBuffer->pNode);
return result;
}
if (pNotification != NULL) { if (pNotification != NULL) {
ma_async_notification_signal(pNotification); ma_async_notification_signal(pNotification);
} }
......
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