[PATCH v2 0/2] MR10306: mfmediaengine: Implement looping behaviour.
When `IMFMediaEngine::SetLoop(TRUE)` is called, media engine will repeatedly loop the video. -- v2: mfmediaengine: Implement looping behaviour. https://gitlab.winehq.org/wine/wine/-/merge_requests/10306
From: Brendan McGrath <bmcgrath@codeweavers.com> When a sink is stopped, all pending requests are discarded by the client (for example IMFMediaSession). --- dlls/mfmediaengine/video_frame_sink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/mfmediaengine/video_frame_sink.c b/dlls/mfmediaengine/video_frame_sink.c index f710466fed4..301a2bcd03a 100644 --- a/dlls/mfmediaengine/video_frame_sink.c +++ b/dlls/mfmediaengine/video_frame_sink.c @@ -1010,6 +1010,7 @@ static HRESULT video_frame_sink_set_state(struct video_frame_sink *sink, enum si { video_frame_sink_sample_queue_flush(sink); video_frame_sink_set_flag(sink, FLAGS_FIRST_FRAME, FALSE); + sink->sample_request_pending = FALSE; } if (state == SINK_STATE_RUNNING && (sink->state == SINK_STATE_STOPPED || sink->state == SINK_STATE_PAUSED || -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10306
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/mfmediaengine/main.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c index 2ababd674d7..63f865e7d9a 100644 --- a/dlls/mfmediaengine/main.c +++ b/dlls/mfmediaengine/main.c @@ -1008,14 +1008,19 @@ static HRESULT WINAPI media_engine_session_events_Invoke(IMFAsyncCallback *iface IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PLAYING, 0, 0); break; case MESessionEnded: - EnterCriticalSection(&engine->cs); - media_engine_set_flag(engine, FLAGS_ENGINE_FIRST_FRAME, FALSE); - media_engine_set_flag(engine, FLAGS_ENGINE_IS_ENDED, TRUE); - engine->video_frame.pts = MINLONGLONG; + if (engine->flags & FLAGS_ENGINE_LOOP) + { + media_engine_set_current_time(engine, 0.0); + } + else + { + engine->video_frame.pts = MINLONGLONG; + media_engine_set_flag(engine, FLAGS_ENGINE_FIRST_FRAME, FALSE); + media_engine_set_flag(engine, FLAGS_ENGINE_IS_ENDED, TRUE); + IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_ENDED, 0, 0); + } LeaveCriticalSection(&engine->cs); - - IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_ENDED, 0, 0); break; case MEEndOfPresentationSegment: -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10306
On Thu Mar 12 15:06:47 2026 +0000, Nikolay Sivov wrote:
There are now two leave's for one enter. Thanks for catching that. I thought I had removed it. I have removed it now.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10306#note_132073
v2: - Remove duplicate `LeaveCriticalSection` from the else path -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10306#note_132074
But this way it will be sending callback inside the critical section. Is that intentional? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10306#note_132075
On Thu Mar 12 18:48:27 2026 +0000, Paul Gofman wrote:
But this way it will be sending callback inside the critical section. Is that intentional? Yes. I originally had two `LeaveCriticalSection` (one for each path) but decided that was unnecessary as the `IMFMediaEngineNotify_EventNotify` simply writes the event to a queue (thus is brief). But seems I only removed the one `LeaveCriticalSection` when I made that change.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10306#note_132076
On Thu Mar 12 18:48:27 2026 +0000, Brendan McGrath wrote:
Yes. I originally had two `LeaveCriticalSection` (one for each path) but decided that was unnecessary as the `IMFMediaEngineNotify_EventNotify` simply writes the event to a queue (thus is brief). But seems I only removed the one `LeaveCriticalSection` when I made that change. There is no queue, it's a user callback. Please leave it the way it was, I believe I tested this manually before.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10306#note_132077
participants (4)
-
Brendan McGrath -
Brendan McGrath (@redmcg) -
Nikolay Sivov (@nsivov) -
Paul Gofman (@gofman)