1 0
import logging
2

3 0
import pykka
4

5 0
from mopidy import mixer
6

7 0
logger = logging.getLogger(__name__)
8

9

10 0
class SoftwareMixer(pykka.ThreadingActor, mixer.Mixer):
11

12 0
    name = "software"
13

14 0
    def __init__(self, config):
15 0
        super().__init__(config)
16

17 0
        self._audio_mixer = None
18 0
        self._initial_volume = None
19 0
        self._initial_mute = None
20

21 0
    def setup(self, mixer_ref):
22 0
        self._audio_mixer = mixer_ref
23

24
        # The Mopidy startup procedure will set the initial volume of a
25
        # mixer, but this happens before the audio actor's mixer is injected
26
        # into the software mixer actor and has no effect. Thus, we need to set
27
        # the initial volume again.
28 0
        if self._initial_volume is not None:
29 0
            self.set_volume(self._initial_volume)
30 0
        if self._initial_mute is not None:
31 0
            self.set_mute(self._initial_mute)
32

33 0
    def teardown(self):
34 0
        self._audio_mixer = None
35

36 0
    def get_volume(self):
37 0
        if self._audio_mixer is None:
38 0
            return None
39 0
        return self._audio_mixer.get_volume().get()
40

41 0
    def set_volume(self, volume):
42 0
        if self._audio_mixer is None:
43 0
            self._initial_volume = volume
44 0
            return False
45 0
        self._audio_mixer.set_volume(volume)
46 0
        return True
47

48 0
    def get_mute(self):
49 0
        if self._audio_mixer is None:
50 0
            return None
51 0
        return self._audio_mixer.get_mute().get()
52

53 0
    def set_mute(self, mute):
54 0
        if self._audio_mixer is None:
55 0
            self._initial_mute = mute
56 0
            return False
57 0
        self._audio_mixer.set_mute(mute)
58 0
        return True

Read our documentation on viewing source code .

Loading