Split from https://gitlab.winehq.org/wine/wine/-/merge_requests/874, as it's fairly unrelated. This alone should fix mfmediaengine tests frequent crashes. They don't cause the test pipeline to fail, but they render the tests pretty much void.
From: Rémi Bernon rbernon@codeweavers.com
This fixes a random crash with mfmediaengine tests, which quickly starts then shuts down a media session. --- dlls/mf/session.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 8be3ffcd7f3..b410a5fe861 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -47,6 +47,7 @@ enum session_command SESSION_CMD_PAUSE, SESSION_CMD_STOP, SESSION_CMD_SET_RATE, + SESSION_CMD_SHUTDOWN, };
struct session_op @@ -460,7 +461,10 @@ static HRESULT session_submit_command(struct media_session *session, struct sess { if (list_empty(&session->commands) && !(session->presentation.flags & SESSION_FLAG_PENDING_COMMAND)) hr = MFPutWorkItem(MFASYNC_CALLBACK_QUEUE_STANDARD, &session->commands_callback, &op->IUnknown_iface); - list_add_tail(&session->commands, &op->entry); + if (op->command == SESSION_CMD_SHUTDOWN) + list_add_head(&session->commands, &op->entry); + else + list_add_tail(&session->commands, &op->entry); IUnknown_AddRef(&op->IUnknown_iface); } LeaveCriticalSection(&session->cs); @@ -2041,7 +2045,7 @@ static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface) IMFPresentationClock_Release(session->clock); session->clock = NULL; session_clear_presentation(session); - session_clear_command_list(session); + session_submit_simple_command(session, SESSION_CMD_SHUTDOWN); } LeaveCriticalSection(&session->cs);
@@ -2383,6 +2387,10 @@ static HRESULT WINAPI session_commands_callback_Invoke(IMFAsyncCallback *iface, case SESSION_CMD_SET_RATE: session_set_rate(session, op->set_rate.thin, op->set_rate.rate); break; + case SESSION_CMD_SHUTDOWN: + session_clear_command_list(session); + session_command_complete(session); + break; default: ; }
This looks fine (or safe?), but could you explain what is crashing exactly? Is it because the list is cleared right away, but some earlier async command could still reach Invoke() ?
On Sun Oct 2 22:01:26 2022 +0000, Nikolay Sivov wrote:
This looks fine (or safe?), but could you explain what is crashing exactly? Is it because the list is cleared right away, but some earlier async command could still reach Invoke() ?
Yes, and then the command is removed twice from the list.
This merge request was approved by Nikolay Sivov.