audio: Make scanner report MIME for missing plugins
This commit is contained in:
parent
224cd65f78
commit
e77a4afaf4
@ -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)
|
||||
===================
|
||||
|
||||
@ -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
|
||||
|
||||
@ -109,6 +109,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
|
||||
|
||||
1
tests/data/scanner/plain.txt
Normal file
1
tests/data/scanner/plain.txt
Normal file
@ -0,0 +1 @@
|
||||
Some plain text file with nothing special in it.
|
||||
1
tests/data/scanner/playlist.m3u
Normal file
1
tests/data/scanner/playlist.m3u
Normal file
@ -0,0 +1 @@
|
||||
http://example.com/
|
||||
Loading…
Reference in New Issue
Block a user