def __init__(self, config, section, main_loop): super().__init__(config, section, main_loop) target_ports_re = config[section].get("connect", ".*") if target_ports_re: self._target_ports_re = re.compile(target_ports_re) else: self._target_ports_re = None start_server = config[section].getboolean("start_server", False) self._active = 0 self._queue = Queue() jack.set_error_function(partial(jack_logger.debug, "%s")) jack.set_info_function(partial(jack_logger.debug, "%s")) try: self._client = jack.Client("Badum-tss machine", no_start_server=not start_server) except jack.JackError as err: raise PlayerLoadError("Could not connect to Jack: {}".format(err)) jack.set_error_function(partial(jack_logger.error, "%s")) jack.set_info_function(partial(jack_logger.info, "%s")) self._client.set_shutdown_callback(self._shutdown) self._client.set_port_registration_callback(self._port_registration) self._client.set_port_rename_callback(self._port_rename) self._client.set_xrun_callback(self._xrun) self._client.set_process_callback(self._process) self._port = None
def _clientDisconnect(self): if self._client: log.info("Disconnecting client '%s'" % self._cfg.get('name', 'jack')) try: jack.set_info_function(None) jack.set_error_function(None) self._client.deactivate() self._client.close() except Exception as e: log.error("Unable to gracefully disconnect '%s' client: %s" % (self._cfg.get('name', 'jack'), e)) Process._clientDisconnect(self)
def _clientConnect(self): log.info("Connecting client '%s'" % self._cfg.get('name', 'jack')) jack.set_error_function(lambda msg: None) self._client = jack.Client("onebutton", no_start_server=True, servername=self._cfg.get('name', 'jack')) jack.set_info_function(self._jack_info_log) jack.set_error_function(self._jack_error_log) self._client.activate() self._client.transport_start() for i in (1,2,3,4,5,6,7,8,9,10): log.debug("Jack Status: '%s', Transport: '%s'" % (self._client.status, self._client.transport_state)) if self._client.transport_state == jack.ROLLING: break sleep(0.5) if not self._client.transport_state == jack.ROLLING: raise Exception("Status is not ROLLING")
def _clientConnect(self): log.info("Connecting client '%s'" % self._cfg.get('name', 'jack')) jack.set_error_function(lambda msg: None) self._client = jack.Client("onebutton", no_start_server=True, servername=self._cfg.get('name', 'jack')) jack.set_info_function(self._jack_info_log) jack.set_error_function(self._jack_error_log) self._client.activate() self._client.transport_start() for i in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10): log.debug("Jack Status: '%s', Transport: '%s'" % (self._client.status, self._client.transport_state)) if self._client.transport_state == jack.ROLLING: break sleep(0.5) if not self._client.transport_state == jack.ROLLING: raise Exception("Status is not ROLLING")
def start(self): self._command = ['jackd', '--name', self._cfg.get('name', 'jack')] cfg = self._cfg.get('config', {}) if cfg.get('rtpriority', 89): self._command += ['--realtime', '--realtime-priority', int(self._cfg.get('config', {}).get('rtpriority', 89))] else: self._command += ['--no-realtime'] if self._cfg.get('type', 'alsa') == 'alsa': self._command += ['-dalsa', '--device', cfg.get('device', 'hw:1'), '--rate', cfg.get('samplerate', 44100), '--period', cfg.get('buffer', 128), '--nperiods', cfg.get('periods', 3)] jack.set_info_function(self._jack_info_log) jack.set_error_function(self._jack_error_log) Process.start(self)
def start(self): self._command = ['jackd', '--name', self._cfg.get('name', 'jack')] cfg = self._cfg.get('config', {}) if cfg.get('rtpriority', 89): self._command += [ '--realtime', '--realtime-priority', int(self._cfg.get('config', {}).get('rtpriority', 89)) ] else: self._command += ['--no-realtime'] if self._cfg.get('type', 'alsa') == 'alsa': self._command += [ '-dalsa', '--device', cfg.get('device', 'hw:1'), '--rate', cfg.get('samplerate', 44100), '--period', cfg.get('buffer', 128), '--nperiods', cfg.get('periods', 3) ] jack.set_info_function(self._jack_info_log) jack.set_error_function(self._jack_error_log) Process.start(self)
""" from __future__ import print_function # only needed for Python 2.x import jack def error(msg): print("Error:", msg) def info(msg): print("Info:", msg) print("setting error/info functions") jack.set_error_function(error) jack.set_info_function(info) print("starting chatty client") client = jack.Client("Chatty-Client") if client.status.server_started: print("JACK server was started") else: print("JACK server was already running") if client.status.name_not_unique: print("unique client name generated:", client.name) print("registering callbacks")