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).
This commit is contained in:
Max Kellermann 2009-03-14 11:36:50 +01:00
parent 8d01110c84
commit a5017a2d7c
12 changed files with 113 additions and 82 deletions

View File

@ -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)

View File

@ -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>

View File

@ -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"

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -19,6 +19,7 @@
#include "../output_api.h"
#include "../mixer_api.h"
#include "mixer_control.h"
#include <glib.h>
#include <alsa/asoundlib.h>

View File

@ -19,6 +19,7 @@
#include "../output_api.h"
#include "../mixer_api.h"
#include "mixer_control.h"
#include <glib.h>

View File

@ -19,6 +19,7 @@
#include "../output_api.h"
#include "../mixer_api.h"
#include "mixer_control.h"
#include <glib.h>
#include <pulse/simple.h>

View File

@ -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

View File

@ -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>