Lookup other actors by their known superclasses
This commit is contained in:
parent
0575d5d3be
commit
d8ea7ea884
@ -5,11 +5,11 @@ import threading
|
||||
from spotify.manager import SpotifySessionManager as PyspotifySessionManager
|
||||
|
||||
from pykka.registry import ActorRegistry
|
||||
from pykka.proxy import ActorProxy
|
||||
|
||||
from mopidy import get_version, settings
|
||||
from mopidy.backends.spotify.translator import SpotifyTranslator
|
||||
from mopidy.models import Playlist
|
||||
from mopidy.outputs.base import BaseOutput
|
||||
from mopidy.utils.process import BaseThread
|
||||
|
||||
logger = logging.getLogger('mopidy.backends.spotify.session_manager')
|
||||
@ -28,9 +28,9 @@ class SpotifySessionManager(BaseThread, PyspotifySessionManager):
|
||||
BaseThread.__init__(self)
|
||||
self.name = 'SpotifySMThread'
|
||||
|
||||
# TODO-PYKKA Get reference to output without hardcoding GStreamerOutput
|
||||
output_refs = ActorRegistry.get_by_class_name('GStreamerOutput')
|
||||
self.output = ActorProxy(output_refs[0])
|
||||
output_refs = ActorRegistry.get_by_class(BaseOutput)
|
||||
assert len(output_refs) == 1, 'Expected exactly one running output.'
|
||||
self.output = output_refs[0].proxy()
|
||||
|
||||
self.connected = threading.Event()
|
||||
self.session = None
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import re
|
||||
|
||||
from pykka.proxy import ActorProxy
|
||||
from pykka.registry import ActorRegistry
|
||||
|
||||
from mopidy.backends.base import Backend
|
||||
from mopidy.frontends.mpd.exceptions import (MpdAckError, MpdArgError,
|
||||
MpdUnknownCommand)
|
||||
from mopidy.frontends.mpd.protocol import mpd_commands, request_handlers
|
||||
@ -27,9 +27,9 @@ class MpdDispatcher(object):
|
||||
def __init__(self, session):
|
||||
self.session = session
|
||||
|
||||
# TODO-PYKKA: Get reference to backend in a more generic way
|
||||
backend_refs = ActorRegistry.get_by_class_name('SpotifyBackend')
|
||||
self.backend = ActorProxy(backend_refs[0])
|
||||
backend_refs = ActorRegistry.get_by_class(Backend)
|
||||
assert len(backend_refs) == 1, 'Expected exactly one running backend.'
|
||||
self.backend = backend_refs[0].proxy()
|
||||
|
||||
self.command_list = False
|
||||
self.command_list_ok = False
|
||||
|
||||
@ -1,16 +1,19 @@
|
||||
from pykka.actor import ThreadingActor
|
||||
from pykka.proxy import ActorProxy
|
||||
from pykka.registry import ActorRegistry
|
||||
|
||||
from mopidy.mixers.base import BaseMixer
|
||||
from mopidy.outputs.base import BaseOutput
|
||||
|
||||
class GStreamerSoftwareMixer(ThreadingActor, BaseMixer):
|
||||
"""Mixer which uses GStreamer to control volume in software."""
|
||||
|
||||
def __init__(self):
|
||||
# TODO-PYKKA Get reference to output without hardcoding GStreamerOutput
|
||||
output_refs = ActorRegistry.get_by_class_name('GStreamerOutput')
|
||||
self.output = ActorProxy(output_refs[0])
|
||||
self.output = None
|
||||
|
||||
def post_start(self):
|
||||
output_refs = ActorRegistry.get_by_class(BaseOutput)
|
||||
assert len(output_refs) == 1, 'Expected exactly one running output.'
|
||||
self.output = output_refs[0].proxy()
|
||||
|
||||
def _get_volume(self):
|
||||
return self.output.get_volume().get()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user