Merge pull request #1258 from adamcik/v1.1.x

audio: Make scanner report MIME for missing plugins
This commit is contained in:
Thomas Adamcik 2015-08-19 00:45:18 +02:00
commit f65784e510
5 changed files with 27 additions and 9 deletions

View File

@ -24,6 +24,9 @@ Bug fix release.
- Audio: Fix timeout handling in scanner. This regression caused timeouts to
expire before it should, causing scans to fail.
- Audio: Update scanner to emit MIME type instead of an error when missing a
plugin.
v1.1.0 (2015-08-09)
===================

View File

@ -12,8 +12,6 @@ from mopidy import exceptions
from mopidy.audio import utils
from mopidy.internal import encoding
_missing_plugin_desc = gst.pbutils.missing_plugin_message_get_description
_Result = collections.namedtuple(
'Result', ('uri', 'tags', 'duration', 'seekable', 'mime', 'playable'))
@ -134,7 +132,7 @@ def _process(pipeline, timeout_ms):
clock = pipeline.get_clock()
bus = pipeline.get_bus()
timeout = timeout_ms * gst.MSECOND
tags, mime, have_audio, missing_description = {}, None, False, None
tags, mime, have_audio, missing_message = {}, None, False, None
types = (gst.MESSAGE_ELEMENT | gst.MESSAGE_APPLICATION | gst.MESSAGE_ERROR
| gst.MESSAGE_EOS | gst.MESSAGE_ASYNC_DONE | gst.MESSAGE_TAG)
@ -147,8 +145,7 @@ def _process(pipeline, timeout_ms):
break
elif message.type == gst.MESSAGE_ELEMENT:
if gst.pbutils.is_missing_plugin_message(message):
missing_description = encoding.locale_decode(
_missing_plugin_desc(message))
missing_message = message
elif message.type == gst.MESSAGE_APPLICATION:
if message.structure.get_name() == 'have-type':
mime = message.structure['caps'].get_name()
@ -158,8 +155,10 @@ def _process(pipeline, timeout_ms):
have_audio = True
elif message.type == gst.MESSAGE_ERROR:
error = encoding.locale_decode(message.parse_error()[0])
if missing_description:
error = '%s (%s)' % (missing_description, error)
if missing_message and not mime:
caps = missing_message.structure['detail']
mime = caps.get_structure(0).get_name()
return tags, mime, have_audio
raise exceptions.ScannerError(error)
elif message.type == gst.MESSAGE_EOS:
return tags, mime, have_audio

View File

@ -40,8 +40,11 @@ class ScannerTest(unittest.TestCase):
self.assertEqual(self.result[name].tags[key], value)
def check_if_missing_plugin(self):
if any(['missing a plug-in' in str(e) for e in self.errors.values()]):
raise unittest.SkipTest('Missing MP3 support?')
for path, result in self.result.items():
if not path.endswith('.mp3'):
continue
if not result.playable and result.mime == 'audio/mpeg':
raise unittest.SkipTest('Missing MP3 support?')
def test_tags_is_set(self):
self.scan(self.find('scanner/simple'))
@ -109,6 +112,17 @@ class ScannerTest(unittest.TestCase):
wav = path_to_data_dir('scanner/empty.wav')
self.assertEqual(self.result[wav].duration, 0)
def test_uri_list(self):
path = path_to_data_dir('scanner/playlist.m3u')
self.scan([path])
self.assertEqual(self.result[path].mime, 'text/uri-list')
def test_text_plain(self):
# GStreamer decode bin hardcodes bad handling of text plain :/
path = path_to_data_dir('scanner/plain.txt')
self.scan([path])
self.assertIn(path, self.errors)
@unittest.SkipTest
def test_song_without_time_is_handeled(self):
pass

View File

@ -0,0 +1 @@
Some plain text file with nothing special in it.

View File

@ -0,0 +1 @@
http://example.com/