Fix a bug where sometimes a notification never gets signalled.

This commit is contained in:
David Reid
2021-06-08 21:05:21 +10:00
parent 5c26709fa7
commit 70d74c9d61
+19 -1
View File
@@ -7597,6 +7597,12 @@ static ma_result ma_resource_manager_data_buffer_init_internal(ma_resource_manag
if ((flags & MA_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { if ((flags & MA_DATA_SOURCE_FLAG_WAIT_INIT) != 0) {
ma_resource_manager_inline_notification_wait_and_uninit(&initNotification); ma_resource_manager_inline_notification_wait_and_uninit(&initNotification);
/* Make sure we return an error if initialization failed on the async thread. */
result = ma_resource_manager_data_buffer_result(pDataBuffer);
if (result == MA_BUSY) {
result = MA_SUCCESS;
}
} }
} }
} }
@@ -9332,7 +9338,7 @@ static ma_result ma_resource_manager_process_job__load_data_buffer(ma_resource_m
/* /*
First thing we need to do is check whether or not the data buffer is getting deleted. If so we First thing we need to do is check whether or not the data buffer is getting deleted. If so we
just abort, but making sure we increment the execution pointer . just abort, but making sure we increment the execution pointer.
*/ */
if (ma_resource_manager_data_buffer_result(pJob->loadDataBuffer.pDataBuffer) != MA_BUSY) { if (ma_resource_manager_data_buffer_result(pJob->loadDataBuffer.pDataBuffer) != MA_BUSY) {
result = MA_INVALID_OPERATION; /* The data buffer may be getting deleted before it's even been loaded. */ result = MA_INVALID_OPERATION; /* The data buffer may be getting deleted before it's even been loaded. */
@@ -9374,6 +9380,18 @@ done:
} }
} }
/*
If at this point the data buffer has not had it's connector initialized, it means the
notification event was never signalled which means we need to signal it here.
*/
if (pJob->loadDataBuffer.pDataBuffer->isConnectorInitialized == MA_FALSE) {
if (pJob->loadDataBuffer.pInitNotification != NULL) {
if (result != MA_SUCCESS) {
ma_async_notification_signal(pJob->loadDataBuffer.pInitNotification, MA_NOTIFICATION_FAILED);
}
}
}
c89atomic_fetch_add_32(&pJob->loadDataBuffer.pDataBuffer->executionPointer, 1); c89atomic_fetch_add_32(&pJob->loadDataBuffer.pDataBuffer->executionPointer, 1);
return result; return result;
} }