From 7ecc6e5af7626bfe39bfa24af61dc04468ba840b Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Wed, 26 Oct 2016 22:41:37 +0200 Subject: [PATCH] audio: Revert MMS related changes. This reverts commit 74cf673171d8ed2748089eecbaeba9f940ed253d. "audio: Wait for state change instead of async done in scanner." This reverts commit 4adea37e970a4e5082366b6d2b1861e2d1006245. "audio: Give up getting duration for MMS (Fixes: #1553)" --- docs/changelog.rst | 2 +- mopidy/audio/scan.py | 39 ++++++++++++++++----------------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 03bca901..c0d60b54 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -40,7 +40,7 @@ Feature release. - Audio: Fix handling of MMS (and any other streams) that can't switch to playing ``ASYNC``. Previously we would time out trying to get a duration from - these. (Fixes: :issue:`1553`, PR :issue:`1575`, :issue:`1576`) + these. (Fixes: :issue:`1553`, PR :issue:`1575`) v2.0.1 (2016-08-16) diff --git a/mopidy/audio/scan.py b/mopidy/audio/scan.py index dde4b26a..e448fe14 100644 --- a/mopidy/audio/scan.py +++ b/mopidy/audio/scan.py @@ -194,14 +194,13 @@ def _process(pipeline, timeout_ms): missing_message = None duration = None - # TODO: Turn this into a callback table to cleanup code. types = ( - Gst.MessageType.APPLICATION | - Gst.MessageType.DURATION_CHANGED | Gst.MessageType.ELEMENT | - Gst.MessageType.EOS | + Gst.MessageType.APPLICATION | Gst.MessageType.ERROR | - Gst.MessageType.STATE_CHANGED | + Gst.MessageType.EOS | + Gst.MessageType.ASYNC_DONE | + Gst.MessageType.DURATION_CHANGED | Gst.MessageType.TAG ) @@ -236,25 +235,19 @@ def _process(pipeline, timeout_ms): raise exceptions.ScannerError(error) elif msg.type == Gst.MessageType.EOS: return tags, mime, have_audio, duration - elif msg.type == Gst.MessageType.STATE_CHANGED and msg.src == pipeline: - old_state, new_state, pending = msg.parse_state_changed() + elif msg.type == Gst.MessageType.ASYNC_DONE: + success, duration = _query_duration(pipeline) + if tags and success: + return tags, mime, have_audio, duration - if pending == Gst.State.VOID_PENDING: - success, duration = _query_duration(pipeline) - if tags and success: - return tags, mime, have_audio, duration - - if new_state == Gst.State.PAUSED: - # 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 - logger.debug('Using workaround for duration missing.') - result = pipeline.set_state(Gst.State.PLAYING) - if result == Gst.StateChangeReturn.FAILURE: - return tags, mime, have_audio, duration - else: - 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 + logger.debug('Using workaround for duration missing before play.') + result = pipeline.set_state(Gst.State.PLAYING) + 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