Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2017-08-23 01:02:02 +0300
committerHendrik Leppkes <h.leppkes@gmail.com>2017-08-23 01:02:02 +0300
commitf56c6a89f336f5d1fb546471d43fae443a82af77 (patch)
treebcbb975ceb63fdb1e55a62f9a7ed2a7328a1340d
parentd9bb31333115cda9d70507ca5106a803df8be4d3 (diff)
Prevent a deadlock issue when changing the format in pause and stopping playback
-rw-r--r--decoder/LAVVideo/LAVVideo.cpp43
-rw-r--r--decoder/LAVVideo/LAVVideo.h2
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);