2009-01-25 17:37:50 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003-2009 The Music Player Daemon Project
|
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2009-01-25 17:37:50 +01:00
|
|
|
*/
|
2008-12-31 16:46:41 +01:00
|
|
|
|
|
|
|
#ifndef MPD_MIXER_H
|
|
|
|
#define MPD_MIXER_H
|
|
|
|
|
2009-02-16 18:40:04 +01:00
|
|
|
#include <stdbool.h>
|
2008-12-31 16:46:41 +01:00
|
|
|
|
2009-01-10 17:53:33 +01:00
|
|
|
/*
|
|
|
|
* list of currently implemented mixers
|
2008-12-31 16:46:41 +01:00
|
|
|
*/
|
|
|
|
|
2009-01-25 17:37:52 +01:00
|
|
|
extern const struct mixer_plugin alsa_mixer;
|
|
|
|
extern const struct mixer_plugin oss_mixer;
|
2009-03-06 18:21:23 +01:00
|
|
|
extern const struct mixer_plugin pulse_mixer;
|
2009-01-10 17:53:33 +01:00
|
|
|
|
2009-02-16 18:40:04 +01:00
|
|
|
struct config_param;
|
|
|
|
|
2009-01-10 17:53:33 +01:00
|
|
|
struct mixer_plugin {
|
2009-01-25 17:38:12 +01:00
|
|
|
/**
|
|
|
|
* Alocates and configures a mixer device.
|
2009-01-10 17:53:33 +01:00
|
|
|
*/
|
2009-01-25 17:45:16 +01:00
|
|
|
struct mixer *(*init)(const struct config_param *param);
|
2009-01-10 17:53:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finish and free mixer data
|
|
|
|
*/
|
2009-01-25 17:45:16 +01:00
|
|
|
void (*finish)(struct mixer *data);
|
2009-01-10 17:53:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Open mixer device
|
|
|
|
*/
|
2009-01-25 17:45:16 +01:00
|
|
|
bool (*open)(struct mixer *data);
|
2009-01-10 17:53:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Close mixer device
|
|
|
|
*/
|
2009-01-25 17:45:16 +01:00
|
|
|
void (*close)(struct mixer *data);
|
2009-02-16 01:39:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads the current volume.
|
|
|
|
*
|
|
|
|
* @return the current volume (0..100 including) or -1 on
|
|
|
|
* error
|
|
|
|
*/
|
|
|
|
int (*get_volume)(struct mixer *mixer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the volume.
|
|
|
|
*
|
|
|
|
* @param volume the new volume (0..100 including)
|
|
|
|
* @return true on success
|
|
|
|
*/
|
|
|
|
bool (*set_volume)(struct mixer *mixer, unsigned volume);
|
2009-01-10 17:53:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mixer {
|
2009-01-25 17:37:52 +01:00
|
|
|
const struct mixer_plugin *plugin;
|
2009-01-10 17:53:33 +01:00
|
|
|
};
|
|
|
|
|
2009-01-25 17:45:16 +01:00
|
|
|
static inline void
|
|
|
|
mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin)
|
|
|
|
{
|
|
|
|
mixer->plugin = plugin;
|
|
|
|
}
|
2009-01-25 17:37:55 +01:00
|
|
|
|
|
|
|
struct mixer *
|
2009-01-25 17:37:59 +01:00
|
|
|
mixer_new(const struct mixer_plugin *plugin, const struct config_param *param);
|
2009-01-25 17:37:55 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
mixer_free(struct mixer *mixer);
|
|
|
|
|
2009-01-10 17:53:33 +01:00
|
|
|
bool mixer_open(struct mixer *mixer);
|
|
|
|
void mixer_close(struct mixer *mixer);
|
2008-12-31 16:46:41 +01:00
|
|
|
|
2009-02-16 01:39:52 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-03-02 18:39:43 +01:00
|
|
|
void mixer_disable_all(void);
|
|
|
|
|
2008-12-31 16:46:41 +01:00
|
|
|
#endif
|