aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/conf.c2
-rw-r--r--src/conf.h3
-rw-r--r--src/mixer/alsa_mixer.c18
-rw-r--r--src/mixer/oss_mixer.c16
-rw-r--r--src/volume.c2
5 files changed, 32 insertions, 9 deletions
diff --git a/src/conf.c b/src/conf.c
index 5bce0f029..1ae0520be 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -80,7 +80,7 @@ ConfigParam *newConfigParam(const char *value, int line)
return ret;
}
-static void
+void
config_param_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
ConfigParam *param = data;
diff --git a/src/conf.h b/src/conf.h
index ad7500225..a50273e6e 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -20,6 +20,7 @@
#define MPD_CONF_H
#include <stdbool.h>
+#include <glib.h>
#define CONF_MUSIC_DIR "music_directory"
#define CONF_PLAYLIST_DIR "playlist_directory"
@@ -105,6 +106,8 @@ int getBoolBlockParam(ConfigParam *param, const char *name, int force);
ConfigParam *newConfigParam(const char *value, int line);
+void config_param_free(gpointer data, gpointer user_data);
+
void addBlockParam(ConfigParam * param, const char *name, const char *value, int line);
#endif
diff --git a/src/mixer/alsa_mixer.c b/src/mixer/alsa_mixer.c
index 6930fa8a0..86a9ae86e 100644
--- a/src/mixer/alsa_mixer.c
+++ b/src/mixer/alsa_mixer.c
@@ -36,6 +36,10 @@ static void
alsa_mixer_finish(struct mixer_data *data)
{
struct alsa_mixer *am = (struct alsa_mixer *)data;
+ if (am->device)
+ g_free(am->device);
+ if (am->control)
+ g_free(am->control);
g_free(am);
}
@@ -45,10 +49,16 @@ alsa_mixer_configure(struct mixer_data *data, ConfigParam *param)
struct alsa_mixer *am = (struct alsa_mixer *)data;
BlockParam *bp;
- if ((bp = getBlockParam(param, "mixer_device")))
- am->device = bp->value;
- if ((bp = getBlockParam(param, "mixer_control")))
- am->control = bp->value;
+ if ((bp = getBlockParam(param, "mixer_device"))) {
+ if (am->device)
+ g_free(am->device);
+ am->device = g_strdup(bp->value);
+ }
+ if ((bp = getBlockParam(param, "mixer_control"))) {
+ if (am->control)
+ g_free(am->control);
+ am->control = g_strdup(bp->value);
+ }
}
static void
diff --git a/src/mixer/oss_mixer.c b/src/mixer/oss_mixer.c
index db8431ab9..75f1f5a0b 100644
--- a/src/mixer/oss_mixer.c
+++ b/src/mixer/oss_mixer.c
@@ -19,8 +19,8 @@
#define VOLUME_MIXER_OSS_DEFAULT "/dev/mixer"
struct oss_mixer {
- const char *device;
- const char *control;
+ char *device;
+ char *control;
int device_fd;
int volume_control;
};
@@ -40,6 +40,10 @@ static void
oss_mixer_finish(struct mixer_data *data)
{
struct oss_mixer *om = (struct oss_mixer *) data;
+ if (om->device)
+ g_free(om->device);
+ if (om->control)
+ g_free(om->control);
g_free(om);
}
@@ -50,11 +54,15 @@ oss_mixer_configure(struct mixer_data *data, ConfigParam *param)
BlockParam *bp;
bp = getBlockParam(param, "mixer_device");
if (bp) {
- om->device = bp->value;
+ if (om->device)
+ g_free(om->device);
+ om->device = g_strdup(bp->value);
}
bp = getBlockParam(param, "mixer_control");
if (bp) {
- om->control = bp->value;
+ if (om->control)
+ g_free(om->control);
+ om->control = g_strdup(bp->value);
}
}
diff --git a/src/volume.c b/src/volume.c
index 97b1ccd2b..5eb0bd64c 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -71,6 +71,8 @@ mixer_reconfigure(char *driver)
g_error("Using mixer_type '%s' with not enabled %s output", driver, driver);
}
}
+ //free parameter list
+ config_param_free(newparam, NULL);
}
void volume_init(void)