diff options
-rw-r--r-- | src/mixer_api.c | 31 | ||||
-rw-r--r-- | src/mixer_api.h | 2 | ||||
-rw-r--r-- | src/volume.c | 3 |
3 files changed, 33 insertions, 3 deletions
diff --git a/src/mixer_api.c b/src/mixer_api.c index ec621950c..9dc3e3b09 100644 --- a/src/mixer_api.c +++ b/src/mixer_api.c @@ -19,13 +19,30 @@ #include <stdio.h> #include <assert.h> +#include <glib.h> + #include "mixer_api.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\n"); + 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); @@ -38,7 +55,9 @@ mixer_new(const struct mixer_plugin *plugin, const struct config_param *param) void mixer_free(struct mixer *mixer) { - assert(mixer != NULL); + if (!mixer) { + return; + } assert(mixer->plugin != NULL); mixer->plugin->finish(mixer); @@ -46,12 +65,18 @@ mixer_free(struct mixer *mixer) bool mixer_open(struct mixer *mixer) { - assert(mixer != NULL && mixer->plugin != NULL); + if (!mixer) { + return false; + } + assert(mixer->plugin != NULL); return mixer->plugin->open(mixer); } void mixer_close(struct mixer *mixer) { - assert(mixer != NULL && mixer->plugin != NULL); + if (!mixer) { + return; + } + assert(mixer->plugin != NULL); mixer->plugin->close(mixer); } diff --git a/src/mixer_api.h b/src/mixer_api.h index 48f962ed7..c8f219d83 100644 --- a/src/mixer_api.h +++ b/src/mixer_api.h @@ -99,4 +99,6 @@ mixer_set_volume(struct mixer *mixer, unsigned volume) return mixer->plugin->set_volume(mixer, volume); } +void mixer_disable_all(void); + #endif diff --git a/src/volume.c b/src/volume.c index 3ff42b9be..46d6118d4 100644 --- a/src/volume.c +++ b/src/volume.c @@ -24,6 +24,7 @@ #include "config.h" #include "audio.h" #include "output_all.h" +#include "mixer_api.h" #include <glib.h> @@ -140,8 +141,10 @@ void volume_init(void) if (param) { if (strcmp(param->value, VOLUME_MIXER_SOFTWARE) == 0) { volume_mixer_type = VOLUME_MIXER_TYPE_SOFTWARE; + mixer_disable_all(); } else if (strcmp(param->value, VOLUME_MIXER_DISABLED) == 0) { volume_mixer_type = VOLUME_MIXER_TYPE_DISABLED; + mixer_disable_all(); } else if (strcmp(param->value, VOLUME_MIXER_HARDWARE) == 0) { //nothing to do } else { |