Some things to test:
* could we use sample allocator unconditionally? In other words, is it possible to get SVR used when no device manager was provided;
* EVR has a circular buffer logic, so maybe we could copy from there;
* it would be great if we could get rid of locking sample buffer for copies, and that should be possible if we always have d3d samples.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5924#note_88688
Nikolay Sivov (@nsivov) commented about dlls/mfmediaengine/video_frame_sink.c:
> + LONGLONG pts2;
> + transfer_sample = TRUE;
> + /* if the second sample we have is also OK, we'll drop the first and use the second */
> + sample_index_increment(&sample_read_index);
> + if (sink->sample[sample_read_index] && sample_get_pts(sink->sample[sample_read_index], clocktime, &pts2) == S_OK)
> + {
> + *pts = pts2;
> + IMFSample_Release(sink->sample[sink->sample_read_index]);
> + sink->sample[sink->sample_read_index] = NULL;
> + sink->sample_read_index = sample_read_index;
> + }
> + }
> + else if (sink->presentation_sample && !sink->sample_presented)
> + {
> + hr = sample_get_pts(sink->presentation_sample, clocktime, pts);
> + }
I find this hard to understand. We'll need to document what's happening. For example, why does this check one more sample at all? Is that because buffer size is 2, or we always would check the adjacent one.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5924#note_88687
Nikolay Sivov (@nsivov) commented about dlls/mfmediaengine/main.c:
> {
> media_engine_set_flag(engine, FLAGS_ENGINE_SHUT_DOWN, TRUE);
> media_engine_clear_presentation(engine);
> + /* critical section can not be held during shutdown, as shut down requires all pending
> + * callbacks to complete, and some callbacks require this cs */
> + LeaveCriticalSection(&engine->cs);
> IMFMediaSession_Shutdown(engine->session);
> + EnterCriticalSection(&engine->cs);
> }
That's something else, unrelated to SVR work?
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5924#note_88686
Nikolay Sivov (@nsivov) commented about dlls/mfmediaengine/main.c:
>
> IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_ENDED, 0, 0);
> break;
> +
> + case MEEndOfPresentation:
> + video_frame_sink_notify_end_of_presentation(engine->presentation.frame_sink);
> + break;
I think you can use MFSTREAMSINK_MARKER_ENDOFSEGMENT for this. The way you did it sort of bypasses normal session flow, there is potentially unknown number of pending samples in the pipeline once MEEndOfPresentation is received. This is only a problem if for some reason earlier node somehow requests more times than the sink. ENDOFSEGMENT is already used in EVR, and that seems to work.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5924#note_88685
Nikolay Sivov (@nsivov) commented about dlls/mfmediaengine/main.c:
>
> static void free_media_engine(struct media_engine *engine)
> {
> + EnterCriticalSection(&engine->cs);
This helper is called when refcount is already 0, nothing else should be using it at this point.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5924#note_88684