winegstreamer: Seek to the beginning of the range in wm_reader_set_output_props().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-10-31 19:03:37 -05:00 committed by Alexandre Julliard
parent 74c2e9020f
commit 6f8d366b57
2 changed files with 20 additions and 0 deletions

View File

@ -136,6 +136,8 @@ struct wm_reader
LONG refcount;
CRITICAL_SECTION cs;
QWORD start_time;
IStream *source_stream;
HANDLE read_thread;
bool read_thread_shutdown;

View File

@ -1543,6 +1543,22 @@ HRESULT wm_reader_set_output_props(struct wm_reader *reader, DWORD output,
stream->format = format;
wg_parser_stream_enable(stream->wg_stream, &format);
/* Re-decode any buffers that might have been generated with the old format.
*
* FIXME: Seeking in-place will cause some buffers to be dropped.
* Unfortunately, we can't really store the last received PTS and seek there
* either: since seeks are inexact and we aren't guaranteed to receive
* samples in order, some buffers might be duplicated or dropped anyway.
* In order to really seamlessly allow for format changes, we need
* cooperation from each individual GStreamer stream, to be able to tell
* upstream exactly which buffers they need resent...
*
* In all likelihood this function is being called not mid-stream but rather
* while setting the stream up, before consuming any events. Accordingly
* let's just seek back to the beginning. */
wg_parser_stream_seek(reader->streams[0].wg_stream, 1.0, reader->start_time, 0,
AM_SEEKING_AbsolutePositioning, AM_SEEKING_NoPositioning);
LeaveCriticalSection(&reader->cs);
return S_OK;
}
@ -1643,6 +1659,8 @@ void wm_reader_seek(struct wm_reader *reader, QWORD start, LONGLONG duration)
EnterCriticalSection(&reader->cs);
reader->start_time = start;
wg_parser_stream_seek(reader->streams[0].wg_stream, 1.0, start, start + duration,
AM_SEEKING_AbsolutePositioning, duration ? AM_SEEKING_AbsolutePositioning : AM_SEEKING_NoPositioning);