Windows: Prevent hang on shutdown.

Which may occur on ARM64 or perhaps lower thread processors?  Let's avoid
spinloops.
This commit is contained in:
Unknown W. Brackets committed 2021-01-02 22:49:06 -08:00
1 parent 83272c5e25
commit c66d5dcac1
3 files changed
+22 -6

No files matched your search

+15
View File
@@ -854,6 +854,21 @@ CAPTUREDEVIDE_MESSAGE WindowsCaptureDevice::getMessage() {
return message;
}
void WindowsCaptureDevice::updateState(const CAPTUREDEVIDE_STATE &newState) {
std::unique_lock<std::mutex> guard(stateMutex_);
state = newState;
stateCond_.notify_all();
}
void WindowsCaptureDevice::waitShutDown() {
sendMessage({ CAPTUREDEVIDE_COMMAND::SHUTDOWN, nullptr });
std::unique_lock<std::mutex> guard(stateMutex_);
while (!isShutDown()) {
stateCond_.wait(guard);
}
}
void WindowsCaptureDevice::messageHandler() {
CoInitializeEx(NULL, COINIT_MULTITHREADED);
MFStartup(MF_VERSION);