jpayne@69: /** jpayne@69: * \file include/mixer.h jpayne@69: * \brief Application interface library for the ALSA driver jpayne@69: * \author Jaroslav Kysela jpayne@69: * \author Abramo Bagnara jpayne@69: * \author Takashi Iwai jpayne@69: * \date 1998-2001 jpayne@69: * jpayne@69: * Application interface library for the ALSA driver jpayne@69: */ jpayne@69: /* jpayne@69: * This library is free software; you can redistribute it and/or modify jpayne@69: * it under the terms of the GNU Lesser General Public License as jpayne@69: * published by the Free Software Foundation; either version 2.1 of jpayne@69: * the License, or (at your option) any later version. jpayne@69: * jpayne@69: * This program is distributed in the hope that it will be useful, jpayne@69: * but WITHOUT ANY WARRANTY; without even the implied warranty of jpayne@69: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jpayne@69: * GNU Lesser General Public License for more details. jpayne@69: * jpayne@69: * You should have received a copy of the GNU Lesser General Public jpayne@69: * License along with this library; if not, write to the Free Software jpayne@69: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA jpayne@69: * jpayne@69: */ jpayne@69: jpayne@69: #ifndef __ALSA_MIXER_H jpayne@69: #define __ALSA_MIXER_H jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \defgroup Mixer Mixer Interface jpayne@69: * The mixer interface. jpayne@69: * \{ jpayne@69: */ jpayne@69: jpayne@69: /** Mixer handle */ jpayne@69: typedef struct _snd_mixer snd_mixer_t; jpayne@69: /** Mixer elements class handle */ jpayne@69: typedef struct _snd_mixer_class snd_mixer_class_t; jpayne@69: /** Mixer element handle */ jpayne@69: typedef struct _snd_mixer_elem snd_mixer_elem_t; jpayne@69: jpayne@69: /** jpayne@69: * \brief Mixer callback function jpayne@69: * \param mixer Mixer handle jpayne@69: * \param mask event mask jpayne@69: * \param elem related mixer element (if any) jpayne@69: * \return 0 on success otherwise a negative error code jpayne@69: */ jpayne@69: typedef int (*snd_mixer_callback_t)(snd_mixer_t *ctl, jpayne@69: unsigned int mask, jpayne@69: snd_mixer_elem_t *elem); jpayne@69: jpayne@69: /** jpayne@69: * \brief Mixer element callback function jpayne@69: * \param elem Mixer element jpayne@69: * \param mask event mask jpayne@69: * \return 0 on success otherwise a negative error code jpayne@69: */ jpayne@69: typedef int (*snd_mixer_elem_callback_t)(snd_mixer_elem_t *elem, jpayne@69: unsigned int mask); jpayne@69: jpayne@69: /** jpayne@69: * \brief Compare function for sorting mixer elements jpayne@69: * \param e1 First element jpayne@69: * \param e2 Second element jpayne@69: * \return -1 if e1 < e2, 0 if e1 == e2, 1 if e1 > e2 jpayne@69: */ jpayne@69: typedef int (*snd_mixer_compare_t)(const snd_mixer_elem_t *e1, jpayne@69: const snd_mixer_elem_t *e2); jpayne@69: jpayne@69: /** jpayne@69: * \brief Event callback for the mixer class jpayne@69: * \param class_ Mixer class jpayne@69: * \param mask Event mask (SND_CTL_EVENT_*) jpayne@69: * \param helem HCTL element which invoked the event jpayne@69: * \param melem Mixer element associated to HCTL element jpayne@69: * \return zero if success, otherwise a negative error value jpayne@69: */ jpayne@69: typedef int (*snd_mixer_event_t)(snd_mixer_class_t *class_, unsigned int mask, jpayne@69: snd_hctl_elem_t *helem, snd_mixer_elem_t *melem); jpayne@69: jpayne@69: jpayne@69: /** Mixer element type */ jpayne@69: typedef enum _snd_mixer_elem_type { jpayne@69: /* Simple mixer elements */ jpayne@69: SND_MIXER_ELEM_SIMPLE, jpayne@69: SND_MIXER_ELEM_LAST = SND_MIXER_ELEM_SIMPLE jpayne@69: } snd_mixer_elem_type_t; jpayne@69: jpayne@69: int snd_mixer_open(snd_mixer_t **mixer, int mode); jpayne@69: int snd_mixer_close(snd_mixer_t *mixer); jpayne@69: snd_mixer_elem_t *snd_mixer_first_elem(snd_mixer_t *mixer); jpayne@69: snd_mixer_elem_t *snd_mixer_last_elem(snd_mixer_t *mixer); jpayne@69: int snd_mixer_handle_events(snd_mixer_t *mixer); jpayne@69: int snd_mixer_attach(snd_mixer_t *mixer, const char *name); jpayne@69: int snd_mixer_attach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl); jpayne@69: int snd_mixer_detach(snd_mixer_t *mixer, const char *name); jpayne@69: int snd_mixer_detach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl); jpayne@69: int snd_mixer_get_hctl(snd_mixer_t *mixer, const char *name, snd_hctl_t **hctl); jpayne@69: int snd_mixer_poll_descriptors_count(snd_mixer_t *mixer); jpayne@69: int snd_mixer_poll_descriptors(snd_mixer_t *mixer, struct pollfd *pfds, unsigned int space); jpayne@69: int snd_mixer_poll_descriptors_revents(snd_mixer_t *mixer, struct pollfd *pfds, unsigned int nfds, unsigned short *revents); jpayne@69: int snd_mixer_load(snd_mixer_t *mixer); jpayne@69: void snd_mixer_free(snd_mixer_t *mixer); jpayne@69: int snd_mixer_wait(snd_mixer_t *mixer, int timeout); jpayne@69: int snd_mixer_set_compare(snd_mixer_t *mixer, snd_mixer_compare_t msort); jpayne@69: void snd_mixer_set_callback(snd_mixer_t *obj, snd_mixer_callback_t val); jpayne@69: void * snd_mixer_get_callback_private(const snd_mixer_t *obj); jpayne@69: void snd_mixer_set_callback_private(snd_mixer_t *obj, void * val); jpayne@69: unsigned int snd_mixer_get_count(const snd_mixer_t *obj); jpayne@69: int snd_mixer_class_unregister(snd_mixer_class_t *clss); jpayne@69: jpayne@69: snd_mixer_elem_t *snd_mixer_elem_next(snd_mixer_elem_t *elem); jpayne@69: snd_mixer_elem_t *snd_mixer_elem_prev(snd_mixer_elem_t *elem); jpayne@69: void snd_mixer_elem_set_callback(snd_mixer_elem_t *obj, snd_mixer_elem_callback_t val); jpayne@69: void * snd_mixer_elem_get_callback_private(const snd_mixer_elem_t *obj); jpayne@69: void snd_mixer_elem_set_callback_private(snd_mixer_elem_t *obj, void * val); jpayne@69: snd_mixer_elem_type_t snd_mixer_elem_get_type(const snd_mixer_elem_t *obj); jpayne@69: jpayne@69: int snd_mixer_class_register(snd_mixer_class_t *class_, snd_mixer_t *mixer); jpayne@69: int snd_mixer_elem_new(snd_mixer_elem_t **elem, jpayne@69: snd_mixer_elem_type_t type, jpayne@69: int compare_weight, jpayne@69: void *private_data, jpayne@69: void (*private_free)(snd_mixer_elem_t *elem)); jpayne@69: int snd_mixer_elem_add(snd_mixer_elem_t *elem, snd_mixer_class_t *class_); jpayne@69: int snd_mixer_elem_remove(snd_mixer_elem_t *elem); jpayne@69: void snd_mixer_elem_free(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_elem_info(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_elem_value(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_elem_attach(snd_mixer_elem_t *melem, snd_hctl_elem_t *helem); jpayne@69: int snd_mixer_elem_detach(snd_mixer_elem_t *melem, snd_hctl_elem_t *helem); jpayne@69: int snd_mixer_elem_empty(snd_mixer_elem_t *melem); jpayne@69: void *snd_mixer_elem_get_private(const snd_mixer_elem_t *melem); jpayne@69: jpayne@69: size_t snd_mixer_class_sizeof(void); jpayne@69: /** \hideinitializer jpayne@69: * \brief allocate an invalid #snd_mixer_class_t using standard alloca jpayne@69: * \param ptr returned pointer jpayne@69: */ jpayne@69: #define snd_mixer_class_alloca(ptr) __snd_alloca(ptr, snd_mixer_class) jpayne@69: int snd_mixer_class_malloc(snd_mixer_class_t **ptr); jpayne@69: void snd_mixer_class_free(snd_mixer_class_t *obj); jpayne@69: void snd_mixer_class_copy(snd_mixer_class_t *dst, const snd_mixer_class_t *src); jpayne@69: snd_mixer_t *snd_mixer_class_get_mixer(const snd_mixer_class_t *class_); jpayne@69: snd_mixer_event_t snd_mixer_class_get_event(const snd_mixer_class_t *class_); jpayne@69: void *snd_mixer_class_get_private(const snd_mixer_class_t *class_); jpayne@69: snd_mixer_compare_t snd_mixer_class_get_compare(const snd_mixer_class_t *class_); jpayne@69: int snd_mixer_class_set_event(snd_mixer_class_t *class_, snd_mixer_event_t event); jpayne@69: int snd_mixer_class_set_private(snd_mixer_class_t *class_, void *private_data); jpayne@69: int snd_mixer_class_set_private_free(snd_mixer_class_t *class_, void (*private_free)(snd_mixer_class_t *)); jpayne@69: int snd_mixer_class_set_compare(snd_mixer_class_t *class_, snd_mixer_compare_t compare); jpayne@69: jpayne@69: /** jpayne@69: * \defgroup SimpleMixer Simple Mixer Interface jpayne@69: * \ingroup Mixer jpayne@69: * The simple mixer interface. jpayne@69: * \{ jpayne@69: */ jpayne@69: jpayne@69: /* Simple mixer elements API */ jpayne@69: jpayne@69: /** Mixer simple element channel identifier */ jpayne@69: typedef enum _snd_mixer_selem_channel_id { jpayne@69: /** Unknown */ jpayne@69: SND_MIXER_SCHN_UNKNOWN = -1, jpayne@69: /** Front left */ jpayne@69: SND_MIXER_SCHN_FRONT_LEFT = 0, jpayne@69: /** Front right */ jpayne@69: SND_MIXER_SCHN_FRONT_RIGHT, jpayne@69: /** Rear left */ jpayne@69: SND_MIXER_SCHN_REAR_LEFT, jpayne@69: /** Rear right */ jpayne@69: SND_MIXER_SCHN_REAR_RIGHT, jpayne@69: /** Front center */ jpayne@69: SND_MIXER_SCHN_FRONT_CENTER, jpayne@69: /** Woofer */ jpayne@69: SND_MIXER_SCHN_WOOFER, jpayne@69: /** Side Left */ jpayne@69: SND_MIXER_SCHN_SIDE_LEFT, jpayne@69: /** Side Right */ jpayne@69: SND_MIXER_SCHN_SIDE_RIGHT, jpayne@69: /** Rear Center */ jpayne@69: SND_MIXER_SCHN_REAR_CENTER, jpayne@69: SND_MIXER_SCHN_LAST = 31, jpayne@69: /** Mono (Front left alias) */ jpayne@69: SND_MIXER_SCHN_MONO = SND_MIXER_SCHN_FRONT_LEFT jpayne@69: } snd_mixer_selem_channel_id_t; jpayne@69: jpayne@69: /** Mixer simple element - register options - abstraction level */ jpayne@69: enum snd_mixer_selem_regopt_abstract { jpayne@69: /** no abstraction - try use all universal controls from driver */ jpayne@69: SND_MIXER_SABSTRACT_NONE = 0, jpayne@69: /** basic abstraction - Master,PCM,CD,Aux,Record-Gain etc. */ jpayne@69: SND_MIXER_SABSTRACT_BASIC, jpayne@69: }; jpayne@69: jpayne@69: /** Mixer simple element - register options */ jpayne@69: struct snd_mixer_selem_regopt { jpayne@69: /** structure version */ jpayne@69: int ver; jpayne@69: /** v1: abstract layer selection */ jpayne@69: enum snd_mixer_selem_regopt_abstract abstract; jpayne@69: /** v1: device name (must be NULL when playback_pcm or capture_pcm != NULL) */ jpayne@69: const char *device; jpayne@69: /** v1: playback PCM connected to mixer device (NULL == none) */ jpayne@69: snd_pcm_t *playback_pcm; jpayne@69: /** v1: capture PCM connected to mixer device (NULL == none) */ jpayne@69: snd_pcm_t *capture_pcm; jpayne@69: }; jpayne@69: jpayne@69: /** Mixer simple element identifier */ jpayne@69: typedef struct _snd_mixer_selem_id snd_mixer_selem_id_t; jpayne@69: jpayne@69: const char *snd_mixer_selem_channel_name(snd_mixer_selem_channel_id_t channel); jpayne@69: jpayne@69: int snd_mixer_selem_register(snd_mixer_t *mixer, jpayne@69: struct snd_mixer_selem_regopt *options, jpayne@69: snd_mixer_class_t **classp); jpayne@69: void snd_mixer_selem_get_id(snd_mixer_elem_t *element, jpayne@69: snd_mixer_selem_id_t *id); jpayne@69: const char *snd_mixer_selem_get_name(snd_mixer_elem_t *elem); jpayne@69: unsigned int snd_mixer_selem_get_index(snd_mixer_elem_t *elem); jpayne@69: snd_mixer_elem_t *snd_mixer_find_selem(snd_mixer_t *mixer, jpayne@69: const snd_mixer_selem_id_t *id); jpayne@69: jpayne@69: int snd_mixer_selem_is_active(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_is_playback_mono(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_playback_channel(snd_mixer_elem_t *obj, snd_mixer_selem_channel_id_t channel); jpayne@69: int snd_mixer_selem_is_capture_mono(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_capture_channel(snd_mixer_elem_t *obj, snd_mixer_selem_channel_id_t channel); jpayne@69: int snd_mixer_selem_get_capture_group(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_common_volume(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_playback_volume(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_playback_volume_joined(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_capture_volume(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_capture_volume_joined(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_common_switch(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_playback_switch(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_playback_switch_joined(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_capture_switch(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_capture_switch_joined(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_has_capture_switch_exclusive(snd_mixer_elem_t *elem); jpayne@69: jpayne@69: int snd_mixer_selem_ask_playback_vol_dB(snd_mixer_elem_t *elem, long value, long *dBvalue); jpayne@69: int snd_mixer_selem_ask_capture_vol_dB(snd_mixer_elem_t *elem, long value, long *dBvalue); jpayne@69: int snd_mixer_selem_ask_playback_dB_vol(snd_mixer_elem_t *elem, long dBvalue, int dir, long *value); jpayne@69: int snd_mixer_selem_ask_capture_dB_vol(snd_mixer_elem_t *elem, long dBvalue, int dir, long *value); jpayne@69: int snd_mixer_selem_get_playback_volume(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long *value); jpayne@69: int snd_mixer_selem_get_capture_volume(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long *value); jpayne@69: int snd_mixer_selem_get_playback_dB(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long *value); jpayne@69: int snd_mixer_selem_get_capture_dB(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long *value); jpayne@69: int snd_mixer_selem_get_playback_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int *value); jpayne@69: int snd_mixer_selem_get_capture_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int *value); jpayne@69: int snd_mixer_selem_set_playback_volume(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value); jpayne@69: int snd_mixer_selem_set_capture_volume(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value); jpayne@69: int snd_mixer_selem_set_playback_dB(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value, int dir); jpayne@69: int snd_mixer_selem_set_capture_dB(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value, int dir); jpayne@69: int snd_mixer_selem_set_playback_volume_all(snd_mixer_elem_t *elem, long value); jpayne@69: int snd_mixer_selem_set_capture_volume_all(snd_mixer_elem_t *elem, long value); jpayne@69: int snd_mixer_selem_set_playback_dB_all(snd_mixer_elem_t *elem, long value, int dir); jpayne@69: int snd_mixer_selem_set_capture_dB_all(snd_mixer_elem_t *elem, long value, int dir); jpayne@69: int snd_mixer_selem_set_playback_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int value); jpayne@69: int snd_mixer_selem_set_capture_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int value); jpayne@69: int snd_mixer_selem_set_playback_switch_all(snd_mixer_elem_t *elem, int value); jpayne@69: int snd_mixer_selem_set_capture_switch_all(snd_mixer_elem_t *elem, int value); jpayne@69: int snd_mixer_selem_get_playback_volume_range(snd_mixer_elem_t *elem, jpayne@69: long *min, long *max); jpayne@69: int snd_mixer_selem_get_playback_dB_range(snd_mixer_elem_t *elem, jpayne@69: long *min, long *max); jpayne@69: int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem, jpayne@69: long min, long max); jpayne@69: int snd_mixer_selem_get_capture_volume_range(snd_mixer_elem_t *elem, jpayne@69: long *min, long *max); jpayne@69: int snd_mixer_selem_get_capture_dB_range(snd_mixer_elem_t *elem, jpayne@69: long *min, long *max); jpayne@69: int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem, jpayne@69: long min, long max); jpayne@69: jpayne@69: int snd_mixer_selem_is_enumerated(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_is_enum_playback(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_is_enum_capture(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_get_enum_items(snd_mixer_elem_t *elem); jpayne@69: int snd_mixer_selem_get_enum_item_name(snd_mixer_elem_t *elem, unsigned int idx, size_t maxlen, char *str); jpayne@69: int snd_mixer_selem_get_enum_item(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, unsigned int *idxp); jpayne@69: int snd_mixer_selem_set_enum_item(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, unsigned int idx); jpayne@69: jpayne@69: size_t snd_mixer_selem_id_sizeof(void); jpayne@69: /** \hideinitializer jpayne@69: * \brief allocate an invalid #snd_mixer_selem_id_t using standard alloca jpayne@69: * \param ptr returned pointer jpayne@69: */ jpayne@69: #define snd_mixer_selem_id_alloca(ptr) __snd_alloca(ptr, snd_mixer_selem_id) jpayne@69: int snd_mixer_selem_id_malloc(snd_mixer_selem_id_t **ptr); jpayne@69: void snd_mixer_selem_id_free(snd_mixer_selem_id_t *obj); jpayne@69: void snd_mixer_selem_id_copy(snd_mixer_selem_id_t *dst, const snd_mixer_selem_id_t *src); jpayne@69: const char *snd_mixer_selem_id_get_name(const snd_mixer_selem_id_t *obj); jpayne@69: unsigned int snd_mixer_selem_id_get_index(const snd_mixer_selem_id_t *obj); jpayne@69: void snd_mixer_selem_id_set_name(snd_mixer_selem_id_t *obj, const char *val); jpayne@69: void snd_mixer_selem_id_set_index(snd_mixer_selem_id_t *obj, unsigned int val); jpayne@69: int snd_mixer_selem_id_parse(snd_mixer_selem_id_t *dst, const char *str); jpayne@69: jpayne@69: /** \} */ jpayne@69: jpayne@69: /** \} */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #endif /* __ALSA_MIXER_H */ jpayne@69: