mf: Maintain sample grabber sink state.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
828ac9880d
commit
2dba94b278
|
@ -28,6 +28,12 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
|
||||
|
||||
enum sink_state
|
||||
{
|
||||
SINK_STATE_STOPPED = 0,
|
||||
SINK_STATE_RUNNING,
|
||||
};
|
||||
|
||||
struct sample_grabber;
|
||||
|
||||
struct sample_grabber_stream
|
||||
|
@ -51,6 +57,7 @@ struct sample_grabber
|
|||
struct sample_grabber_stream *stream;
|
||||
IMFMediaEventQueue *event_queue;
|
||||
IMFPresentationClock *clock;
|
||||
enum sink_state state;
|
||||
CRITICAL_SECTION cs;
|
||||
};
|
||||
|
||||
|
@ -685,32 +692,77 @@ static ULONG WINAPI sample_grabber_clock_sink_Release(IMFClockStateSink *iface)
|
|||
return IMFMediaSink_Release(&grabber->IMFMediaSink_iface);
|
||||
}
|
||||
|
||||
static void sample_grabber_set_state(struct sample_grabber *grabber, enum sink_state state)
|
||||
{
|
||||
static const DWORD events[] =
|
||||
{
|
||||
MEStreamSinkStopped, /* SINK_STATE_STOPPED */
|
||||
MEStreamSinkStarted, /* SINK_STATE_RUNNING */
|
||||
};
|
||||
BOOL set_state = FALSE;
|
||||
|
||||
EnterCriticalSection(&grabber->cs);
|
||||
|
||||
switch (grabber->state)
|
||||
{
|
||||
case SINK_STATE_STOPPED:
|
||||
set_state = state == SINK_STATE_RUNNING;
|
||||
break;
|
||||
case SINK_STATE_RUNNING:
|
||||
set_state = state == SINK_STATE_STOPPED;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
if (set_state)
|
||||
{
|
||||
grabber->state = state;
|
||||
if (grabber->stream)
|
||||
IMFStreamSink_QueueEvent(&grabber->stream->IMFStreamSink_iface, events[state], &GUID_NULL, S_OK, NULL);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&grabber->cs);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_clock_sink_OnClockStart(IMFClockStateSink *iface, MFTIME systime, LONGLONG offset)
|
||||
{
|
||||
FIXME("%p, %s, %s.\n", iface, wine_dbgstr_longlong(systime), wine_dbgstr_longlong(offset));
|
||||
struct sample_grabber *grabber = impl_from_IMFClockStateSink(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p, %s, %s.\n", iface, wine_dbgstr_longlong(systime), wine_dbgstr_longlong(offset));
|
||||
|
||||
sample_grabber_set_state(grabber, SINK_STATE_RUNNING);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_clock_sink_OnClockStop(IMFClockStateSink *iface, MFTIME systime)
|
||||
{
|
||||
FIXME("%p, %s.\n", iface, wine_dbgstr_longlong(systime));
|
||||
struct sample_grabber *grabber = impl_from_IMFClockStateSink(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(systime));
|
||||
|
||||
sample_grabber_set_state(grabber, SINK_STATE_STOPPED);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_clock_sink_OnClockPause(IMFClockStateSink *iface, MFTIME systime)
|
||||
{
|
||||
FIXME("%p, %s.\n", iface, wine_dbgstr_longlong(systime));
|
||||
TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(systime));
|
||||
|
||||
return E_NOTIMPL;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_clock_sink_OnClockRestart(IMFClockStateSink *iface, MFTIME systime)
|
||||
{
|
||||
FIXME("%p, %s.\n", iface, wine_dbgstr_longlong(systime));
|
||||
struct sample_grabber *grabber = impl_from_IMFClockStateSink(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(systime));
|
||||
|
||||
sample_grabber_set_state(grabber, SINK_STATE_RUNNING);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_clock_sink_OnClockSetRate(IMFClockStateSink *iface, MFTIME systime, float rate)
|
||||
|
|
|
@ -820,3 +820,6 @@ cpp_quote("EXTERN_GUID(MF_TOPOLOGY_START_TIME_ON_PRESENTATION_SWITCH, 0xc8cc113f
|
|||
cpp_quote("EXTERN_GUID(MF_TOPOLOGY_STATIC_PLAYBACK_OPTIMIZATIONS, 0xb86cac42, 0x41a6, 0x4b79, 0x89, 0x7a, 0x1a, 0xb0, 0xe5, 0x2b, 0x4a, 0x1b);")
|
||||
|
||||
cpp_quote("EXTERN_GUID(MF_RATE_CONTROL_SERVICE, 0x866fa297, 0xb802, 0x4bf8, 0x9d, 0xc9, 0x5e, 0x3b, 0x6a, 0x9f, 0x53, 0xc9);")
|
||||
|
||||
cpp_quote("EXTERN_GUID(MF_SAMPLEGRABBERSINK_SAMPLE_TIME_OFFSET, 0x62e3d776, 0x8100, 0x4e03, 0xa6, 0xe8, 0xbd, 0x38, 0x57, 0xac, 0x9c, 0x47);")
|
||||
cpp_quote("EXTERN_GUID(MF_SAMPLEGRABBERSINK_IGNORE_CLOCK, 0x0efda2c0, 0x2b69, 0x4e2e, 0xab, 0x8d, 0x46, 0xdc, 0xbf, 0xf7, 0xd2, 0x5d);")
|
||||
|
|
Loading…
Reference in New Issue