refactor: replace writer thread with synchronous save and fix ring buffer memory ordering
This commit is contained in:
committed by
Loic Coenen (aider)
parent
10e47e6c0c
commit
f38797fe0a
@@ -17,7 +17,8 @@ void channel_add(jack_client_t *client, int idx) {
|
||||
snprintf(in_name, sizeof(in_name), "channel%d_input", next_channel_id);
|
||||
snprintf(out_name, sizeof(out_name), "channel%d_output", next_channel_id);
|
||||
|
||||
/* Always register audio ports (needed for pass-through even for MIDI channels?) */
|
||||
/* Always register audio ports (needed for pass-through even for MIDI
|
||||
* channels?) */
|
||||
channels[idx].audio_in = jack_port_register(
|
||||
client, in_name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
|
||||
channels[idx].audio_out = jack_port_register(
|
||||
@@ -32,24 +33,26 @@ void channel_add(jack_client_t *client, int idx) {
|
||||
|
||||
/* If this is a MIDI channel, register MIDI ports */
|
||||
if (channels[idx].type == CHANNEL_MIDI) {
|
||||
char midi_in_name[64], midi_out_name[64];
|
||||
snprintf(midi_in_name, sizeof(midi_in_name), "channel%d_midi_in", next_channel_id);
|
||||
snprintf(midi_out_name, sizeof(midi_out_name), "channel%d_midi_out", next_channel_id);
|
||||
channels[idx].midi_in = jack_port_register(
|
||||
client, midi_in_name, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0);
|
||||
channels[idx].midi_out = jack_port_register(
|
||||
client, midi_out_name, JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0);
|
||||
if (!channels[idx].midi_in || !channels[idx].midi_out) {
|
||||
fprintf(stderr, "Failed to register MIDI ports for channel %d\n",
|
||||
next_channel_id);
|
||||
atomic_store(&channels[idx].active, 0);
|
||||
jack_port_unregister(client, channels[idx].audio_in);
|
||||
jack_port_unregister(client, channels[idx].audio_out);
|
||||
return;
|
||||
}
|
||||
char midi_in_name[64], midi_out_name[64];
|
||||
snprintf(midi_in_name, sizeof(midi_in_name), "channel%d_midi_in",
|
||||
next_channel_id);
|
||||
snprintf(midi_out_name, sizeof(midi_out_name), "channel%d_midi_out",
|
||||
next_channel_id);
|
||||
channels[idx].midi_in = jack_port_register(
|
||||
client, midi_in_name, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0);
|
||||
channels[idx].midi_out = jack_port_register(
|
||||
client, midi_out_name, JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0);
|
||||
if (!channels[idx].midi_in || !channels[idx].midi_out) {
|
||||
fprintf(stderr, "Failed to register MIDI ports for channel %d\n",
|
||||
next_channel_id);
|
||||
atomic_store(&channels[idx].active, 0);
|
||||
jack_port_unregister(client, channels[idx].audio_in);
|
||||
jack_port_unregister(client, channels[idx].audio_out);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
channels[idx].midi_in = NULL;
|
||||
channels[idx].midi_out = NULL;
|
||||
channels[idx].midi_in = NULL;
|
||||
channels[idx].midi_out = NULL;
|
||||
}
|
||||
|
||||
atomic_store(&channels[idx].active, 1);
|
||||
|
||||
Reference in New Issue
Block a user