Remove global client_is_open flag, always execute former conditional statements. We know we're open.
This commit is contained in:
+23
-33
@@ -48,7 +48,6 @@ void jack_deinit(void);
|
||||
void jack_start(int, int);
|
||||
int play(void *, int);
|
||||
void jack_stop(void);
|
||||
int jack_is_running(void);
|
||||
int jack_delay(long *);
|
||||
void jack_flush(void);
|
||||
|
||||
@@ -69,7 +68,6 @@ audio_output audio_jack = {.name = "jack",
|
||||
jack_port_t *left_port;
|
||||
jack_port_t *right_port;
|
||||
|
||||
int client_is_open;
|
||||
jack_client_t *client;
|
||||
jack_nframes_t sample_rate;
|
||||
jack_nframes_t jack_latency;
|
||||
@@ -183,31 +181,26 @@ int jack_init(__attribute__((unused)) int argc, __attribute__((unused)) char **a
|
||||
jack_set_error_function(default_jack_error_callback);
|
||||
jack_set_info_function(default_jack_info_callback);
|
||||
|
||||
client_is_open = 0;
|
||||
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
jack_status_t status;
|
||||
client = jack_client_open(config.jack_client_name, JackNoStartServer, &status);
|
||||
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);
|
||||
}
|
||||
pthread_mutex_unlock(&client_mutex);
|
||||
|
||||
@@ -216,13 +209,10 @@ int jack_init(__attribute__((unused)) int argc, __attribute__((unused)) char **a
|
||||
|
||||
void jack_deinit() {
|
||||
pthread_mutex_lock(&client_mutex);
|
||||
if (client_is_open) {
|
||||
if (jack_deactivate(client))
|
||||
debug(1, "Error deactivating jack client");
|
||||
if (jack_client_close(client))
|
||||
debug(1, "Error closing jack client");
|
||||
client_is_open = 0;
|
||||
}
|
||||
if (jack_deactivate(client))
|
||||
debug(1, "Error deactivating jack client");
|
||||
if (jack_client_close(client))
|
||||
debug(1, "Error closing jack client");
|
||||
pthread_mutex_unlock(&client_mutex);
|
||||
jack_ringbuffer_free(jackbuf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user