diff options
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | src/audio.c | 1 | ||||
-rw-r--r-- | src/mixer_all.c | 2 | ||||
-rw-r--r-- | src/mixer_api.c | 55 | ||||
-rw-r--r-- | src/mixer_api.h | 23 | ||||
-rw-r--r-- | src/mixer_control.c | 76 | ||||
-rw-r--r-- | src/mixer_control.h | 30 | ||||
-rw-r--r-- | src/output/alsa_plugin.c | 1 | ||||
-rw-r--r-- | src/output/oss_plugin.c | 1 | ||||
-rw-r--r-- | src/output/pulse_plugin.c | 1 | ||||
-rw-r--r-- | src/output_command.c | 2 | ||||
-rw-r--r-- | src/volume.c | 2 |
12 files changed, 113 insertions, 82 deletions
diff --git a/Makefile.am b/Makefile.am index bc5e58f54..e93e3413f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -602,6 +602,7 @@ test_run_output_SOURCES = test/run_output.c \ src/output_init.c src/output_list.c \ $(ENCODER_SRC) \ src/mixer_api.c \ + src/mixer_control.c \ $(MIXER_SRC) \ $(OUTPUT_SRC) diff --git a/src/audio.c b/src/audio.c index 1b0d3262d..d48558e46 100644 --- a/src/audio.c +++ b/src/audio.c @@ -23,7 +23,6 @@ #include "output_internal.h" #include "output_plugin.h" #include "output_all.h" -#include "mixer_api.h" #include "conf.h" #include <glib.h> diff --git a/src/mixer_all.c b/src/mixer_all.c index b4ac024b9..34b16c4b7 100644 --- a/src/mixer_all.c +++ b/src/mixer_all.c @@ -18,7 +18,7 @@ */ #include "mixer_all.h" -#include "mixer_api.h" +#include "mixer_control.h" #include "output_all.h" #include "output_plugin.h" #include "output_internal.h" diff --git a/src/mixer_api.c b/src/mixer_api.c index 8ec4f41bc..3c9f54e14 100644 --- a/src/mixer_api.c +++ b/src/mixer_api.c @@ -26,58 +26,3 @@ #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); - - 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); -} diff --git a/src/mixer_api.h b/src/mixer_api.h index 22858821c..a02ab2dd5 100644 --- a/src/mixer_api.h +++ b/src/mixer_api.h @@ -40,27 +40,4 @@ mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin) mixer->plugin = plugin; } -struct mixer * -mixer_new(const struct mixer_plugin *plugin, const struct config_param *param); - -void -mixer_free(struct mixer *mixer); - -bool mixer_open(struct mixer *mixer); -void mixer_close(struct mixer *mixer); - -static inline int -mixer_get_volume(struct mixer *mixer) -{ - return mixer->plugin->get_volume(mixer); -} - -static inline bool -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/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); +} diff --git a/src/mixer_control.h b/src/mixer_control.h index 4f3a97dbc..b126d8c81 100644 --- a/src/mixer_control.h +++ b/src/mixer_control.h @@ -17,9 +17,39 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +/** \file + * + * Functions which manipulate a #mixer object. + */ + #ifndef MPD_MIXER_CONTROL_H #define MPD_MIXER_CONTROL_H #include <stdbool.h> +struct mixer; +struct mixer_plugin; +struct config_param; + +void +mixer_disable_all(void); + +struct mixer * +mixer_new(const struct mixer_plugin *plugin, const struct config_param *param); + +void +mixer_free(struct mixer *mixer); + +bool +mixer_open(struct mixer *mixer); + +void +mixer_close(struct mixer *mixer); + +int +mixer_get_volume(struct mixer *mixer); + +bool +mixer_set_volume(struct mixer *mixer, unsigned volume); + #endif diff --git a/src/output/alsa_plugin.c b/src/output/alsa_plugin.c index ce7a737da..15728a10f 100644 --- a/src/output/alsa_plugin.c +++ b/src/output/alsa_plugin.c @@ -19,6 +19,7 @@ #include "../output_api.h" #include "../mixer_api.h" +#include "mixer_control.h" #include <glib.h> #include <alsa/asoundlib.h> diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c index 399a29146..b3a2257b7 100644 --- a/src/output/oss_plugin.c +++ b/src/output/oss_plugin.c @@ -19,6 +19,7 @@ #include "../output_api.h" #include "../mixer_api.h" +#include "mixer_control.h" #include <glib.h> diff --git a/src/output/pulse_plugin.c b/src/output/pulse_plugin.c index 109ccd3b9..b62b431a5 100644 --- a/src/output/pulse_plugin.c +++ b/src/output/pulse_plugin.c @@ -19,6 +19,7 @@ #include "../output_api.h" #include "../mixer_api.h" +#include "mixer_control.h" #include <glib.h> #include <pulse/simple.h> diff --git a/src/output_command.c b/src/output_command.c index 48985f5f9..7f16a79d7 100644 --- a/src/output_command.c +++ b/src/output_command.c @@ -28,7 +28,7 @@ #include "output_all.h" #include "output_internal.h" #include "output_plugin.h" -#include "mixer_api.h" +#include "mixer_control.h" #include "idle.h" bool diff --git a/src/volume.c b/src/volume.c index a7bae9627..e120df403 100644 --- a/src/volume.c +++ b/src/volume.c @@ -24,7 +24,7 @@ #include "pcm_volume.h" #include "config.h" #include "output_all.h" -#include "mixer_api.h" +#include "mixer_control.h" #include "mixer_all.h" #include <glib.h> |