From: Rémi Bernon rbernon@codeweavers.com
Fixes some stuttering in Secret of Mana.
Native seems to only preroll 2 samples, but it still stutters a bit in Secret of Mana without at least 3 buffers. This is probably caused by a different sample decoding pattern, and 3 buffers in flight should be fine. --- dlls/mf/evr.c | 15 ++++++++++++--- dlls/mf/session.c | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/mf/evr.c b/dlls/mf/evr.c index db7053a1405..5ac526c9651 100644 --- a/dlls/mf/evr.c +++ b/dlls/mf/evr.c @@ -64,6 +64,7 @@ struct video_stream LONG refcount; unsigned int id; unsigned int flags; + unsigned int preroll_count; struct video_renderer *parent; IMFMediaEventQueue *event_queue; IMFVideoSampleAllocator *allocator; @@ -420,9 +421,16 @@ static HRESULT WINAPI video_stream_sink_ProcessSample(IMFStreamSink *iface, IMFS
if (stream->flags & EVR_STREAM_PREROLLING) { - IMFMediaEventQueue_QueueEventParamVar(stream->event_queue, MEStreamSinkPrerolled, &GUID_NULL, S_OK, NULL); - stream->flags &= ~EVR_STREAM_PREROLLING; - stream->flags |= EVR_STREAM_PREROLLED; + if (stream->preroll_count--) + IMFMediaEventQueue_QueueEventParamVar(stream->event_queue, MEStreamSinkRequestSample, + &GUID_NULL, S_OK, NULL); + else + { + IMFMediaEventQueue_QueueEventParamVar(stream->event_queue, MEStreamSinkPrerolled, + &GUID_NULL, S_OK, NULL); + stream->flags &= ~EVR_STREAM_PREROLLING; + stream->flags |= EVR_STREAM_PREROLLED; + } } }
@@ -1528,6 +1536,7 @@ static HRESULT WINAPI video_renderer_preroll_NotifyPreroll(IMFMediaSinkPreroll * IMFMediaEventQueue_QueueEventParamVar(stream->event_queue, MEStreamSinkRequestSample, &GUID_NULL, S_OK, NULL); stream->flags |= EVR_STREAM_PREROLLING; + stream->preroll_count = 3; } LeaveCriticalSection(&stream->cs); } diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 3c989249229..d01f2728782 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -1798,7 +1798,7 @@ static HRESULT session_append_node(struct media_session *session, IMFTopologyNod &IID_IMFVideoSampleAllocator, (void **)&topo_node->u.sink.allocator))) { if (FAILED(hr = IMFVideoSampleAllocator_InitializeSampleAllocator(topo_node->u.sink.allocator, - 2, media_type))) + 4, media_type))) { WARN("Failed to initialize sample allocator for the stream, hr %#lx.\n", hr); }