mf/session: Do not drop pending commands when clearing current presentation.

Calling Start() short after SetTopology() has a good chance of getting lost,
because clearing logic will drop all pending commands. This is easy to reproduce
with IMFPMediaPlayer, which works reliably on Windows.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-05-28 15:49:02 +03:00 committed by Alexandre Julliard
parent e4e319d032
commit 20a1eb3b25
1 changed files with 13 additions and 8 deletions

View File

@ -855,12 +855,22 @@ static void session_shutdown_current_topology(struct media_session *session)
}
}
static void session_clear_command_list(struct media_session *session)
{
struct session_op *op, *op2;
LIST_FOR_EACH_ENTRY_SAFE(op, op2, &session->commands, struct session_op, entry)
{
list_remove(&op->entry);
IUnknown_Release(&op->IUnknown_iface);
}
}
static void session_clear_presentation(struct media_session *session)
{
struct media_source *source, *source2;
struct media_sink *sink, *sink2;
struct topo_node *node, *node2;
struct session_op *op, *op2;
session_shutdown_current_topology(session);
@ -895,12 +905,6 @@ static void session_clear_presentation(struct media_session *session)
IMFMediaEventGenerator_Release(sink->event_generator);
heap_free(sink);
}
LIST_FOR_EACH_ENTRY_SAFE(op, op2, &session->commands, struct session_op, entry)
{
list_remove(&op->entry);
IUnknown_Release(&op->IUnknown_iface);
}
}
static struct topo_node *session_get_node_by_id(const struct media_session *session, TOPOID id)
@ -1730,6 +1734,7 @@ static ULONG WINAPI mfsession_Release(IMFMediaSession *iface)
{
session_clear_topologies(session);
session_clear_presentation(session);
session_clear_command_list(session);
if (session->presentation.current_topology)
IMFTopology_Release(session->presentation.current_topology);
if (session->event_queue)
@ -1847,7 +1852,6 @@ static HRESULT WINAPI mfsession_Start(IMFMediaSession *iface, const GUID *format
hr = session_submit_command(session, op);
IUnknown_Release(&op->IUnknown_iface);
return hr;
}
@ -1896,6 +1900,7 @@ static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface)
IMFPresentationClock_Release(session->clock);
session->clock = NULL;
session_clear_presentation(session);
session_clear_command_list(session);
}
LeaveCriticalSection(&session->cs);