strmbase: Introduce filter state callbacks.

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-10-23 20:04:26 -05:00 committed by Alexandre Julliard
parent f7232d4e2c
commit 7c8c0a1d2e
2 changed files with 52 additions and 18 deletions

View File

@ -126,54 +126,82 @@ HRESULT WINAPI BaseFilterImpl_GetClassID(IBaseFilter * iface, CLSID * pClsid)
HRESULT WINAPI BaseFilterImpl_Stop(IBaseFilter *iface) HRESULT WINAPI BaseFilterImpl_Stop(IBaseFilter *iface)
{ {
struct strmbase_filter *filter = impl_from_IBaseFilter(iface); struct strmbase_filter *filter = impl_from_IBaseFilter(iface);
HRESULT hr = S_OK;
TRACE("iface %p.\n", iface); TRACE("filter %p.\n", filter);
EnterCriticalSection(&filter->csFilter); EnterCriticalSection(&filter->csFilter);
filter->state = State_Stopped;
if (filter->state == State_Running && filter->ops->filter_stop_stream)
hr = filter->ops->filter_stop_stream(filter);
if (SUCCEEDED(hr) && filter->ops->filter_cleanup_stream)
hr = filter->ops->filter_cleanup_stream(filter);
if (SUCCEEDED(hr))
filter->state = State_Stopped;
LeaveCriticalSection(&filter->csFilter); LeaveCriticalSection(&filter->csFilter);
return S_OK; return hr;
} }
HRESULT WINAPI BaseFilterImpl_Pause(IBaseFilter *iface) HRESULT WINAPI BaseFilterImpl_Pause(IBaseFilter *iface)
{ {
struct strmbase_filter *filter = impl_from_IBaseFilter(iface); struct strmbase_filter *filter = impl_from_IBaseFilter(iface);
HRESULT hr = S_OK;
TRACE("iface %p.\n", iface); TRACE("filter %p.\n", filter);
EnterCriticalSection(&filter->csFilter); EnterCriticalSection(&filter->csFilter);
filter->state = State_Paused;
if (filter->state == State_Stopped && filter->ops->filter_init_stream)
hr = filter->ops->filter_init_stream(filter);
else if (filter->state == State_Running && filter->ops->filter_stop_stream)
hr = filter->ops->filter_stop_stream(filter);
if (SUCCEEDED(hr))
filter->state = State_Paused;
LeaveCriticalSection(&filter->csFilter); LeaveCriticalSection(&filter->csFilter);
return S_OK; return hr;
} }
HRESULT WINAPI BaseFilterImpl_Run(IBaseFilter *iface, REFERENCE_TIME start) HRESULT WINAPI BaseFilterImpl_Run(IBaseFilter *iface, REFERENCE_TIME start)
{ {
struct strmbase_filter *filter = impl_from_IBaseFilter(iface); struct strmbase_filter *filter = impl_from_IBaseFilter(iface);
HRESULT hr = S_OK;
TRACE("iface %p, start %s.\n", iface, debugstr_time(start)); TRACE("filter %p, start %s.\n", filter, debugstr_time(start));
EnterCriticalSection(&filter->csFilter); EnterCriticalSection(&filter->csFilter);
filter->state = State_Running;
if (filter->state == State_Stopped && filter->ops->filter_init_stream)
hr = filter->ops->filter_init_stream(filter);
if (SUCCEEDED(hr) && filter->ops->filter_start_stream)
hr = filter->ops->filter_start_stream(filter, start);
if (SUCCEEDED(hr))
filter->state = State_Running;
LeaveCriticalSection(&filter->csFilter); LeaveCriticalSection(&filter->csFilter);
return S_OK; return hr;
} }
HRESULT WINAPI BaseFilterImpl_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState ) HRESULT WINAPI BaseFilterImpl_GetState(IBaseFilter *iface, DWORD timeout, FILTER_STATE *state)
{ {
struct strmbase_filter *This = impl_from_IBaseFilter(iface); struct strmbase_filter *filter = impl_from_IBaseFilter(iface);
TRACE("(%p)->(%d, %p)\n", This, dwMilliSecsTimeout, pState); HRESULT hr = S_OK;
EnterCriticalSection(&This->csFilter); TRACE("filter %p, timeout %u, state %p.\n", filter, timeout, state);
{
*pState = This->state;
}
LeaveCriticalSection(&This->csFilter);
return S_OK; EnterCriticalSection(&filter->csFilter);
if (filter->ops->filter_wait_state)
hr = filter->ops->filter_wait_state(filter, timeout);
*state = filter->state;
LeaveCriticalSection(&filter->csFilter);
return hr;
} }
HRESULT WINAPI BaseFilterImpl_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock) HRESULT WINAPI BaseFilterImpl_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)

View File

@ -170,6 +170,12 @@ struct strmbase_filter_ops
IPin *(*filter_get_pin)(struct strmbase_filter *iface, unsigned int index); IPin *(*filter_get_pin)(struct strmbase_filter *iface, unsigned int index);
void (*filter_destroy)(struct strmbase_filter *iface); void (*filter_destroy)(struct strmbase_filter *iface);
HRESULT (*filter_query_interface)(struct strmbase_filter *iface, REFIID iid, void **out); HRESULT (*filter_query_interface)(struct strmbase_filter *iface, REFIID iid, void **out);
HRESULT (*filter_init_stream)(struct strmbase_filter *iface);
HRESULT (*filter_start_stream)(struct strmbase_filter *iface, REFERENCE_TIME time);
HRESULT (*filter_stop_stream)(struct strmbase_filter *iface);
HRESULT (*filter_cleanup_stream)(struct strmbase_filter *iface);
HRESULT (*filter_wait_state)(struct strmbase_filter *iface, DWORD timeout);
}; };
HRESULT WINAPI BaseFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv); HRESULT WINAPI BaseFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv);