On Wed Nov 20 09:13:04 2024 +0000, Conor McCarthy wrote:
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:
- Change `MFUnlockWorkQueue()` to execute all pending commands.
- Keep the event queue alive after source shutdown.
- 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:
- 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?
I don't know, it would need tests to make sure what native behavior is and match it.
From the game usage it doesn't seem to me that shutting down a media source should put the media session in any kind of aborted state. Rather, it looks like it should simply just ignore the error and later keep working normally when ClearTopologies / SetTopology / Start are called with a new topology.
- Keep the event queue alive after source shutdown.
This would need tests, especially in the light of the documentation and example links above.