From 58d1e0fbeee30f223653a990e9a74d6028843a2c Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Wed, 26 Oct 2016 23:02:39 +0200 Subject: [PATCH] audio: Make missing duration workaround more robust. --- mopidy/audio/scan.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mopidy/audio/scan.py b/mopidy/audio/scan.py index a48b0c9d..cc182e8d 100644 --- a/mopidy/audio/scan.py +++ b/mopidy/audio/scan.py @@ -251,10 +251,13 @@ def _process(pipeline, timeout_ms): if result == Gst.StateChangeReturn.FAILURE: return tags, mime, have_audio, duration - elif msg.type == Gst.MessageType.DURATION_CHANGED: - # duration will be read after ASYNC_DONE received; for now - # just give it a non-None value to flag that we have a duration: - duration = 0 + elif msg.type == Gst.MessageType.DURATION_CHANGED and tags: + # VBR formats sometimes seem to not have a duration by the time we + # go back to paused. So just try to get it right away. + success, duration = _query_duration(pipeline) + pipeline.set_state(Gst.State.PAUSED) + if success: + return tags, mime, have_audio, duration elif msg.type == Gst.MessageType.TAG: taglist = msg.parse_tag() # Note that this will only keep the last tag. @@ -262,11 +265,6 @@ def _process(pipeline, timeout_ms): timeout = timeout_ms - (int(time.time() * 1000) - start) - # workaround for https://bugzilla.gnome.org/show_bug.cgi?id=763553: - # if we got what we want then stop playing (and wait for ASYNC_DONE) - if tags and duration is not None: - pipeline.set_state(Gst.State.PAUSED) - raise exceptions.ScannerError('Timeout after %dms' % timeout_ms)