From 59a81ecf6de3be6ee2fc19c45d5f28855726cda0 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 3 May 2010 21:44:06 +0200 Subject: [PATCH] libspotify: Make audio controller injectable for testing --- mopidy/backends/libspotify.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mopidy/backends/libspotify.py b/mopidy/backends/libspotify.py index eecc514c..0f11fc77 100644 --- a/mopidy/backends/libspotify.py +++ b/mopidy/backends/libspotify.py @@ -47,13 +47,16 @@ class LibspotifyBackend(BaseBackend): self.stored_playlists = LibspotifyStoredPlaylistsController( backend=self) self.uri_handlers = [u'spotify:', u'http://open.spotify.com/'] + self.audio_controller_class = kwargs.get( + 'audio_controller_class', AlsaController) self.spotify = self._connect() def _connect(self): logger.info(u'Connecting to Spotify') spotify = LibspotifySessionManager( settings.SPOTIFY_USERNAME, settings.SPOTIFY_PASSWORD, - core_queue=self.core_queue) + core_queue=self.core_queue, + audio_controller_class=self.audio_controller_class) spotify.start() return spotify @@ -175,12 +178,12 @@ class LibspotifySessionManager(SpotifySessionManager, threading.Thread): appkey_file = os.path.expanduser(settings.SPOTIFY_LIB_APPKEY) user_agent = 'Mopidy %s' % get_version() - def __init__(self, username, password, core_queue): + def __init__(self, username, password, core_queue, audio_controller): SpotifySessionManager.__init__(self, username, password) threading.Thread.__init__(self) self.core_queue = core_queue self.connected = threading.Event() - self.audio = AlsaController() + self.audio = audio_controller() self.session = None def run(self):