mf: Return earlier for clock state change calls when time source is not set.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Nikolay Sivov 2019-10-04 14:42:49 +03:00 committed by Alexandre Julliard
parent 3bd1e1edf7
commit 4e8d7ece69
2 changed files with 20 additions and 4 deletions

View File

@ -1923,6 +1923,9 @@ static HRESULT clock_change_state(struct presentation_clock *clock, enum clock_c
MFTIME system_time;
HRESULT hr;
if (!clock->time_source)
return MF_E_CLOCK_NO_TIME_SOURCE;
if (command != CLOCK_CMD_SET_RATE && clock->state == states[command] && clock->state != MFCLOCK_STATE_RUNNING)
return MF_E_CLOCK_STATE_ALREADY_SET;

View File

@ -1501,6 +1501,9 @@ static void test_presentation_clock(void)
hr = MFCreatePresentationClock(&clock);
ok(hr == S_OK, "Failed to create presentation clock, hr %#x.\n", hr);
hr = IMFPresentationClock_QueryInterface(clock, &IID_IMFRateControl, (void **)&rate_control);
ok(hr == S_OK, "Failed to get rate control interface, hr %#x.\n", hr);
hr = IMFPresentationClock_GetTimeSource(clock, &time_source);
ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
@ -1521,7 +1524,7 @@ static void test_presentation_clock(void)
value = 1;
hr = IMFPresentationClock_GetContinuityKey(clock, &value);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(hr == S_OK, "Failed to get continuity key, hr %#x.\n", hr);
ok(value == 0, "Unexpected value %u.\n", value);
hr = IMFPresentationClock_GetProperties(clock, &props);
@ -1559,6 +1562,19 @@ static void test_presentation_clock(void)
hr = IMFPresentationClock_RemoveClockStateSink(clock, &test_sink);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
/* State change commands, time source is not set yet. */
hr = IMFPresentationClock_Start(clock, 0);
ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
hr = IMFPresentationClock_Pause(clock);
ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
hr = IMFPresentationClock_Stop(clock);
ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
hr = IMFRateControl_SetRate(rate_control, FALSE, 0.0f);
ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
/* Set default time source. */
hr = MFCreateSystemTimeSource(&time_source);
ok(hr == S_OK, "Failed to create time source, hr %#x.\n", hr);
@ -1631,9 +1647,6 @@ static void test_presentation_clock(void)
IMFPresentationTimeSource_Release(time_source);
hr = IMFPresentationClock_QueryInterface(clock, &IID_IMFRateControl, (void **)&rate_control);
ok(hr == S_OK, "Failed to get rate control interface, hr %#x.\n", hr);
hr = IMFRateControl_GetRate(rate_control, NULL, &rate);
ok(hr == S_OK, "Failed to get clock rate, hr %#x.\n", hr);