def on_connection_change(self, context): """a callback from pulse lib indicating connection status""" state = lib.pa_context_get_state(context) if state == lib.PA_CONTEXT_READY: # ready self.connected = True # once onnection is established we need to get server information self.timeout_add(0.1, self.get_server_info) elif state == lib.PA_CONTEXT_FAILED: # failed to connect self.connected = False self._subscribed = False log.error('Failed to connect to pulseaudio') self.timeout_add(10, self.connect) elif state == lib.PA_CONTEXT_TERMINATED: # done self.connected = False self._subscribed = False log.error('Connection to pulseaudio has been terminated') elif state == lib.PA_CONTEXT_UNCONNECTED: self.connected = False self._subscribed = False log.error("Disconnected from pulsedio")
def on_connection_change(self, context): """a callback from pulse lib indicating connection status""" state = lib.pa_context_get_state(context) if state == lib.PA_CONTEXT_READY: # ready self.connected = True # once onnection is established we need to get server information self.timeout_add(0.1, self.get_server_info) log.debug("Connection to pulseaudio ready") elif state == lib.PA_CONTEXT_FAILED: # failed to connect self.connected = False self._subscribed = False log.warning("Failed to connect to pulseaudio, retrying in 10s") self.timeout_add(10, self.connect) elif state == lib.PA_CONTEXT_TERMINATED: # done self.connected = False self._subscribed = False log.debug("Connection to pulseaudio terminated cleanly") elif state == lib.PA_CONTEXT_UNCONNECTED: self.connected = False self._subscribed = False log.warning("Disconnected from pulseaudio")