From: R��mi Bernon rbernon@codeweavers.com
--- dlls/mf/session.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 7d46b2c1bdf..abe50aed1d3 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -254,7 +254,10 @@ struct media_session float rate; } presentation; struct list topologies; + + struct session_op *pending_command; struct list commands; + enum session_state state; DWORD caps; CRITICAL_SECTION cs; @@ -470,7 +473,7 @@ static HRESULT session_submit_command(struct media_session *session, struct sess EnterCriticalSection(&session->cs); if (SUCCEEDED(hr = session_is_shut_down(session))) { - if (list_empty(&session->commands)) + if (!session->pending_command && list_empty(&session->commands)) hr = MFPutWorkItem(MFASYNC_CALLBACK_QUEUE_STANDARD, &session->commands_callback, &op->IUnknown_iface); list_add_tail(&session->commands, &op->entry); IUnknown_AddRef(&op->IUnknown_iface); @@ -736,6 +739,12 @@ static void session_clear_command_list(struct media_session *session) { struct session_op *op, *op2;
+ if ((op = session->pending_command)) + { + IUnknown_Release(&op->IUnknown_iface); + session->pending_command = NULL; + } + LIST_FOR_EACH_ENTRY_SAFE(op, op2, &session->commands, struct session_op, entry) { list_remove(&op->entry); @@ -802,12 +811,10 @@ static void session_command_complete(struct media_session *session) struct session_op *op; struct list *e;
- /* Pop current command, submit next. */ - if ((e = list_head(&session->commands))) + if ((op = session->pending_command)) { - op = LIST_ENTRY(e, struct session_op, entry); - list_remove(&op->entry); IUnknown_Release(&op->IUnknown_iface); + session->pending_command = NULL; }
if ((e = list_head(&session->commands))) @@ -2374,6 +2381,9 @@ static HRESULT WINAPI session_commands_callback_Invoke(IMFAsyncCallback *iface,
EnterCriticalSection(&session->cs);
+ list_remove(&op->entry); + session->pending_command = op; + switch (op->command) { case SESSION_CMD_CLEAR_TOPOLOGIES: