From e9137e132a04baf9d36ee3f34bf682c8ce3335d8 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Fri, 25 Mar 2016 15:17:02 +0100 Subject: [PATCH] audio: Try and simplify logic for going to playing in scanner --- mopidy/audio/scan.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mopidy/audio/scan.py b/mopidy/audio/scan.py index ff96b641..27888638 100644 --- a/mopidy/audio/scan.py +++ b/mopidy/audio/scan.py @@ -192,14 +192,18 @@ def _process(pipeline, timeout_ms): duration = duration // Gst.MSECOND else: duration = None - if (tags and duration is not None - # workaround for - # https://bugzilla.gnome.org/show_bug.cgi?id=763553: - # try to start pipeline playing; if it doesn't then - # give up: - ) or (pipeline.set_state(Gst.State.PLAYING) == - Gst.StateChangeReturn.FAILURE): + + if tags and duration is not None: return tags, mime, have_audio, duration + + # Workaround for upstream bug which causes tags/duration to arrive + # after pre-roll. We get around this by starting to play the track + # and then waiting for a duration change. + # https://bugzilla.gnome.org/show_bug.cgi?id=763553 + result = pipeline.set_state(Gst.State.PLAYING) + if result == Gst.StateChangeReturn.FAILURE: + return tags, mime, have_audio, duration + elif message.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: