aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/mixer/alsa_mixer.c29
-rw-r--r--src/mixer/oss_mixer.c29
-rw-r--r--src/mixer_api.c16
-rw-r--r--src/mixer_api.h14
4 files changed, 20 insertions, 68 deletions
diff --git a/src/mixer/alsa_mixer.c b/src/mixer/alsa_mixer.c
index f3213c4cf..95e5c70ee 100644
--- a/src/mixer/alsa_mixer.c
+++ b/src/mixer/alsa_mixer.c
@@ -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;
}
@@ -60,25 +63,6 @@ alsa_mixer_finish(struct mixer_data *data)
}
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)
{
struct alsa_mixer *am = (struct alsa_mixer *)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
diff --git a/src/mixer/oss_mixer.c b/src/mixer/oss_mixer.c
index 504fedc67..261616747 100644
--- a/src/mixer/oss_mixer.c
+++ b/src/mixer/oss_mixer.c
@@ -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;
}
@@ -64,25 +67,6 @@ oss_mixer_finish(struct mixer_data *data)
}
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)
{
struct oss_mixer *om = (struct oss_mixer *) 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
diff --git a/src/mixer_api.c b/src/mixer_api.c
index b0fea9a7a..0cf4e0c92 100644
--- a/src/mixer_api.c
+++ b/src/mixer_api.c
@@ -21,14 +21,6 @@
#include "mixer_api.h"
-void mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin)
-{
- assert(plugin != NULL);
- assert(mixer != NULL);
- mixer->plugin = plugin;
- mixer->data = mixer->plugin->init();
-}
-
void mixer_finish(struct mixer *mixer)
{
assert(mixer != NULL && mixer->plugin != NULL);
@@ -40,11 +32,13 @@ void mixer_finish(struct mixer *mixer)
struct mixer *
mixer_new(const struct mixer_plugin *plugin, const struct config_param *param)
{
- struct mixer *mixer = g_new(struct mixer, 1);
+ struct mixer *mixer;
- mixer_init(mixer, plugin);
- plugin->configure(mixer->data, param);
+ assert(plugin != NULL);
+ mixer = g_new(struct mixer, 1);
+ mixer->plugin = plugin;
+ mixer->data = mixer->plugin->init(param);
return mixer;
}
diff --git a/src/mixer_api.h b/src/mixer_api.h
index cc0d8327f..50a9cb165 100644
--- a/src/mixer_api.h
+++ b/src/mixer_api.h
@@ -31,11 +31,10 @@ extern const struct mixer_plugin oss_mixer;
struct mixer_data;
struct mixer_plugin {
-
- /**
- * Allocate and initialize mixer data
+ /**
+ * Alocates and configures a mixer device.
*/
- struct mixer_data *(*init)(void);
+ struct mixer_data *(*init)(const struct config_param *param);
/**
* Finish and free mixer data
@@ -43,12 +42,6 @@ struct mixer_plugin {
void (*finish)(struct mixer_data *data);
/**
- * Setup and configure mixer
- */
- void (*configure)(struct mixer_data *data,
- const struct config_param *param);
-
- /**
* Open mixer device
*/
bool (*open)(struct mixer_data *data);
@@ -69,7 +62,6 @@ struct mixer {
struct mixer_data *data;
};
-void mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin);
void mixer_finish(struct mixer *mixer);
struct mixer *