On Mon Dec 8 01:20:03 2025 +0000, Brendan McGrath wrote:
Media Session on Windows seems to have only one sample request (per stream) in flight at a time. So it must have a mechanism for keeping track of the number of requests it has received from a particular sink. In Wine, we currently have [`requests`](https://gitlab.winehq.org/wine/wine/-/blob/5375446b5c6398adaf6d0ee1b8f3564ba...) for each sink to keep track of that. I wonder if we can't just increment that if we know we're not up to the point where we have started the sources, and then make the first sample request once the source is started. We do similar in [`session_flush_sinks`](https://gitlab.winehq.org/wine/wine/-/blob/5375446b5c6398adaf6d0ee1b8f3564ba...). That is we will send a sample request if one is pending. Although I think the decrement there is a bug (as it should only be decremented once the sample is delivered to the sink). Actually, I had a test app already where it was easy for me to modify and test this scenario. It looks like Windows doesn't read from the sink event queue until after it has received the `MENewStream` events. Here's the relevant lines from my test apps log file:
1158.448380|05904|sink_mock_QueueEvent: 305 (MEStreamSinkRequestSample) {00000000-0000-0000-0000-000000000000} (GUID_NULL) 0 <EMPTY>
1158.448966|13744|source_mock_BeginGetEvent:
1158.449218|05904|source_mock_QueueEvent: 205 (MENewStream) {00000000-0000-0000-0000-000000000000} (GUID_NULL) 0 0000019EEF766B08
1158.449235|05904|source_mock_QueueEvent: 201 (MESourceStarted) {00000000-0000-0000-0000-000000000000} (GUID_NULL) 0 0 (20)
1158.449312|13744|source_mock_EndGetEvent: hr: 0, 205 (MENewStream) {00000000-0000-0000-0000-000000000000} (GUID_NULL) 0 0000019EEF766B08
1158.449323|13744|source_mock_BeginGetEvent:
1158.449350|13744|source_mock_EndGetEvent: hr: 0, 201 (MESourceStarted) {00000000-0000-0000-0000-000000000000} (GUID_NULL) 0 0 (20)
1158.449383|13744|source_mock_BeginGetEvent:
1158.449597|05904|sink_mock_BeginGetEvent:
1158.449636|05904|sink_mock_EndGetEvent: hr: 0, 305 (MEStreamSinkRequestSample) {00000000-0000-0000-0000-000000000000} (GUID_NULL) 0 <EMPTY>
You can see the `MEStreamSinkRequestSample` is queued first, but `sink_mock_BeginGetEvent` isn't called until after `source_mock_EndGetEvent` with `MESourceStarted`. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9716#note_125125