Poll gst_pad_query_duration a few times before giving up and trying to get duration by converting from byte-length. Fixes a bug in Fallout: New Vegas where the duration value is incorrect and causes the audio to loop.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/winegstreamer/wg_parser.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 5529321490e..391b0b26532 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -1499,9 +1499,21 @@ static gboolean src_event_cb(GstPad *pad, GstObject *parent, GstEvent *event) static LONGLONG query_duration(GstPad *pad) { gint64 duration, byte_length; + unsigned int i;
if (gst_pad_query_duration(pad, GST_FORMAT_TIME, &duration)) return duration / 100; + /* + * Sometimes we query duration too early, try again a few times before + * giving up and trying to convert from byte length. If the duration can't + * be found after 50ms, we probably have a bigger issue. + */ + for (i = 0; i < 10; ++i) + { + g_usleep(5000); + if (gst_pad_query_duration(pad, GST_FORMAT_TIME, &duration)) + return duration / 100; + }
WARN("Failed to query time duration; trying to convert from byte length.\n");