HRESULT WavSource::GetEvent(DWORD dwFlags, IMFMediaEvent** ppEvent) { // NOTE: GetEvent can block indefinitely, so we don't hold the // WavSource lock. This requires some juggling with the // event queue pointer. HRESULT hr = S_OK; IMFMediaEventQueue *pQueue = NULL; EnterCriticalSection(&m_critSec); // Check shutdown hr = CheckShutdown(); if (SUCCEEDED(hr)) { pQueue = m_pEventQueue; pQueue->AddRef(); } LeaveCriticalSection(&m_critSec); if (SUCCEEDED(hr)) { hr = pQueue->GetEvent(dwFlags, ppEvent); } SafeRelease(&pQueue); return hr; }
HRESULT WavStream::GetEvent(DWORD dwFlags, IMFMediaEvent** ppEvent) { HRESULT hr = S_OK; IMFMediaEventQueue *pQueue = NULL; EnterCriticalSection(&m_critSec); hr = CheckShutdown(); if (SUCCEEDED(hr)) { pQueue = m_pEventQueue; pQueue->AddRef(); } LeaveCriticalSection(&m_critSec); if (SUCCEEDED(hr)) { hr = pQueue->GetEvent(dwFlags, ppEvent); } SafeRelease(&pQueue); return hr; }
HRESULT MPEG1Stream::GetEvent(DWORD dwFlags, IMFMediaEvent** ppEvent) { HRESULT hr = S_OK; IMFMediaEventQueue *pQueue = NULL; { // scope for lock SourceLock lock(m_pSource); // Check shutdown CHECK_HR(hr = CheckShutdown()); // Cache a local pointer to the queue. pQueue = m_pEventQueue; pQueue->AddRef(); } // release lock // Use the local pointer to call GetEvent. CHECK_HR(hr = pQueue->GetEvent(dwFlags, ppEvent)); done: SAFE_RELEASE(pQueue); return hr; }
STDMETHODIMP CMediaEventGenerator::GetEvent( _In_ DWORD dwFlags, _Outptr_result_maybenull_ IMFMediaEvent** ppEvent ) { // // Because GetEvent can block indefinitely, it requires // a slightly different locking strategy. // HRESULT hr = S_OK; //MFWMITRACE(DH_THIS_FILE, TP_NORMAL, __FUNCTION__ " : MultiPinMFT GetEvent called"); IMFMediaEventQueue *pQueue = NULL; m_critSec.Lock(); hr = CheckShutdown(); // // Store the pointer in a local variable, so that another thread // does not release it after we leave the critical section. // if (SUCCEEDED(hr)) { pQueue = m_pQueue; } m_critSec.Unlock(); if (SUCCEEDED(hr)) { hr = pQueue->GetEvent(dwFlags, ppEvent); } return hr; }
HRESULT PpboxStream::GetEvent(DWORD dwFlags, IMFMediaEvent** ppEvent) { HRESULT hr = S_OK; IMFMediaEventQueue *pQueue = NULL; { // scope for lock SourceLock lock(m_pSource); // Check shutdown hr = CheckShutdown(); // Cache a local pointer to the queue. if (SUCCEEDED(hr)) { pQueue = m_pEventQueue; pQueue->AddRef(); } } // release lock // Use the local pointer to call GetEvent. if (SUCCEEDED(hr)) { hr = pQueue->GetEvent(dwFlags, ppEvent); } SafeRelease(&pQueue); return hr; }