Nikolay Sivov : mf: Maintain sample grabber sink state.

Alexandre Julliard julliard at winehq.org
Thu May 30 16:27:13 CDT 2019


Module: wine
Branch: master
Commit: 2dba94b27816fa3633744eecb3898ba3cee58d8f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2dba94b27816fa3633744eecb3898ba3cee58d8f

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu May 30 14:46:13 2019 +0300

mf: Maintain sample grabber sink state.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mf/samplegrabber.c | 68 +++++++++++++++++++++++++++++++++++++++++++------
 include/mfidl.idl       |  3 +++
 2 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/dlls/mf/samplegrabber.c b/dlls/mf/samplegrabber.c
index d501e08..e2766c0 100644
--- a/dlls/mf/samplegrabber.c
+++ b/dlls/mf/samplegrabber.c
@@ -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)
diff --git a/include/mfidl.idl b/include/mfidl.idl
index 2421c06..93e20a6 100644
--- a/include/mfidl.idl
+++ b/include/mfidl.idl
@@ -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);")




More information about the wine-cvs mailing list