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
+18
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;
}
} }
} }
} }
@@ -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;
} }