strmbase/transform: Hold the streaming lock for the entirety of Receive().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-11-30 19:48:32 -06:00 committed by Alexandre Julliard
parent 3b7ce56908
commit 3a7f54947e
4 changed files with 10 additions and 21 deletions

View File

@ -66,12 +66,10 @@ static HRESULT WINAPI ACMWrapper_Receive(TransformFilter *tf, IMediaSample *pSam
LONGLONG tStart = -1, tStop = -1, tMed;
LONGLONG mtStart = -1, mtStop = -1, mtMed;
EnterCriticalSection(&This->tf.csReceive);
hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
if (FAILED(hr))
{
ERR("Cannot get pointer to sample data (%x)\n", hr);
LeaveCriticalSection(&This->tf.csReceive);
return hr;
}
@ -107,7 +105,6 @@ static HRESULT WINAPI ACMWrapper_Receive(TransformFilter *tf, IMediaSample *pSam
if (FAILED(hr))
{
ERR("Unable to get delivery buffer (%x)\n", hr);
LeaveCriticalSection(&This->tf.csReceive);
return hr;
}
IMediaSample_SetPreroll(pOutSample, preroll);
@ -224,7 +221,6 @@ error:
This->lasttime_real = tStop;
This->lasttime_sent = tMed;
LeaveCriticalSection(&This->tf.csReceive);
return hr;
}

View File

@ -111,12 +111,11 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
LONGLONG tStart, tStop;
DWORD flags = 0;
EnterCriticalSection(&This->tf.csReceive);
hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
if (FAILED(hr))
{
ERR("Cannot get pointer to sample data (%x)\n", hr);
goto error;
return hr;
}
cbSrcStream = IMediaSample_GetActualDataLength(pSample);
@ -129,7 +128,7 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->tf.source, &pOutSample, NULL, NULL, 0);
if (FAILED(hr)) {
ERR("Unable to get delivery buffer (%x)\n", hr);
goto error;
return hr;
}
hr = IMediaSample_SetActualDataLength(pOutSample, 0);
@ -138,13 +137,14 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
hr = IMediaSample_GetPointer(pOutSample, &pbDstStream);
if (FAILED(hr)) {
ERR("Unable to get pointer to buffer (%x)\n", hr);
goto error;
IMediaSample_Release(pOutSample);
return hr;
}
cbDstStream = IMediaSample_GetSize(pOutSample);
if (cbDstStream < This->pBihOut->biSizeImage) {
ERR("Sample size is too small %d < %d\n", cbDstStream, This->pBihOut->biSizeImage);
hr = E_FAIL;
goto error;
IMediaSample_Release(pOutSample);
return E_FAIL;
}
if (IMediaSample_IsPreroll(pSample) == S_OK)
@ -161,8 +161,8 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
/* Drop sample if it's intended to be dropped */
if (flags & ICDECOMPRESS_HURRYUP) {
hr = S_OK;
goto error;
IMediaSample_Release(pOutSample);
return S_OK;
}
IMediaSample_SetActualDataLength(pOutSample, This->pBihOut->biSizeImage);
@ -187,11 +187,7 @@ static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
if (hr != S_OK && hr != VFW_E_NOT_CONNECTED)
ERR("Error sending sample (%x)\n", hr);
error:
if (pOutSample)
IMediaSample_Release(pOutSample);
LeaveCriticalSection(&This->tf.csReceive);
IMediaSample_Release(pOutSample);
return hr;
}

View File

@ -82,12 +82,12 @@ static HRESULT WINAPI TransformFilter_Input_Receive(struct strmbase_sink *This,
return S_FALSE;
}
LeaveCriticalSection(&pTransform->csReceive);
if (pTransform->pFuncsTable->pfnReceive)
hr = pTransform->pFuncsTable->pfnReceive(pTransform, pInSample);
else
hr = S_FALSE;
LeaveCriticalSection(&pTransform->csReceive);
return hr;
}

View File

@ -227,7 +227,6 @@ static HRESULT WINAPI Gstreamer_transform_ProcessData(TransformFilter *iface, IM
mark_wine_thread();
EnterCriticalSection(&This->tf.csReceive);
IMediaSample_GetPointer(sample, &data);
IMediaSample_AddRef(sample);
@ -235,7 +234,6 @@ static HRESULT WINAPI Gstreamer_transform_ProcessData(TransformFilter *iface, IM
buf = gst_buffer_new_wrapped_full(0, data, bufsize, 0, bufsize, sample, release_sample_wrapper);
if (!buf) {
IMediaSample_Release(sample);
LeaveCriticalSection(&This->tf.csReceive);
return S_OK;
}
@ -259,7 +257,6 @@ static HRESULT WINAPI Gstreamer_transform_ProcessData(TransformFilter *iface, IM
GST_BUFFER_FLAG_SET(buf, GST_BUFFER_FLAG_LIVE);
if (IMediaSample_IsSyncPoint(sample) != S_OK)
GST_BUFFER_FLAG_SET(buf, GST_BUFFER_FLAG_DELTA_UNIT);
LeaveCriticalSection(&This->tf.csReceive);
ret = gst_pad_push(This->my_src, buf);
if (ret)
WARN("Sending returned: %i\n", ret);