Cleanly handle "MF_E_SHUTDOWN" error when an even is received while the session is shutting down

This commit is contained in:
Mamadou DIOP 2015-11-11 00:58:19 +01:00
parent c82f4505fc
commit 7ff6a247a8
1 changed files with 8 additions and 2 deletions

View File

@ -684,10 +684,16 @@ static void* TSK_STDCALL RunSessionThread(void *pArg)
TSK_DEBUG_INFO("RunSessionThread (MF video producer) - ENTER");
while (pSelf->bStarted){
CHECK_HR(hr = pSelf->pSession->GetEvent(0, &pEvent));
hr = pSelf->pSession->GetEvent(0, &pEvent);
if (hr == MF_E_SHUTDOWN) {
if (pSelf->bStarted) {
CHECK_HR(hr); // Shutdown called but "bStarted" not equal to false
}
break; // Shutdown called and "bStarted" is equal to false => break the loop
}
CHECK_HR(hr = pEvent->GetStatus(&hrStatus));
CHECK_HR(hr = pEvent->GetType(&met));
if (FAILED(hrStatus) /*&& hrStatus != MF_E_NO_SAMPLE_TIMESTAMP*/)
{
TSK_DEBUG_ERROR("Session error: 0x%x (event id: %d)\n", hrStatus, met);