On Tue Nov 19 07:50:09 2024 +0000, Conor McCarthy wrote:
Thanks for the info. I made a test which shows that `MFUnlockWorkQueue()` does not purge pending items in Windows and instead they are processed. To fix this we need only pass FALSE to `CloseThreadpoolCleanupGroupMembers()`. On top of that, if we delay shutting down the event queue until the source is destroyed, and enqueue events with status MF_E_SHUTDOWN for commands handled after shutdown, it seems to fix the hang. I'll do some more testing. Since we can no longer rely on the event queue tracking shutdown status, we'll need this commit too.
Well that's maybe yet another issue but not what I meant.
What I think is happening is related to the `SESSION_FLAG_PENDING_COMMAND` that is used at https://gitlab.winehq.org/wine/wine/-/blob/master/dlls/mf/session.c?ref_type... to decide whether to append the async call to a list or whether to request a new async call from the thread pool.
The flag is set at https://gitlab.winehq.org/wine/wine/-/blob/master/dlls/mf/session.c?ref_type..., so before processing `SESSION_CMD_START`, which calls BeginGetEvent and Start on the media sources at https://gitlab.winehq.org/wine/wine/-/blob/master/dlls/mf/session.c?ref_type....
If `IMFMediaSource_Start` is returning an error immediately (if the source has been shutdown before the call), the flag is correctly cleared with `session_command_complete_with_event` at https://gitlab.winehq.org/wine/wine/-/blob/master/dlls/mf/session.c?ref_type....
If the call doesn't return an error, but the source is shutdown before it has a chance of executing its async command, the media session never completes its command and never clear that flag because `MESourceStarted` is never received, and `session_set_source_object_state` never called.