From: Jörn Nettingsmeier Date: Fri, 15 Feb 2019 22:59:31 +0000 (+0000) Subject: Fail early and fail deadly (AFAIK there is no fallback to another audio backend,... X-Git-Tag: 3.3RC0~52^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63b3381a27906859e7a2932e6bebe3979e7e075d;p=thirdparty%2Fshairport-sync.git Fail early and fail deadly (AFAIK there is no fallback to another audio backend, so any severe JACK issue should be fatal). --- diff --git a/audio_jack.c b/audio_jack.c index d825cacc..20e3b37f 100644 --- a/audio_jack.c +++ b/audio_jack.c @@ -148,32 +148,29 @@ static void default_jack_error_callback(const char *desc) { debug(2, "jackd erro static void default_jack_info_callback(const char *desc) { inform("jackd information: \"%s\"", desc); } - static int jack_client_open_if_needed(void) { pthread_mutex_lock(&client_mutex); if (client_is_open == 0) { jack_status_t status; client = jack_client_open(config.jack_client_name, JackNoStartServer, &status); - if (client) { - jack_set_process_callback(client, jack_stream_write_cb, 0); - left_port = jack_port_register(client, "out_L", JACK_DEFAULT_AUDIO_TYPE, - JackPortIsOutput, 0); - right_port = jack_port_register(client, "out_R", - JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); - sample_rate = jack_get_sample_rate(client); - // debug(1, "jackaudio sample rate = %" PRId32 ".", sample_rate); - if (sample_rate == 44100) { - if (jack_activate(client)) { - debug(1, "jackaudio cannot activate client"); - } else { - debug(2, "jackaudio client opened."); - client_is_open = 1; - } - } else { - inform( - "jackaudio is running at the wrong speed (%d) for Shairport Sync, which must be 44100", - sample_rate); - } + if (!client) { + die("Could not start JACK server. JackStatus is %x", status); + } + sample_rate = jack_get_sample_rate(client); + if (sample_rate != 44100) { + die("The JACK server is running at the wrong sample rate (%d) for Shairport Sync. Must be 44100 Hz.", + sample_rate); + } + jack_set_process_callback(client, jack_stream_write_cb, 0); + left_port = jack_port_register(client, "out_L", JACK_DEFAULT_AUDIO_TYPE, + JackPortIsOutput, 0); + right_port = jack_port_register(client, "out_R", + JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); + if (jack_activate(client)) { + die("Could not activate %s JACK client.", config.jack_client_name); + } else { + debug(2, "JACK client %s activated sucessfully.", config.jack_client_name); + client_is_open = 1; } } pthread_mutex_unlock(&client_mutex);