Exemple #1
0
    def __init__(self, alsa_mixer_name="DSPVolume"):
        self.restore = False

        self.server = SigmaTCPServer()
        if "--alsa" in sys.argv:
            logging.info("initializiong ALSA mixer control")
            alsasync = AlsaSync()
            alsasync.set_alsa_control(alsa_mixer_name)
            SigmaTCPHandler.alsasync = alsasync
            volreg = SigmaTCPHandler.get_meta(ATTRIBUTE_VOL_CTL)
            if volreg is not None and len(volreg) > 0:
                reg = datatools.parse_int(volreg)
                alsasync.set_volume_register(reg)
            alsasync.start()
        else:
            logging.info("not using ALSA volume control")
            self.alsa_mixer_name = None

        if "--lgsoundsync" in sys.argv:
            try:
                logging.info("initializing LG SoundSync")
                SigmaTCPHandler.lgsoundsync = SoundSync()
                SigmaTCPHandler.lgsoundsync.start()
                SigmaTCPHandler.update_lgsoundsync()
            except Exception as e:
                logging.exception(e)
        else:
            logging.info("not enabling LG SoundSync")

        if "--restore" in sys.argv:
            self.restore = True

        logging.info("server initialization finished")
Exemple #2
0
    def __init__(self, alsa_mixer_name="DSPVolume"):
        self.restore = False
        self.abort = False
        self.zeroconf = None

        self.server = SigmaTCPServer()

        params = self.parse_config()
        if params["alsa"]:
            logging.info("initializing ALSA mixer control %s", alsa_mixer_name)
            alsasync = AlsaSync()
            if alsasync.set_alsa_control(alsa_mixer_name):
                SigmaTCPHandler.alsasync = alsasync
                volreg = SigmaTCPHandler.get_meta(ATTRIBUTE_VOL_CTL)
                if volreg is not None and len(volreg) > 0:
                    reg = datatools.parse_int(volreg)
                    alsasync.set_volume_register(reg)
                alsasync.start()
            else:
                logging.error("can't create mixer control - aborting")
                self.abort = True
        else:
            logging.info("not using ALSA volume control")
            self.alsa_mixer_name = None

        if params["lgsoundsync"]:
            try:
                logging.info("initializing LG Sound Sync")
                SigmaTCPHandler.lgsoundsync = SoundSync()
                SigmaTCPHandler.lgsoundsync.start()
                SigmaTCPHandler.update_lgsoundsync()
            except Exception as e:
                logging.exception(e)
        else:
            logging.info("not enabling LG Sound Sync")

        if this.notify_on_updates is not None:
            logging.info("Sending notifies on program updates to %s",
                         this.notify_on_updates)

        if params["restore"]:
            self.restore = True
Exemple #3
0
 def test_parse_volume_with_missing_sound_sync_signature(self):
     assert SoundSync.parse_volume_from_status(
         b'\xff\xff\xff\xff\xff\xff') is None
Exemple #4
0
 def test_parse_volume_of_100_on_another_tv(self):
     # Data observed on a LG OLED55C9
     assert SoundSync.parse_volume_from_status(
         b'\x00\x06\x4f\x04\x8a\x60') == 100
Exemple #5
0
 def test_parse_volume_of_100(self):
     assert SoundSync.parse_volume_from_status(
         b'\x00\x16\x4f\x04\x8a\x62') == 100
Exemple #6
0
 def test_parse_volume_of_50(self):
     assert SoundSync.parse_volume_from_status(
         b'\x00\x13\x2f\x04\x8a\x62') == 50
Exemple #7
0
 def test_parse_out_of_range_volume(self):
     # The maximum value is 100, but we don't enforce that in the parser itself,
     # but rather in later validation.
     assert SoundSync.parse_volume_from_status(
         b'\x00\x1f\xff\x04\x8a\x62') == 255
 def test_parse_volume_of_0(self):
     assert SoundSync.parse_volume_from_status(b'\x00\x10\x0f\x04\x8a') == 0