aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer_control.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-14 11:36:50 +0100
committerMax Kellermann <max@duempel.org>2009-03-14 11:36:50 +0100
commita5017a2d7c03506f55cf7eb465ca7d254dfc14a9 (patch)
treedea521c4221f3cd6729e85f384dfcb8d2fa1e8d1 /src/mixer_control.c
parent8d01110c8407b1efbdbe255f2e27a6daf6ac2d9a (diff)
downloadmpd-a5017a2d7c03506f55cf7eb465ca7d254dfc14a9.tar.gz
mpd-a5017a2d7c03506f55cf7eb465ca7d254dfc14a9.tar.xz
mpd-a5017a2d7c03506f55cf7eb465ca7d254dfc14a9.zip
mixer_api: moved functions to mixer_control.c
mixer_control.h should provide the functions needed to manipulate a mixer, without exposing the internal mixer API (which is provided by mixer_api.h).
Diffstat (limited to 'src/mixer_control.c')
-rw-r--r--src/mixer_control.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/mixer_control.c b/src/mixer_control.c
index 229c3683e..ba49e2ec4 100644
--- a/src/mixer_control.c
+++ b/src/mixer_control.c
@@ -20,4 +20,80 @@
#include "mixer_control.h"
#include "mixer_api.h"
+#include <glib.h>
+
#include <assert.h>
+#include <stddef.h>
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "mixer"
+
+static bool mixers_enabled = true;
+
+void
+mixer_disable_all(void)
+{
+ g_debug("mixer api is disabled");
+ mixers_enabled = false;
+}
+
+struct mixer *
+mixer_new(const struct mixer_plugin *plugin, const struct config_param *param)
+{
+ struct mixer *mixer;
+
+ //mixers are disabled (by using software volume)
+ if (!mixers_enabled) {
+ return NULL;
+ }
+ assert(plugin != NULL);
+
+ mixer = plugin->init(param);
+
+ assert(mixer == NULL || mixer->plugin == plugin);
+
+ return mixer;
+}
+
+void
+mixer_free(struct mixer *mixer)
+{
+ if (!mixer) {
+ return;
+ }
+ assert(mixer->plugin != NULL);
+
+ mixer->plugin->finish(mixer);
+}
+
+bool
+mixer_open(struct mixer *mixer)
+{
+ if (!mixer) {
+ return false;
+ }
+ assert(mixer->plugin != NULL);
+ return mixer->plugin->open(mixer);
+}
+
+void
+mixer_close(struct mixer *mixer)
+{
+ if (!mixer) {
+ return;
+ }
+ assert(mixer->plugin != NULL);
+ mixer->plugin->close(mixer);
+}
+
+int
+mixer_get_volume(struct mixer *mixer)
+{
+ return mixer->plugin->get_volume(mixer);
+}
+
+bool
+mixer_set_volume(struct mixer *mixer, unsigned volume)
+{
+ return mixer->plugin->set_volume(mixer, volume);
+}