diff --git a/call_manager.py b/call_manager.py index 6e4063d..cd932ad 100644 --- a/call_manager.py +++ b/call_manager.py @@ -10,16 +10,24 @@ OP_PING = 'PING'.encode() OP_OK = 'OK'.encode() OP_ERROR = 'ERROR'.encode() +def exec_mumble(deaf: bool): + subprocess.Popen(['mumble', 'rpc', 'deaf' if deaf else 'undeaf']) + +def deaf_mumble(): + exec_mumble(true) + +def undeaf_mumble(): + exec_mumble(false) + class CallManager: def __init__(self, config): self.config = config self.state = NO_CALL self.station = None - self.call_process = None def call(self, station): try: - self.call_process = subprocess.Popen(['parole', '-c', station['host'], '-d', self.config['audio device']]) + undeaf_mumble() s = socket.socket() print('host=', station['host']) print('port=', station['port']) @@ -34,10 +42,9 @@ class CallManager: except Exception as e: print('Error al realizar la llamada: ', e) station['green'].off() - self.call_process.terminate() - self.call_process.communicate() def incoming_call(self, station): + undeaf_mumble() self.state = INCOMING_CALL self.station = station station['red'].on() @@ -46,9 +53,7 @@ class CallManager: print('Hang! self.station', self.station) if self.station is not None: self.station['red'].off() - if self.call_process is not None: - self.call_process.terminate() - self.call_process.communicate() + deaf_mumble() self.state = NO_CALL self.station = None diff --git a/intercom.py b/intercom.py index fdd7306..a17b2f9 100644 --- a/intercom.py +++ b/intercom.py @@ -102,9 +102,7 @@ for _station in stations: try: while True: for _station in stations: - # new_input_state = GPIO.input(_station['button']) new_input_state = _station['btn'].is_pressed -# print('new_input_state ', new_input_state) # Al pulsar el interruptor cambia el estado. elapsed_time = time.clock_gettime(time.CLOCK_MONOTONIC) - _station['button state changed time'] if new_input_state != _station['old button state'] and elapsed_time > 0.2: diff --git a/parole.service b/mumble.service similarity index 73% rename from parole.service rename to mumble.service index 6908b97..4498990 100644 --- a/parole.service +++ b/mumble.service @@ -1,9 +1,9 @@ [Unit] -Description=Parole +Description=Mumble After=network.target [Service] -ExecStart=/usr/bin/parole -la -d plughw:1,0 +ExecStart=xvfb-run mumble mumble://uli@miki WorkingDirectory=/home/pi StandardOutput=inherit StandardError=inherit