Commit 4008aba4 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

strmbase: Use a separate critical section for the SourceSeeking structure.

parent 3b2a705b
......@@ -18,7 +18,6 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* FIXME: critical sections */
#include "strmbase_private.h"
......@@ -29,7 +28,9 @@ static inline SourceSeeking *impl_from_IMediaSeeking(IMediaSeeking *iface)
return CONTAINING_RECORD(iface, SourceSeeking, IMediaSeeking_iface);
}
HRESULT SourceSeeking_Init(SourceSeeking *pSeeking, const IMediaSeekingVtbl *Vtbl, SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart, SourceSeeking_ChangeRate fnChangeRate, PCRITICAL_SECTION crit_sect)
HRESULT strmbase_seeking_init(SourceSeeking *pSeeking, const IMediaSeekingVtbl *Vtbl,
SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart,
SourceSeeking_ChangeRate fnChangeRate)
{
assert(fnChangeStop && fnChangeStart && fnChangeRate);
......@@ -48,10 +49,16 @@ HRESULT SourceSeeking_Init(SourceSeeking *pSeeking, const IMediaSeekingVtbl *Vtb
pSeeking->llDuration = pSeeking->llStop;
pSeeking->dRate = 1.0;
pSeeking->timeformat = TIME_FORMAT_MEDIA_TIME;
pSeeking->crst = crit_sect;
InitializeCriticalSection(&pSeeking->cs);
pSeeking->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SourceSeeking.cs");
return S_OK;
}
void strmbase_seeking_cleanup(SourceSeeking *seeking)
{
DeleteCriticalSection(&seeking->cs);
}
HRESULT WINAPI SourceSeekingImpl_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities)
{
SourceSeeking *This = impl_from_IMediaSeeking(iface);
......@@ -104,9 +111,9 @@ HRESULT WINAPI SourceSeekingImpl_GetTimeFormat(IMediaSeeking * iface, GUID * pFo
SourceSeeking *This = impl_from_IMediaSeeking(iface);
TRACE("(%s)\n", debugstr_guid(pFormat));
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
*pFormat = This->timeformat;
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
return S_OK;
}
......@@ -118,10 +125,10 @@ HRESULT WINAPI SourceSeekingImpl_IsUsingTimeFormat(IMediaSeeking * iface, const
TRACE("(%s)\n", debugstr_guid(pFormat));
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
if (!IsEqualIID(pFormat, &This->timeformat))
hr = S_FALSE;
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
return hr;
}
......@@ -140,9 +147,9 @@ HRESULT WINAPI SourceSeekingImpl_GetDuration(IMediaSeeking * iface, LONGLONG * p
TRACE("(%p)\n", pDuration);
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
*pDuration = This->llDuration;
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
return S_OK;
}
......@@ -153,9 +160,9 @@ HRESULT WINAPI SourceSeekingImpl_GetStopPosition(IMediaSeeking * iface, LONGLONG
TRACE("(%p)\n", pStop);
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
*pStop = This->llStop;
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
return S_OK;
}
......@@ -167,9 +174,9 @@ HRESULT WINAPI SourceSeekingImpl_GetCurrentPosition(IMediaSeeking * iface, LONGL
TRACE("(%p)\n", pCurrent);
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
*pCurrent = This->llCurrent;
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
return S_OK;
}
......@@ -214,7 +221,7 @@ HRESULT WINAPI SourceSeekingImpl_SetPositions(IMediaSeeking * iface, LONGLONG *
LONGLONG llNewCurrent, llNewStop;
TRACE("(%p, %x, %p, %x)\n", pCurrent, dwCurrentFlags, pStop, dwStopFlags);
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
llNewCurrent = Adjust(This->llCurrent, pCurrent, dwCurrentFlags);
llNewStop = Adjust(This->llStop, pStop, dwStopFlags);
......@@ -233,7 +240,7 @@ HRESULT WINAPI SourceSeekingImpl_SetPositions(IMediaSeeking * iface, LONGLONG *
*pCurrent = llNewCurrent;
if (pStop && (dwStopFlags & AM_SEEKING_ReturnTime))
*pStop = llNewStop;
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
if (bChangeCurrent)
This->fnChangeStart(iface);
......@@ -249,10 +256,10 @@ HRESULT WINAPI SourceSeekingImpl_GetPositions(IMediaSeeking * iface, LONGLONG *
TRACE("(%p, %p)\n", pCurrent, pStop);
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
IMediaSeeking_GetCurrentPosition(iface, pCurrent);
IMediaSeeking_GetStopPosition(iface, pStop);
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
return S_OK;
}
......@@ -263,10 +270,10 @@ HRESULT WINAPI SourceSeekingImpl_GetAvailable(IMediaSeeking * iface, LONGLONG *
TRACE("(%p, %p)\n", pEarliest, pLatest);
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
*pEarliest = 0;
*pLatest = This->llDuration;
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
return S_OK;
}
......@@ -285,11 +292,11 @@ HRESULT WINAPI SourceSeekingImpl_SetRate(IMediaSeeking * iface, double dRate)
return VFW_E_UNSUPPORTED_AUDIO;
}
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
This->dRate = dRate;
if (bChangeRate)
hr = This->fnChangeRate(iface);
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
return hr;
}
......@@ -300,10 +307,10 @@ HRESULT WINAPI SourceSeekingImpl_GetRate(IMediaSeeking * iface, double * dRate)
TRACE("(%p)\n", dRate);
EnterCriticalSection(This->crst);
EnterCriticalSection(&This->cs);
/* Forward? */
*dRate = This->dRate;
LeaveCriticalSection(This->crst);
LeaveCriticalSection(&This->cs);
return S_OK;
}
......
......@@ -1869,6 +1869,7 @@ static void free_source_pin(struct gstdemux_source *pin)
FreeMediaType(&pin->mt);
gst_segment_free(pin->segment);
strmbase_seeking_cleanup(&pin->seek);
strmbase_source_cleanup(&pin->pin);
heap_free(pin);
}
......@@ -1921,8 +1922,8 @@ static struct gstdemux_source *create_pin(struct gstdemux *filter, const WCHAR *
pin->segment = gst_segment_new();
gst_segment_init(pin->segment, GST_FORMAT_TIME);
pin->IQualityControl_iface.lpVtbl = &GSTOutPin_QualityControl_Vtbl;
SourceSeeking_Init(&pin->seek, &GST_Seeking_Vtbl, GST_ChangeStop,
GST_ChangeCurrent, GST_ChangeRate, &filter->filter.csFilter);
strmbase_seeking_init(&pin->seek, &GST_Seeking_Vtbl, GST_ChangeStop,
GST_ChangeCurrent, GST_ChangeRate);
BaseFilterImpl_IncrementPinVersion(&filter->filter);
sprintf(pad_name, "qz_sink_%u", filter->cStreams);
......
......@@ -340,7 +340,8 @@ IUnknown * CALLBACK QTSplitter_create(IUnknown *outer, HRESULT *phr)
This->pInputPin.pin.peer = NULL;
This->pInputPin.pin.pFuncsTable = &sink_ops;
SourceSeeking_Init(&This->sourceSeeking, &QT_Seeking_Vtbl, QTSplitter_ChangeStop, QTSplitter_ChangeStart, QTSplitter_ChangeRate, &This->filter.csFilter);
strmbase_seeking_init(&This->sourceSeeking, &QT_Seeking_Vtbl,
QTSplitter_ChangeStop, QTSplitter_ChangeStart, QTSplitter_ChangeRate);
*phr = S_OK;
return &This->filter.IUnknown_inner;
......
......@@ -272,10 +272,13 @@ typedef struct SourceSeeking
double dRate;
LONGLONG llCurrent, llStop, llDuration;
GUID timeformat;
PCRITICAL_SECTION crst;
CRITICAL_SECTION cs;
} SourceSeeking;
HRESULT SourceSeeking_Init(SourceSeeking *pSeeking, const IMediaSeekingVtbl *Vtbl, SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart, SourceSeeking_ChangeRate fnChangeRate, PCRITICAL_SECTION crit_sect);
HRESULT strmbase_seeking_init(SourceSeeking *seeking, const IMediaSeekingVtbl *vtbl,
SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart,
SourceSeeking_ChangeRate fnChangeRate);
void strmbase_seeking_cleanup(SourceSeeking *seeking);
HRESULT WINAPI SourceSeekingImpl_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
HRESULT WINAPI SourceSeekingImpl_CheckCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment