LiquidSoapInitThread.py 1.81 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import time
import threading

from libraries.exceptions.auraexceptions import LQConnectionError


class LiquidSoapInitThread(threading.Thread):
    socket = None
    liquidsoapcommunicator = None

    def __init__(self, liquidsoapcommunicator, socket):
        threading.Thread.__init__(self)

        self.socket = socket
        self.liquidsoapcommunicator = liquidsoapcommunicator

17
    def run(self):
18
19
        try:
            # sleep needed, because the socket is created to slow by liquidsoap
20
            time.sleep(10)
Gottfried Gaisbauer's avatar
Gottfried Gaisbauer committed
21
22
23
24
25
26
27
28
            self.liquidsoapcommunicator.enable_transaction()
            self.liquidsoapcommunicator.open_conn(self.socket)
            self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "volume", "0", "0")
            self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "volume", "1", "0")
            self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "volume", "2", "0")
            self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "select", "0", "true")
            self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "select", "1", "true")
            self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "select", "2", "true")
29
30
            # a little hack => the cracklings stop after 5 seconds after restarting the liquidsoap server
            time.sleep(5)
Gottfried Gaisbauer's avatar
Gottfried Gaisbauer committed
31
            self.liquidsoapcommunicator.__send_lqc_command__(self.socket, "mixer", "select", "2", "true")
32

Gottfried Gaisbauer's avatar
Gottfried Gaisbauer committed
33
34
            self.liquidsoapcommunicator.close_conn(self.socket)
            self.liquidsoapcommunicator.disable_transaction()
35
36
37
38
39
40
41
42
        except LQConnectionError as e:
            print("Liquidsoap connection ERROR! Restart LQ Server!")
            print(e.message)
            print(e)
        except Exception as e:
            print(e)