mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Resource Manager: Fix a bug when reusing an already-loaded data buffer.
This commit is contained in:
+12
-1
@@ -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)
|
|||||||
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)
|
|||||||
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
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user