Skip to content

Commit

Permalink
mf/evr: Increase the number of prerolled samples to 3.
Browse files Browse the repository at this point in the history
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.

CW-Bug-Id: #21713
  • Loading branch information
rbernon committed Dec 8, 2023
1 parent 6082cd7 commit c4654ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions dlls/mf/evr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion dlls/mf/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,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);
}
Expand Down

0 comments on commit c4654ec

Please sign in to comment.