#include "jack_mixer.h"
jack_mixer_t mixer;
+bool keepRunning = true;
void
usage()
channels_volumes_read(mixer);
}
+void
+triggerShutDown(int sig)
+{
+ (void)sig;
+ keepRunning = false;
+}
+
int
main(int argc, char *argv[])
{
channel_index += 1;
channel_name = malloc(15);
if (snprintf(channel_name, 15, "Channel %d", channel_index) >= 15) {
+ free(channel_name);
abort();
}
channel = add_channel(mixer, channel_name, bStereo);
channel_set_volume_midi_cc(channel, atoi(argv[optind++]));
channel_set_midi_scale(channel, scale);
channel_volume_write(channel, initialVolume);
+ free(channel_name);
}
signal(SIGUSR1, reportVolume);
+ signal(SIGTERM, triggerShutDown);
+ signal(SIGHUP, triggerShutDown);
+ signal(SIGINT, triggerShutDown);
- while (true) {
- sleep(1);
+ while (keepRunning) {
+ usleep(500u * 1000u); //500msec
}
+ remove_channels(mixer);
+ remove_output_channel(main_mix_channel);
+ destroy(mixer);
+ scale_destroy(scale);
+ free(jack_cli_name);
return 0;
}
assert(channel_ptr->mixer_ptr->midi_cc_map[channel_ptr->midi_cc_solo_index] == channel_ptr);
channel_ptr->mixer_ptr->midi_cc_map[channel_ptr->midi_cc_solo_index] = NULL;
}
+
+ free(channel_ptr->frames_left);
+ free(channel_ptr->frames_right);
+ free(channel_ptr->prefader_frames_left);
+ free(channel_ptr->prefader_frames_right);
+
free(channel_ptr);
}
bool stereo)
{
struct channel * channel_ptr;
- char * port_name;
+ char * port_name = NULL;
size_t channel_name_size;
channel_ptr = malloc(sizeof(struct channel));
channel_ptr->mixer_ptr->input_channels_list = g_slist_prepend(
channel_ptr->mixer_ptr->input_channels_list, channel_ptr);
+ free(port_name);
return channel_ptr;
fail_unregister_left_channel:
{
struct channel * channel_ptr;
struct output_channel * output_channel_ptr;
- char * port_name;
+ char * port_name = NULL;
size_t channel_name_size;
output_channel_ptr = malloc(sizeof(struct output_channel));
output_channel_ptr->system = system;
output_channel_ptr->prefader = false;
+ free(port_name);
return output_channel_ptr;
fail_unregister_left_channel:
return output_channel_ptr;
}
+void
+remove_channels(
+ jack_mixer_t mixer)
+{
+ GSList *list_ptr;
+ for (list_ptr = mixer_ctx_ptr->input_channels_list; list_ptr; list_ptr = g_slist_next(list_ptr))
+ {
+ struct channel *input_channel_ptr = list_ptr->data;
+ remove_channel((jack_mixer_channel_t)input_channel_ptr);
+ }
+}
+
void
remove_output_channel(
jack_mixer_output_channel_t output_channel)
g_slist_free(output_channel_ptr->soloed_channels);
g_slist_free(output_channel_ptr->muted_channels);
+ free(channel_ptr->tmp_mixed_frames_left);
+ free(channel_ptr->tmp_mixed_frames_right);
+ free(channel_ptr->frames_left);
+ free(channel_ptr->frames_right);
+ free(channel_ptr->prefader_frames_left);
+ free(channel_ptr->prefader_frames_right);
+
free(channel_ptr);
}
remove_channel(
jack_mixer_channel_t channel);
+void
+remove_channels(
+ jack_mixer_t mixer);
+
/* returned value is in dBFS */
double
channel_abspeak_read(
scale_destroy(
jack_mixer_scale_t scale)
{
+ scale_remove_thresholds(scale);
free(scale_ptr);
}
+void
+scale_remove_thresholds(
+ jack_mixer_scale_t scale)
+{
+
+ struct threshold * threshold_ptr;
+ struct threshold * node_ptr;
+
+ list_for_each_entry_safe(threshold_ptr, node_ptr, &scale_ptr->thresholds, scale_siblings)
+ {
+ list_del(&(threshold_ptr->scale_siblings));
+ free(threshold_ptr);
+ threshold_ptr = NULL;
+ }
+}
+
bool
scale_add_threshold(
jack_mixer_scale_t scale,
float db,
float scale_value);
+void
+scale_remove_thresholds(
+ jack_mixer_scale_t scale);
+
void
scale_calculate_coefficients(
jack_mixer_scale_t scale);