File libcava-0.10.6-2.patch of Package libcava
diff -ura cava-0.10.6/include/cava/config.h cava-0.10.6.new/include/cava/config.h
--- cava-0.10.6/include/cava/config.h 2025-10-10 08:23:27.000000000 +0200
+++ cava-0.10.6.new/include/cava/config.h 2025-10-15 10:57:21.366988313 +0200
@@ -139,5 +139,5 @@
};
bool load_config(char configPath[PATH_MAX], struct config_params *p, bool colorsOnly,
struct error_s *error, int reload);
-
+void config_clean(struct config_params *prm);
enum input_method input_method_by_name(const char *str);
diff -ura cava-0.10.6/src/cava.c cava-0.10.6.new/src/cava.c
--- cava-0.10.6/src/cava.c 2025-10-10 08:23:27.000000000 +0200
+++ cava-0.10.6.new/src/cava.c 2025-10-15 10:57:50.613655869 +0200
@@ -705,9 +705,6 @@
pthread_mutex_unlock(&audio.lock);
pthread_join(p_thread, NULL);
- if (p.userEQ_enabled)
- free(p.userEQ);
-
free(audio.source);
free(audio.cava_in);
cleanup(p.output);
diff -ura cava-0.10.6/src/config.c cava-0.10.6.new/src/config.c
--- cava-0.10.6/src/config.c 2025-10-10 08:23:27.000000000 +0200
+++ cava-0.10.6.new/src/config.c 2025-10-15 10:58:03.963656274 +0200
@@ -524,6 +524,8 @@
bool load_config(char configPath[PATH_MAX], struct config_params *p, bool colorsOnly,
struct error_s *error, int reload) {
+ if (reload == 1)
+ config_clean(p);
#ifdef _WIN32
p->hFile = NULL;
@@ -751,12 +753,6 @@
p->bcolor = strdup(iniparser_getstring(ini, "color:background", "default"));
p->gradient = iniparser_getint(ini, "color:gradient", 0);
-
- if (reload) {
- for (int i = 0; i < 8; ++i)
- free(p->gradient_colors[i]);
- }
- free(p->gradient_colors);
p->gradient_colors = (char **)malloc(sizeof(char *) * 8 * 9);
p->gradient_colors[0] = strdup(iniparser_getstring(ini, "color:gradient_color_1", "not_set"));
@@ -769,12 +765,6 @@
p->gradient_colors[7] = strdup(iniparser_getstring(ini, "color:gradient_color_8", "not_set"));
p->horizontal_gradient = iniparser_getint(ini, "color:horizontal_gradient", 0);
-
- if (reload) {
- for (int i = 0; i < 8; ++i)
- free(p->horizontal_gradient_colors[i]);
- }
- free(p->horizontal_gradient_colors);
p->horizontal_gradient_colors = (char **)malloc(sizeof(char *) * 8 * 9);
p->horizontal_gradient_colors[0] =
@@ -1212,3 +1202,34 @@
return result;
}
+
+void config_clean(struct config_params *prm) {
+ if (prm->color)
+ free(prm->color);
+ if (prm->bcolor)
+ free(prm->bcolor);
+ if (prm->raw_target)
+ free(prm->raw_target);
+ if (prm->audio_source)
+ free(prm->audio_source);
+ if (prm->gradient_colors) {
+ for (int i = 0; prm->gradient_colors[i] != NULL; ++i)
+ free(prm->gradient_colors[i]);
+ free(prm->gradient_colors);
+ }
+ if (prm->horizontal_gradient_colors) {
+ for (int i = 0; prm->horizontal_gradient_colors[i] != NULL; ++i)
+ free(prm->horizontal_gradient_colors[i]);
+ free(prm->horizontal_gradient_colors);
+ }
+ if (prm->data_format)
+ free(prm->data_format);
+ if (prm->vertex_shader)
+ free(prm->vertex_shader);
+ if (prm->fragment_shader)
+ free(prm->fragment_shader);
+ if (prm->theme)
+ free(prm->theme);
+ if (prm->userEQ)
+ free(prm->userEQ);
+}
diff -ura cava-0.10.6/src/output/common.c cava-0.10.6.new/src/output/common.c
--- cava-0.10.6/src/output/common.c 2025-10-10 08:23:27.000000000 +0200
+++ cava-0.10.6.new/src/output/common.c 2025-10-15 10:58:27.296990317 +0200
@@ -204,9 +204,10 @@
audio->terminate = 1;
exit(EXIT_FAILURE);
}
- if (audio_raw->number_of_bars <= 1) {
+ if (audio_raw->number_of_bars < audio_raw->output_channels) {
cleanup(prm->output);
- fprintf(stderr, "fixed number of bars must be at least 1\n");
+ fprintf(stderr, "fixed number of bars must be at least 1 with mono output and "
+ "2 with stereo output\n");
exit(EXIT_FAILURE);
}
if (audio_raw->output_channels == 2 && audio_raw->number_of_bars % 2 != 0) {