On Tue Nov 19 14:05:24 2024 +0000, Conor McCarthy wrote:
A test Santino made last year for the same issue in Proton new media source showed that when this case happens in Windows, `MESourceStarted` is sent with a status of `MF_E_SHUTDOWN`. I'll try to make a Wine test which shows that.
I misread the info on the Proton issue; it was for `MESessionStarted`. For the media source in Windows, when `Shutdown()` is called after `Start()`, the `Invoke()` callback is called but `IMFMediaSource::EndGetEvent()` fails with `MF_E_SHUTDOWN`. If we replicate this behaviour then we have notification of the shutdown.
I propose:
1. Change `MFUnlockWorkQueue()` to execute all pending commands. 2. Keep the event queue alive after source shutdown. 3. When a command executes on a shutdown source, we can call `QueueEventParamVar()` with `MESourceStarted` (and others if necessary). Combined with commit b30da09b this results in `Invoke()` being called but `IMFMediaSource::EndGetEvent()` fails just as in Windows. 4. In media session, use `session_events_callback_Invoke()` and subsequent failure of `EndGetEvent()` to detect an abort condition, and call a `session_abort()` helper. 5. Also call `session_abort()` on failure to re-subscribe.
My current implementation of `session_abort()` does:
1. If the session state is `SESSION_STATE_STARTING_SOURCES`, enqueue an `MESessionStarted` with status `MF_E_SHUTDOWN`. 2. Set the state to `ABORTED`. 3. Delete all commands in `session->commands` which are not `CLOSE` or `SHUTDOWN`. 4. Call `session_command_complete()`. 5. In `session_close()`, if the state is `ABORTED`, call `session_command_complete_with_event()` with `MESessionClosed`.
How does that look?