audio: Fix UnicodeDecodeError when logging errors

Fixes #347
This commit is contained in:
Stein Magnus Jodal 2013-03-30 13:16:19 +01:00
parent e21de8dc8c
commit 9e5f0703c7
2 changed files with 15 additions and 2 deletions

View File

@ -24,6 +24,11 @@ v0.13.0 (in development)
the Mopidy process will now always make it log tracebacks for all alive
threads.
**Audio sub-system**
- Make audio error logging handle log messages with non-ASCII chars. (Fixes:
:issue:`347`)
**Local backend**
- Make ``mopidy-scan`` work with Ogg Vorbis files. (Fixes: :issue:`275`)

View File

@ -241,11 +241,19 @@ class Audio(pykka.ThreadingActor):
self._on_end_of_stream()
elif message.type == gst.MESSAGE_ERROR:
error, debug = message.parse_error()
logger.error('%s %s', error, debug)
logger.error(
'%s\nError message: %s\nDebug message: %s',
str(error).decode('utf-8'),
error.message.decode('utf-8') or 'None',
debug.decode('utf-8') or 'None')
self.stop_playback()
elif message.type == gst.MESSAGE_WARNING:
error, debug = message.parse_warning()
logger.warning('%s %s', error, debug)
logger.warning(
'%s\nError message: %s\nDebug message: %s',
str(error).decode('utf-8'),
error.message.decode('utf-8') or 'None',
debug.decode('utf-8') or 'None')
def _on_playbin_state_changed(self, old_state, new_state, pending_state):
if new_state == gst.STATE_READY and pending_state == gst.STATE_NULL: