mixer: merged methods "init" and "configure"
Both methods are always called together. There is no point in having them separate. This simplifies the code, because the old configure() method could be called more than once, and had to free old allocations.
This commit is contained in:
+6
-23
@@ -36,16 +36,19 @@ struct alsa_mixer {
|
||||
};
|
||||
|
||||
static struct mixer_data *
|
||||
alsa_mixer_init(void)
|
||||
alsa_mixer_init(const struct config_param *param)
|
||||
{
|
||||
struct alsa_mixer *am = g_malloc(sizeof(struct alsa_mixer));
|
||||
am->device = NULL;
|
||||
am->control = NULL;
|
||||
|
||||
am->device = config_dup_block_string(param, "mixer_device", NULL);
|
||||
am->control = config_dup_block_string(param, "mixer_control", NULL);
|
||||
|
||||
am->handle = NULL;
|
||||
am->elem = NULL;
|
||||
am->volume_min = 0;
|
||||
am->volume_max = 0;
|
||||
am->volume_set = -1;
|
||||
|
||||
return (struct mixer_data *)am;
|
||||
}
|
||||
|
||||
@@ -59,25 +62,6 @@ alsa_mixer_finish(struct mixer_data *data)
|
||||
g_free(am);
|
||||
}
|
||||
|
||||
static void
|
||||
alsa_mixer_configure(struct mixer_data *data, const struct config_param *param)
|
||||
{
|
||||
struct alsa_mixer *am = (struct alsa_mixer *)data;
|
||||
const char *value;
|
||||
|
||||
value = config_get_block_string(param, "mixer_device", NULL);
|
||||
if (value != NULL) {
|
||||
g_free(am->device);
|
||||
am->device = g_strdup(value);
|
||||
}
|
||||
|
||||
value = config_get_block_string(param, "mixer_control", NULL);
|
||||
if (value != NULL) {
|
||||
g_free(am->control);
|
||||
am->control = g_strdup(value);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
alsa_mixer_close(struct mixer_data *data)
|
||||
{
|
||||
@@ -235,7 +219,6 @@ alsa_mixer_control(struct mixer_data *data, int cmd, void *arg)
|
||||
const struct mixer_plugin alsa_mixer = {
|
||||
.init = alsa_mixer_init,
|
||||
.finish = alsa_mixer_finish,
|
||||
.configure = alsa_mixer_configure,
|
||||
.open = alsa_mixer_open,
|
||||
.control = alsa_mixer_control,
|
||||
.close = alsa_mixer_close
|
||||
|
||||
+6
-23
@@ -43,13 +43,16 @@ struct oss_mixer {
|
||||
};
|
||||
|
||||
static struct mixer_data *
|
||||
oss_mixer_init(void)
|
||||
oss_mixer_init(const struct config_param *param)
|
||||
{
|
||||
struct oss_mixer *om = g_malloc(sizeof(struct oss_mixer));
|
||||
om->device = NULL;
|
||||
om->control = NULL;
|
||||
|
||||
om->device = config_dup_block_string(param, "mixer_device", NULL);
|
||||
om->control = config_dup_block_string(param, "mixer_control", NULL);
|
||||
|
||||
om->device_fd = -1;
|
||||
om->volume_control = SOUND_MIXER_PCM;
|
||||
|
||||
return (struct mixer_data *)om;
|
||||
}
|
||||
|
||||
@@ -63,25 +66,6 @@ oss_mixer_finish(struct mixer_data *data)
|
||||
g_free(om);
|
||||
}
|
||||
|
||||
static void
|
||||
oss_mixer_configure(struct mixer_data *data, const struct config_param *param)
|
||||
{
|
||||
struct oss_mixer *om = (struct oss_mixer *) data;
|
||||
const char *value;
|
||||
|
||||
value = config_get_block_string(param, "mixer_device", NULL);
|
||||
if (value != NULL) {
|
||||
g_free(om->device);
|
||||
om->device = g_strdup(value);
|
||||
}
|
||||
|
||||
value = config_get_block_string(param, "mixer_control", NULL);
|
||||
if (value != NULL) {
|
||||
g_free(om->control);
|
||||
om->control = g_strdup(value);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
oss_mixer_close(struct mixer_data *data)
|
||||
{
|
||||
@@ -215,7 +199,6 @@ oss_mixer_control(struct mixer_data *data, int cmd, void *arg)
|
||||
const struct mixer_plugin oss_mixer = {
|
||||
.init = oss_mixer_init,
|
||||
.finish = oss_mixer_finish,
|
||||
.configure = oss_mixer_configure,
|
||||
.open = oss_mixer_open,
|
||||
.control = oss_mixer_control,
|
||||
.close = oss_mixer_close
|
||||
|
||||
Reference in New Issue
Block a user