Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 14 ++++++++++++-- dlls/mf/tests/mf.c | 1 - 2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index e92ae401f6..0c283c4392 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -62,6 +62,7 @@ struct media_session IMFMediaEventQueue *event_queue; IMFPresentationClock *clock; struct list topologies; + BOOL is_shut_down; CRITICAL_SECTION cs; };
@@ -412,12 +413,21 @@ static HRESULT WINAPI mfsession_Close(IMFMediaSession *iface) static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface) { struct media_session *session = impl_from_IMFMediaSession(iface); + HRESULT hr = S_OK;
FIXME("(%p)\n", iface);
- IMFMediaEventQueue_Shutdown(session->event_queue); + EnterCriticalSection(&session->cs); + if (session->is_shut_down) + hr = MF_E_SHUTDOWN; + else + { + session->is_shut_down = TRUE; + IMFMediaEventQueue_Shutdown(session->event_queue); + } + LeaveCriticalSection(&session->cs);
- return E_NOTIMPL; + return hr; }
static HRESULT WINAPI mfsession_GetClock(IMFMediaSession *iface, IMFClock **clock) diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index f37ac7c3ff..bae80203c5 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -944,7 +944,6 @@ static void test_session_events(IMFMediaSession *session)
/* Shutdown behavior. */ hr = IMFMediaSession_Shutdown(session); -todo_wine ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 55 ++++++++++++++++++++++++++++++++++++++-------- dlls/mf/tests/mf.c | 11 ++++++++++ 2 files changed, 57 insertions(+), 9 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 0c283c4392..76573c9f44 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -35,7 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
enum session_command { - SESSION_CLEAR_TOPOLOGIES, + SESSION_CMD_CLEAR_TOPOLOGIES, + SESSION_CMD_CLOSE, };
struct session_op @@ -51,6 +52,13 @@ struct queued_topology IMFTopology *topology; };
+enum session_state +{ + SESSION_STATE_STOPPED = 0, + SESSION_STATE_CLOSED, + SESSION_STATE_SHUT_DOWN, +}; + struct media_session { IMFMediaSession IMFMediaSession_iface; @@ -62,7 +70,7 @@ struct media_session IMFMediaEventQueue *event_queue; IMFPresentationClock *clock; struct list topologies; - BOOL is_shut_down; + enum session_state state; CRITICAL_SECTION cs; };
@@ -362,7 +370,16 @@ static HRESULT WINAPI mfsession_SetTopology(IMFMediaSession *iface, DWORD flags,
static HRESULT session_submit_command(struct media_session *session, IUnknown *op) { - return MFPutWorkItem(MFASYNC_CALLBACK_QUEUE_STANDARD, &session->commands_callback, op); + HRESULT hr; + + EnterCriticalSection(&session->cs); + if (session->state == SESSION_STATE_SHUT_DOWN) + hr = MF_E_SHUTDOWN; + else + hr = MFPutWorkItem(MFASYNC_CALLBACK_QUEUE_STANDARD, &session->commands_callback, op); + LeaveCriticalSection(&session->cs); + + return hr; }
static HRESULT WINAPI mfsession_ClearTopologies(IMFMediaSession *iface) @@ -373,7 +390,7 @@ static HRESULT WINAPI mfsession_ClearTopologies(IMFMediaSession *iface)
TRACE("%p.\n", iface);
- if (FAILED(hr = create_session_op(SESSION_CLEAR_TOPOLOGIES, &op))) + if (FAILED(hr = create_session_op(SESSION_CMD_CLEAR_TOPOLOGIES, &op))) return hr;
hr = session_submit_command(session, op); @@ -405,9 +422,19 @@ static HRESULT WINAPI mfsession_Stop(IMFMediaSession *iface)
static HRESULT WINAPI mfsession_Close(IMFMediaSession *iface) { - FIXME("(%p)\n", iface); + struct media_session *session = impl_from_IMFMediaSession(iface); + IUnknown *op; + HRESULT hr;
- return S_OK; + TRACE("(%p)\n", iface); + + if (FAILED(hr = create_session_op(SESSION_CMD_CLOSE, &op))) + return hr; + + hr = session_submit_command(session, op); + IUnknown_Release(op); + + return hr; }
static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface) @@ -418,11 +445,11 @@ static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface) FIXME("(%p)\n", iface);
EnterCriticalSection(&session->cs); - if (session->is_shut_down) + if (session->state == SESSION_STATE_SHUT_DOWN) hr = MF_E_SHUTDOWN; else { - session->is_shut_down = TRUE; + session->state = SESSION_STATE_SHUT_DOWN; IMFMediaEventQueue_Shutdown(session->event_queue); } LeaveCriticalSection(&session->cs); @@ -572,7 +599,7 @@ static HRESULT WINAPI session_commands_callback_Invoke(IMFAsyncCallback *iface,
switch (op->command) { - case SESSION_CLEAR_TOPOLOGIES: + case SESSION_CMD_CLEAR_TOPOLOGIES: EnterCriticalSection(&session->cs); session_clear_topologies(session); LeaveCriticalSection(&session->cs); @@ -580,6 +607,16 @@ static HRESULT WINAPI session_commands_callback_Invoke(IMFAsyncCallback *iface, IMFMediaEventQueue_QueueEventParamVar(session->event_queue, MESessionTopologiesCleared, &GUID_NULL, S_OK, NULL); break; + case SESSION_CMD_CLOSE: + EnterCriticalSection(&session->cs); + if (session->state != SESSION_STATE_CLOSED) + { + /* FIXME: actually do something to presentation objects */ + session->state = SESSION_STATE_CLOSED; + IMFMediaEventQueue_QueueEventParamVar(session->event_queue, MESessionClosed, &GUID_NULL, S_OK, NULL); + } + LeaveCriticalSection(&session->cs); + break; default: ; } diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index bae80203c5..39a049000f 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1000,6 +1000,17 @@ static void test_media_session(void)
IMFMediaSession_Release(session);
+ hr = MFCreateMediaSession(NULL, &session); + ok(hr == S_OK, "Failed to create media session, hr %#x.\n", hr); + + hr = IMFMediaSession_Shutdown(session); + ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); + + hr = IMFMediaSession_Close(session); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + + IMFMediaSession_Release(session); + hr = MFShutdown(); ok(hr == S_OK, "Shutdown failure, hr %#x.\n", hr); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 14 ++++++++++++-- dlls/mf/tests/mf.c | 11 ++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 76573c9f44..9c2826f8e5 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -841,9 +841,19 @@ static ULONG WINAPI present_clock_Release(IMFPresentationClock *iface)
static HRESULT WINAPI present_clock_GetClockCharacteristics(IMFPresentationClock *iface, DWORD *flags) { - FIXME("%p, %p.\n", iface, flags); + struct presentation_clock *clock = impl_from_IMFPresentationClock(iface); + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %p.\n", iface, flags); + + EnterCriticalSection(&clock->cs); + if (clock->time_source) + hr = IMFPresentationTimeSource_GetClockCharacteristics(clock->time_source, flags); + else + hr = MF_E_CLOCK_NO_TIME_SOURCE; + LeaveCriticalSection(&clock->cs); + + return hr; }
static HRESULT WINAPI present_clock_GetCorrelatedTime(IMFPresentationClock *iface, DWORD reserved, diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 39a049000f..e07c82486b 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1449,7 +1449,6 @@ static void test_presentation_clock(void) ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
hr = IMFPresentationClock_GetClockCharacteristics(clock, &value); -todo_wine ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
value = 1; @@ -1491,9 +1490,19 @@ todo_wine hr = MFCreateSystemTimeSource(&time_source); ok(hr == S_OK, "Failed to create time source, hr %#x.\n", hr);
+ hr = IMFPresentationTimeSource_GetClockCharacteristics(time_source, &value); + ok(hr == S_OK, "Failed to get time source flags, hr %#x.\n", hr); + ok(value == (MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ | MFCLOCK_CHARACTERISTICS_FLAG_IS_SYSTEM_CLOCK), + "Unexpected clock flags %#x.\n", value); + hr = IMFPresentationClock_SetTimeSource(clock, time_source); ok(hr == S_OK, "Failed to set time source, hr %#x.\n", hr);
+ hr = IMFPresentationClock_GetClockCharacteristics(clock, &value); + ok(hr == S_OK, "Failed to get clock flags, hr %#x.\n", hr); + ok(value == (MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ | MFCLOCK_CHARACTERISTICS_FLAG_IS_SYSTEM_CLOCK), + "Unexpected clock flags %#x.\n", value); + /* State changes. */ for (i = 0; i < ARRAY_SIZE(clock_state_change); ++i) {
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 7 +------ dlls/mf/tests/mf.c | 9 ++++++++- 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 9c2826f8e5..14aac77470 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -894,15 +894,10 @@ static HRESULT WINAPI present_clock_GetProperties(IMFPresentationClock *iface, M TRACE("%p, %p.\n", iface, props);
EnterCriticalSection(&clock->cs); - if (clock->time_source) - { - FIXME("%p, %p.\n", iface, props); - hr = E_NOTIMPL; - } + hr = IMFPresentationTimeSource_GetProperties(clock->time_source, props); else hr = MF_E_CLOCK_NO_TIME_SOURCE; - LeaveCriticalSection(&clock->cs);
return hr; diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index e07c82486b..b710d0a13d 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1427,9 +1427,9 @@ static void test_presentation_clock(void) }; IMFClockStateSink test_sink = { &test_clock_sink_vtbl }; IMFPresentationTimeSource *time_source; + MFCLOCK_PROPERTIES props, props2; IMFRateControl *rate_control; IMFPresentationClock *clock; - MFCLOCK_PROPERTIES props; IMFShutdown *shutdown; LONGLONG clock_time; MFCLOCK_STATE state; @@ -1498,11 +1498,18 @@ todo_wine hr = IMFPresentationClock_SetTimeSource(clock, time_source); ok(hr == S_OK, "Failed to set time source, hr %#x.\n", hr);
+ hr = IMFPresentationTimeSource_GetProperties(time_source, &props2); + ok(hr == S_OK, "Failed to get time source properties, hr %#x.\n", hr); + hr = IMFPresentationClock_GetClockCharacteristics(clock, &value); ok(hr == S_OK, "Failed to get clock flags, hr %#x.\n", hr); ok(value == (MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ | MFCLOCK_CHARACTERISTICS_FLAG_IS_SYSTEM_CLOCK), "Unexpected clock flags %#x.\n", value);
+ hr = IMFPresentationClock_GetProperties(clock, &props); + ok(hr == S_OK, "Failed to get clock properties, hr %#x.\n", hr); + ok(!memcmp(&props, &props2, sizeof(props)), "Unexpected clock properties.\n"); + /* State changes. */ for (i = 0; i < ARRAY_SIZE(clock_state_change); ++i) {
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 27 +++++++++++++++++++-------- dlls/mf/tests/mf.c | 28 +++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 14aac77470..be5ea642d4 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -842,15 +842,13 @@ static ULONG WINAPI present_clock_Release(IMFPresentationClock *iface) static HRESULT WINAPI present_clock_GetClockCharacteristics(IMFPresentationClock *iface, DWORD *flags) { struct presentation_clock *clock = impl_from_IMFPresentationClock(iface); - HRESULT hr; + HRESULT hr = MF_E_CLOCK_NO_TIME_SOURCE;
TRACE("%p, %p.\n", iface, flags);
EnterCriticalSection(&clock->cs); if (clock->time_source) hr = IMFPresentationTimeSource_GetClockCharacteristics(clock->time_source, flags); - else - hr = MF_E_CLOCK_NO_TIME_SOURCE; LeaveCriticalSection(&clock->cs);
return hr; @@ -889,15 +887,13 @@ static HRESULT WINAPI present_clock_GetState(IMFPresentationClock *iface, DWORD static HRESULT WINAPI present_clock_GetProperties(IMFPresentationClock *iface, MFCLOCK_PROPERTIES *props) { struct presentation_clock *clock = impl_from_IMFPresentationClock(iface); - HRESULT hr; + HRESULT hr = MF_E_CLOCK_NO_TIME_SOURCE;
TRACE("%p, %p.\n", iface, props);
EnterCriticalSection(&clock->cs); if (clock->time_source) hr = IMFPresentationTimeSource_GetProperties(clock->time_source, props); - else - hr = MF_E_CLOCK_NO_TIME_SOURCE; LeaveCriticalSection(&clock->cs);
return hr; @@ -939,6 +935,9 @@ static HRESULT WINAPI present_clock_GetTimeSource(IMFPresentationClock *iface,
TRACE("%p, %p.\n", iface, time_source);
+ if (!time_source) + return E_INVALIDARG; + EnterCriticalSection(&clock->cs); if (clock->time_source) { @@ -954,9 +953,21 @@ static HRESULT WINAPI present_clock_GetTimeSource(IMFPresentationClock *iface,
static HRESULT WINAPI present_clock_GetTime(IMFPresentationClock *iface, MFTIME *time) { - FIXME("%p, %p.\n", iface, time); + struct presentation_clock *clock = impl_from_IMFPresentationClock(iface); + HRESULT hr = MF_E_CLOCK_NO_TIME_SOURCE; + MFTIME systime;
- return E_NOTIMPL; + TRACE("%p, %p.\n", iface, time); + + if (!time) + return E_POINTER; + + EnterCriticalSection(&clock->cs); + if (clock->time_source) + hr = IMFPresentationTimeSource_GetCorrelatedTime(clock->time_source, 0, time, &systime); + LeaveCriticalSection(&clock->cs); + + return hr; }
static HRESULT WINAPI present_clock_AddClockStateSink(IMFPresentationClock *iface, IMFClockStateSink *state_sink) diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index b710d0a13d..dc58dc1efd 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1431,10 +1431,10 @@ static void test_presentation_clock(void) IMFRateControl *rate_control; IMFPresentationClock *clock; IMFShutdown *shutdown; + MFTIME systime, time; LONGLONG clock_time; MFCLOCK_STATE state; IMFTimer *timer; - MFTIME systime; unsigned int i; DWORD value; HRESULT hr; @@ -1448,9 +1448,21 @@ static void test_presentation_clock(void) hr = IMFPresentationClock_GetTimeSource(clock, &time_source); ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
+ hr = IMFPresentationClock_GetTimeSource(clock, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + hr = IMFPresentationClock_GetClockCharacteristics(clock, &value); ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
+ hr = IMFPresentationClock_GetClockCharacteristics(clock, NULL); + ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr); + + hr = IMFPresentationClock_GetTime(clock, &time); + ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr); + + hr = IMFPresentationClock_GetTime(clock, NULL); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + value = 1; hr = IMFPresentationClock_GetContinuityKey(clock, &value); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); @@ -1538,6 +1550,20 @@ todo_wine ok(state == clock_state_change[i].clock_state, "%u: unexpected state %d.\n", i, state); }
+ /* Clock time stamps. */ + hr = IMFPresentationClock_Start(clock, 10); + ok(hr == S_OK, "Failed to start presentation clock, hr %#x.\n", hr); + + hr = IMFPresentationClock_Pause(clock); + ok(hr == S_OK, "Failed to pause presentation clock, hr %#x.\n", hr); + + hr = IMFPresentationClock_GetTime(clock, &time); + ok(hr == S_OK, "Failed to get clock time, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &clock_time, &systime); + ok(hr == S_OK, "Failed to get time source time, hr %#x.\n", hr); + ok(time == clock_time, "Unexpected clock time.\n"); + IMFPresentationTimeSource_Release(time_source);
hr = IMFPresentationClock_QueryInterface(clock, &IID_IMFRateControl, (void **)&rate_control);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 12 ++++++++++-- dlls/mf/tests/mf.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index be5ea642d4..8e41942448 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -857,9 +857,17 @@ static HRESULT WINAPI present_clock_GetClockCharacteristics(IMFPresentationClock static HRESULT WINAPI present_clock_GetCorrelatedTime(IMFPresentationClock *iface, DWORD reserved, LONGLONG *clock_time, MFTIME *system_time) { - FIXME("%p, %#x, %p, %p.\n", iface, reserved, clock_time, system_time); + struct presentation_clock *clock = impl_from_IMFPresentationClock(iface); + HRESULT hr = MF_E_CLOCK_NO_TIME_SOURCE;
- return E_NOTIMPL; + TRACE("%p, %#x, %p, %p.\n", iface, reserved, clock_time, system_time); + + EnterCriticalSection(&clock->cs); + if (clock->time_source) + hr = IMFPresentationTimeSource_GetCorrelatedTime(clock->time_source, reserved, clock_time, system_time); + LeaveCriticalSection(&clock->cs); + + return hr; }
static HRESULT WINAPI present_clock_GetContinuityKey(IMFPresentationClock *iface, DWORD *key) diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index dc58dc1efd..8f9a97d497 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1476,7 +1476,12 @@ static void test_presentation_clock(void) ok(state == MFCLOCK_STATE_INVALID, "Unexpected state %d.\n", state);
hr = IMFPresentationClock_GetCorrelatedTime(clock, 0, &clock_time, &systime); -todo_wine + ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr); + + hr = IMFPresentationClock_GetCorrelatedTime(clock, 0, NULL, &systime); + ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr); + + hr = IMFPresentationClock_GetCorrelatedTime(clock, 0, &time, NULL); ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
/* Sinks. */ @@ -1564,6 +1569,10 @@ todo_wine ok(hr == S_OK, "Failed to get time source time, hr %#x.\n", hr); ok(time == clock_time, "Unexpected clock time.\n");
+ hr = IMFPresentationClock_GetCorrelatedTime(clock, 0, &time, &systime); + ok(hr == S_OK, "Failed to get clock time, hr %#x.\n", hr); + ok(time == clock_time, "Unexpected clock time.\n"); + IMFPresentationTimeSource_Release(time_source);
hr = IMFPresentationClock_QueryInterface(clock, &IID_IMFRateControl, (void **)&rate_control);