spotify: Only pause on connection error if playing

Spotify has availability issues today, which makes this easy to reproduce and
improve. Before this patch, the following was logged on a Spotify connection
error when not playing:

ERROR    Spotify connection error: Can not connect to Spotify
WARNING  Setting GStreamer state to GST_STATE_PAUSED failed
ERROR    Resource not found. gstplaybin2.c(3824): setup_next_source ():
/GstPlayBin2:playbin20

With this patch, only the first and relevant error message is logged.
This commit is contained in:
Stein Magnus Jodal 2012-11-20 15:08:17 +01:00
parent e87f6f70b1
commit 16518697c8

View File

@ -10,7 +10,7 @@ import threading
from spotify.manager import SpotifySessionManager as PyspotifySessionManager from spotify.manager import SpotifySessionManager as PyspotifySessionManager
from mopidy import settings from mopidy import audio, settings
from mopidy.backends.listener import BackendListener from mopidy.backends.listener import BackendListener
from mopidy.utils import process, versioning from mopidy.utils import process, versioning
@ -92,7 +92,8 @@ class SpotifySessionManager(process.BaseThread, PyspotifySessionManager):
logger.info('Spotify connection OK') logger.info('Spotify connection OK')
else: else:
logger.error('Spotify connection error: %s', error) logger.error('Spotify connection error: %s', error)
self.backend.playback.pause() if self.audio.state.get() == audio.PlaybackState.PLAYING:
self.backend.playback.pause()
def message_to_user(self, session, message): def message_to_user(self, session, message):
"""Callback used by pyspotify""" """Callback used by pyspotify"""