diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2017-08-23 01:02:02 +0300 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2017-08-23 01:02:02 +0300 |
commit | f56c6a89f336f5d1fb546471d43fae443a82af77 (patch) | |
tree | bcbb975ceb63fdb1e55a62f9a7ed2a7328a1340d /decoder/LAVVideo | |
parent | d9bb31333115cda9d70507ca5106a803df8be4d3 (diff) |
Prevent a deadlock issue when changing the format in pause and stopping playback
Diffstat (limited to 'decoder/LAVVideo')
-rw-r--r-- | decoder/LAVVideo/LAVVideo.cpp | 43 | ||||
-rw-r--r-- | decoder/LAVVideo/LAVVideo.h | 2 |
2 files changed, 45 insertions, 0 deletions
diff --git a/decoder/LAVVideo/LAVVideo.cpp b/decoder/LAVVideo/LAVVideo.cpp index da336f42..494a0283 100644 --- a/decoder/LAVVideo/LAVVideo.cpp +++ b/decoder/LAVVideo/LAVVideo.cpp @@ -1016,6 +1016,49 @@ HRESULT CLAVVideo::StartStreaming() return S_OK; } +STDMETHODIMP CLAVVideo::Stop() +{ + CAutoLock lck1(&m_csFilter); + if (m_State == State_Stopped) { + return NOERROR; + } + + // Succeed the Stop if we are not completely connected + ASSERT(m_pInput == NULL || m_pOutput != NULL); + if (m_pInput == NULL || m_pInput->IsConnected() == FALSE || m_pOutput->IsConnected() == FALSE) { + m_State = State_Stopped; + m_bEOSDelivered = FALSE; + return NOERROR; + } + + ASSERT(m_pInput); + ASSERT(m_pOutput); + + // block futher delivery to prevent lock issues + m_bFlushing = TRUE; + + // decommit the input pin before locking or we can deadlock + m_pInput->Inactive(); + + // synchronize with Receive calls + + CAutoLock lck2(&m_csReceive); + m_pOutput->Inactive(); + + // allow a class derived from CTransformFilter + // to know about starting and stopping streaming + + HRESULT hr = StopStreaming(); + if (SUCCEEDED(hr)) { + // complete the state transition + m_State = State_Stopped; + m_bEOSDelivered = FALSE; + } + + m_bFlushing = FALSE; + return hr; +} + HRESULT CLAVVideo::GetDeliveryBuffer(IMediaSample** ppOut, int width, int height, AVRational ar, DXVA2_ExtendedFormat dxvaExtFlags, REFERENCE_TIME avgFrameDuration) { CheckPointer(ppOut, E_POINTER); diff --git a/decoder/LAVVideo/LAVVideo.h b/decoder/LAVVideo/LAVVideo.h index e48aca13..2fcd68cd 100644 --- a/decoder/LAVVideo/LAVVideo.h +++ b/decoder/LAVVideo/LAVVideo.h @@ -143,6 +143,8 @@ public: STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName); // CTransformFilter + STDMETHODIMP Stop(); + HRESULT CheckInputType(const CMediaType* mtIn); HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut); HRESULT DecideBufferSize(IMemAllocator * pAllocator, ALLOCATOR_PROPERTIES *pprop); |