winegstreamer: Delay duration query until caps have been acquired.

Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Connor McAdams 2021-04-29 15:49:13 -05:00 committed by Alexandre Julliard
parent ca03802a45
commit 2c5314d007
2 changed files with 7 additions and 2 deletions

View file

@ -929,7 +929,7 @@ static void test_seeking(void)
duration = 0xdeadbeef;
hr = IMediaSeeking_GetDuration(seeking, &duration);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(duration > 0, "Got duration %s.\n", wine_dbgstr_longlong(duration));
ok(duration > 0, "Got duration %s.\n", wine_dbgstr_longlong(duration));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetStopPosition(seeking, &stop);

View file

@ -1553,7 +1553,6 @@ static HRESULT CDECL wg_parser_connect(struct wg_parser *parser, uint64_t file_s
{
struct wg_parser_stream *stream = parser->streams[i];
stream->duration = query_duration(stream->their_src);
while (!stream->has_caps && !parser->error)
pthread_cond_wait(&parser->init_cond, &parser->mutex);
if (parser->error)
@ -1561,6 +1560,12 @@ static HRESULT CDECL wg_parser_connect(struct wg_parser *parser, uint64_t file_s
pthread_mutex_unlock(&parser->mutex);
return E_FAIL;
}
/* GStreamer doesn't actually provide any guarantees about when duration
* is available, even for seekable streams. However, many elements (e.g.
* avidemux, wavparse, qtdemux) in practice record duration before
* fixing caps, so as a heuristic, wait until we get caps before trying
* to query for duration. */
stream->duration = query_duration(stream->their_src);
}
pthread_mutex_unlock(&parser->mutex);