[PATCH 0/2] MR8185: mf/samplegrabber: Initialize state -> event map in a more robust way.
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8185
From: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/mf/samplegrabber.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/mf/samplegrabber.c b/dlls/mf/samplegrabber.c index 016c68f98b8..964f4e9001e 100644 --- a/dlls/mf/samplegrabber.c +++ b/dlls/mf/samplegrabber.c @@ -1170,9 +1170,9 @@ static HRESULT sample_grabber_set_state(struct sample_grabber *grabber, enum sin { static const DWORD events[] = { - MEStreamSinkStopped, /* SINK_STATE_STOPPED */ - MEStreamSinkPaused, /* SINK_STATE_PAUSED */ - MEStreamSinkStarted, /* SINK_STATE_RUNNING */ + [SINK_STATE_STOPPED] = MEStreamSinkStopped, + [SINK_STATE_PAUSED] = MEStreamSinkPaused, + [SINK_STATE_RUNNING] = MEStreamSinkStarted, }; BOOL do_callback = FALSE; HRESULT hr = S_OK; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8185
From: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/mf/clock.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/dlls/mf/clock.c b/dlls/mf/clock.c index e6be05d2794..997994fc5f9 100644 --- a/dlls/mf/clock.c +++ b/dlls/mf/clock.c @@ -473,10 +473,9 @@ static HRESULT WINAPI present_clock_AddClockStateSink(IMFPresentationClock *ifac { static const enum clock_notification notifications[MFCLOCK_STATE_PAUSED + 1] = { - /* MFCLOCK_STATE_INVALID */ 0, /* Does not apply */ - /* MFCLOCK_STATE_RUNNING */ CLOCK_NOTIFY_START, - /* MFCLOCK_STATE_STOPPED */ CLOCK_NOTIFY_STOP, - /* MFCLOCK_STATE_PAUSED */ CLOCK_NOTIFY_PAUSE, + [MFCLOCK_STATE_RUNNING] = CLOCK_NOTIFY_START, + [MFCLOCK_STATE_STOPPED] = CLOCK_NOTIFY_STOP, + [MFCLOCK_STATE_PAUSED] = CLOCK_NOTIFY_PAUSE, }; struct clock_state_change_param param; @@ -559,26 +558,18 @@ static HRESULT clock_call_state_change(MFTIME system_time, struct clock_state_ch static HRESULT clock_change_state(struct presentation_clock *clock, enum clock_command command, struct clock_state_change_param param) { - static const BYTE state_change_is_allowed[MFCLOCK_STATE_PAUSED+1][CLOCK_CMD_MAX] = - { /* S S* P, R */ - /* INVALID */ { 1, 1, 1, 1 }, - /* RUNNING */ { 1, 1, 1, 1 }, - /* STOPPED */ { 1, 1, 0, 1 }, - /* PAUSED */ { 1, 1, 0, 1 }, - }; static const MFCLOCK_STATE states[CLOCK_CMD_MAX] = { - /* CLOCK_CMD_START */ MFCLOCK_STATE_RUNNING, - /* CLOCK_CMD_STOP */ MFCLOCK_STATE_STOPPED, - /* CLOCK_CMD_PAUSE */ MFCLOCK_STATE_PAUSED, - /* CLOCK_CMD_SET_RATE */ 0, /* Unused */ + [CLOCK_CMD_START] = MFCLOCK_STATE_RUNNING, + [CLOCK_CMD_STOP] = MFCLOCK_STATE_STOPPED, + [CLOCK_CMD_PAUSE] = MFCLOCK_STATE_PAUSED, }; static const enum clock_notification notifications[CLOCK_CMD_MAX] = { - /* CLOCK_CMD_START */ CLOCK_NOTIFY_START, - /* CLOCK_CMD_STOP */ CLOCK_NOTIFY_STOP, - /* CLOCK_CMD_PAUSE */ CLOCK_NOTIFY_PAUSE, - /* CLOCK_CMD_SET_RATE */ CLOCK_NOTIFY_SET_RATE, + [CLOCK_CMD_START] = CLOCK_NOTIFY_START, + [CLOCK_CMD_STOP] = CLOCK_NOTIFY_STOP, + [CLOCK_CMD_PAUSE] = CLOCK_NOTIFY_PAUSE, + [CLOCK_CMD_SET_RATE] = CLOCK_NOTIFY_SET_RATE, }; enum clock_notification notification; struct clock_sink *sink; @@ -593,7 +584,8 @@ static HRESULT clock_change_state(struct presentation_clock *clock, enum clock_c if (command != CLOCK_CMD_SET_RATE && clock->state == states[command] && clock->state != MFCLOCK_STATE_RUNNING) return MF_E_CLOCK_STATE_ALREADY_SET; - if (!state_change_is_allowed[clock->state][command]) + /* Invalid transitions. */ + if (command == CLOCK_CMD_PAUSE && (clock->state == MFCLOCK_STATE_STOPPED || clock->state == MFCLOCK_STATE_PAUSED)) return MF_E_INVALIDREQUEST; system_time = MFGetSystemTime(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8185
participants (2)
-
Nikolay Sivov -
Nikolay Sivov (@nsivov)