mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
More documentation. Added mode argument to i/o_stdio_open.
This commit is contained in:
parent
53fc0f6332
commit
de4cfc3e4b
12 changed files with 1525 additions and 784 deletions
|
|
@ -118,7 +118,7 @@ static int get_char_skip_comments(input_t *input)
|
|||
int err = get_delimstring(&file, '>', input);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_input_stdio_open(&in, file);
|
||||
err = snd_input_stdio_open(&in, file, "r");
|
||||
if (err < 0)
|
||||
return err;
|
||||
fd = malloc(sizeof(*fd));
|
||||
|
|
@ -1220,7 +1220,7 @@ int snd_config_update()
|
|||
err = snd_config_top(&snd_config);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_input_stdio_open(&in, SYS_ASOUNDRC);
|
||||
err = snd_input_stdio_open(&in, SYS_ASOUNDRC, "r");
|
||||
if (err >= 0) {
|
||||
err = snd_config_load(snd_config, in);
|
||||
snd_input_close(in);
|
||||
|
|
@ -1233,7 +1233,7 @@ int snd_config_update()
|
|||
sys_asoundrc_inode = sys_st.st_ino;
|
||||
sys_asoundrc_mtime = sys_st.st_mtime;
|
||||
}
|
||||
err = snd_input_stdio_open(&in, usr_asoundrc);
|
||||
err = snd_input_stdio_open(&in, usr_asoundrc, "r");
|
||||
if (err >= 0) {
|
||||
err = snd_config_load(snd_config, in);
|
||||
snd_input_close(in);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
EXTRA_LTLIBRARIES = libcontrol.la
|
||||
|
||||
libcontrol_la_SOURCES = cards.c hcontrol.c defaults.c \
|
||||
control.c control_m4.c control_hw.c control_shm.c
|
||||
control.c control_hw.c control_shm.c
|
||||
|
||||
noinst_HEADERS = control_local.h
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,753 +0,0 @@
|
|||
/*
|
||||
* Control - Automatically generated functions
|
||||
* Copyright (c) 2001 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "control_local.h"
|
||||
|
||||
size_t snd_ctl_elem_id_sizeof()
|
||||
{
|
||||
return sizeof(snd_ctl_elem_id_t);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr)
|
||||
{
|
||||
assert(ptr);
|
||||
*ptr = calloc(1, sizeof(snd_ctl_elem_id_t));
|
||||
if (!*ptr)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
void snd_ctl_elem_id_copy(snd_ctl_elem_id_t *dst, const snd_ctl_elem_id_t *src)
|
||||
{
|
||||
assert(dst && src);
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->numid;
|
||||
}
|
||||
|
||||
snd_ctl_elem_iface_t snd_ctl_elem_id_get_interface(const snd_ctl_elem_id_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return snd_int_to_enum(obj->iface);
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_id_get_device(const snd_ctl_elem_id_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->device;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_id_get_subdevice(const snd_ctl_elem_id_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->subdevice;
|
||||
}
|
||||
|
||||
const char *snd_ctl_elem_id_get_name(const snd_ctl_elem_id_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->name;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_id_get_index(const snd_ctl_elem_id_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->index;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_id_set_numid(snd_ctl_elem_id_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->numid = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_id_set_interface(snd_ctl_elem_id_t *obj, snd_ctl_elem_iface_t val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->iface = snd_enum_to_int(val);
|
||||
}
|
||||
|
||||
void snd_ctl_elem_id_set_device(snd_ctl_elem_id_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->device = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_id_set_subdevice(snd_ctl_elem_id_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->subdevice = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_id_set_name(snd_ctl_elem_id_t *obj, const char *val)
|
||||
{
|
||||
assert(obj);
|
||||
strncpy(obj->name, val, sizeof(obj->name));
|
||||
}
|
||||
|
||||
void snd_ctl_elem_id_set_index(snd_ctl_elem_id_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->index = val;
|
||||
}
|
||||
|
||||
size_t snd_ctl_card_info_sizeof()
|
||||
{
|
||||
return sizeof(snd_ctl_card_info_t);
|
||||
}
|
||||
|
||||
int snd_ctl_card_info_malloc(snd_ctl_card_info_t **ptr)
|
||||
{
|
||||
assert(ptr);
|
||||
*ptr = calloc(1, sizeof(snd_ctl_card_info_t));
|
||||
if (!*ptr)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_ctl_card_info_free(snd_ctl_card_info_t *obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
void snd_ctl_card_info_copy(snd_ctl_card_info_t *dst, const snd_ctl_card_info_t *src)
|
||||
{
|
||||
assert(dst && src);
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
int snd_ctl_card_info_get_card(const snd_ctl_card_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->card;
|
||||
}
|
||||
|
||||
snd_card_type_t snd_ctl_card_info_get_type(const snd_ctl_card_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return snd_int_to_enum(obj->type);
|
||||
}
|
||||
|
||||
const char *snd_ctl_card_info_get_id(const snd_ctl_card_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id;
|
||||
}
|
||||
|
||||
const char *snd_ctl_card_info_get_abbreviation(const snd_ctl_card_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->abbreviation;
|
||||
}
|
||||
|
||||
const char *snd_ctl_card_info_get_name(const snd_ctl_card_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->name;
|
||||
}
|
||||
|
||||
const char *snd_ctl_card_info_get_longname(const snd_ctl_card_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->longname;
|
||||
}
|
||||
|
||||
const char *snd_ctl_card_info_get_mixerid(const snd_ctl_card_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->mixerid;
|
||||
}
|
||||
|
||||
const char *snd_ctl_card_info_get_mixername(const snd_ctl_card_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->mixername;
|
||||
}
|
||||
|
||||
size_t snd_ctl_event_sizeof()
|
||||
{
|
||||
return sizeof(snd_ctl_event_t);
|
||||
}
|
||||
|
||||
int snd_ctl_event_malloc(snd_ctl_event_t **ptr)
|
||||
{
|
||||
assert(ptr);
|
||||
*ptr = calloc(1, sizeof(snd_ctl_event_t));
|
||||
if (!*ptr)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_ctl_event_free(snd_ctl_event_t *obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
void snd_ctl_event_copy(snd_ctl_event_t *dst, const snd_ctl_event_t *src)
|
||||
{
|
||||
assert(dst && src);
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
snd_ctl_event_type_t snd_ctl_event_get_type(const snd_ctl_event_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return snd_int_to_enum(obj->type);
|
||||
}
|
||||
|
||||
size_t snd_ctl_elem_list_sizeof()
|
||||
{
|
||||
return sizeof(snd_ctl_elem_list_t);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_list_malloc(snd_ctl_elem_list_t **ptr)
|
||||
{
|
||||
assert(ptr);
|
||||
*ptr = calloc(1, sizeof(snd_ctl_elem_list_t));
|
||||
if (!*ptr)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_list_free(snd_ctl_elem_list_t *obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
void snd_ctl_elem_list_copy(snd_ctl_elem_list_t *dst, const snd_ctl_elem_list_t *src)
|
||||
{
|
||||
assert(dst && src);
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_list_set_offset(snd_ctl_elem_list_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->offset = val;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_list_get_used(const snd_ctl_elem_list_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->used;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_list_get_count(const snd_ctl_elem_list_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->count;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_list_get_id(const snd_ctl_elem_list_t *obj, unsigned int idx, snd_ctl_elem_id_t *ptr)
|
||||
{
|
||||
assert(obj && ptr);
|
||||
assert(idx < obj->used);
|
||||
*ptr = obj->pids[idx];
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_list_get_numid(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < obj->used);
|
||||
return obj->pids[idx].numid;
|
||||
}
|
||||
|
||||
snd_ctl_elem_iface_t snd_ctl_elem_list_get_interface(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < obj->used);
|
||||
return snd_int_to_enum(obj->pids[idx].iface);
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_list_get_device(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < obj->used);
|
||||
return obj->pids[idx].device;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_list_get_subdevice(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < obj->used);
|
||||
return obj->pids[idx].subdevice;
|
||||
}
|
||||
|
||||
const char *snd_ctl_elem_list_get_name(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < obj->used);
|
||||
return obj->pids[idx].name;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_list_get_index(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < obj->used);
|
||||
return obj->pids[idx].index;
|
||||
}
|
||||
|
||||
size_t snd_ctl_elem_info_sizeof()
|
||||
{
|
||||
return sizeof(snd_ctl_elem_info_t);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_info_malloc(snd_ctl_elem_info_t **ptr)
|
||||
{
|
||||
assert(ptr);
|
||||
*ptr = calloc(1, sizeof(snd_ctl_elem_info_t));
|
||||
if (!*ptr)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_free(snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_copy(snd_ctl_elem_info_t *dst, const snd_ctl_elem_info_t *src)
|
||||
{
|
||||
assert(dst && src);
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
snd_ctl_elem_type_t snd_ctl_elem_info_get_type(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return snd_int_to_enum(obj->type);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_info_is_readable(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_READ);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_info_is_writable(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_WRITE);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_info_is_volatile(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_VOLATILE);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_info_is_inactive(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_info_is_locked(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_LOCK);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_info_is_indirect(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_INDIRECT);
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_info_get_count(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->count;
|
||||
}
|
||||
|
||||
long snd_ctl_elem_info_get_min(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
assert(obj->type == SNDRV_CTL_ELEM_TYPE_INTEGER);
|
||||
return obj->value.integer.min;
|
||||
}
|
||||
|
||||
long snd_ctl_elem_info_get_max(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
assert(obj->type == SNDRV_CTL_ELEM_TYPE_INTEGER);
|
||||
return obj->value.integer.max;
|
||||
}
|
||||
|
||||
long snd_ctl_elem_info_get_step(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
assert(obj->type == SNDRV_CTL_ELEM_TYPE_INTEGER);
|
||||
return obj->value.integer.step;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_info_get_items(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
assert(obj->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED);
|
||||
return obj->value.enumerated.items;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_set_item(snd_ctl_elem_info_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->value.enumerated.item = val;
|
||||
}
|
||||
|
||||
const char *snd_ctl_elem_info_get_item_name(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
assert(obj->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED);
|
||||
return obj->value.enumerated.name;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_get_id(const snd_ctl_elem_info_t *obj, snd_ctl_elem_id_t *ptr)
|
||||
{
|
||||
assert(obj && ptr);
|
||||
*ptr = obj->id;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_info_get_numid(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.numid;
|
||||
}
|
||||
|
||||
snd_ctl_elem_iface_t snd_ctl_elem_info_get_interface(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return snd_int_to_enum(obj->id.iface);
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_info_get_device(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.device;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_info_get_subdevice(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.subdevice;
|
||||
}
|
||||
|
||||
const char *snd_ctl_elem_info_get_name(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.name;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_info_get_index(const snd_ctl_elem_info_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.index;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_set_id(snd_ctl_elem_info_t *obj, const snd_ctl_elem_id_t *ptr)
|
||||
{
|
||||
assert(obj && ptr);
|
||||
obj->id = *ptr;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_set_numid(snd_ctl_elem_info_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.numid = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_set_interface(snd_ctl_elem_info_t *obj, snd_ctl_elem_iface_t val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.iface = snd_enum_to_int(val);
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_set_device(snd_ctl_elem_info_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.device = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_set_subdevice(snd_ctl_elem_info_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.subdevice = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_set_name(snd_ctl_elem_info_t *obj, const char *val)
|
||||
{
|
||||
assert(obj);
|
||||
strncpy(obj->id.name, val, sizeof(obj->id.name));
|
||||
}
|
||||
|
||||
void snd_ctl_elem_info_set_index(snd_ctl_elem_info_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.index = val;
|
||||
}
|
||||
|
||||
size_t snd_ctl_elem_value_sizeof()
|
||||
{
|
||||
return sizeof(snd_ctl_elem_value_t);
|
||||
}
|
||||
|
||||
int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr)
|
||||
{
|
||||
assert(ptr);
|
||||
*ptr = calloc(1, sizeof(snd_ctl_elem_value_t));
|
||||
if (!*ptr)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_free(snd_ctl_elem_value_t *obj)
|
||||
{
|
||||
free(obj);
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_copy(snd_ctl_elem_value_t *dst, const snd_ctl_elem_value_t *src)
|
||||
{
|
||||
assert(dst && src);
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_get_id(const snd_ctl_elem_value_t *obj, snd_ctl_elem_id_t *ptr)
|
||||
{
|
||||
assert(obj && ptr);
|
||||
*ptr = obj->id;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_value_get_numid(const snd_ctl_elem_value_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.numid;
|
||||
}
|
||||
|
||||
snd_ctl_elem_iface_t snd_ctl_elem_value_get_interface(const snd_ctl_elem_value_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return snd_int_to_enum(obj->id.iface);
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_value_get_device(const snd_ctl_elem_value_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.device;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_value_get_subdevice(const snd_ctl_elem_value_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.subdevice;
|
||||
}
|
||||
|
||||
const char *snd_ctl_elem_value_get_name(const snd_ctl_elem_value_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.name;
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_value_get_index(const snd_ctl_elem_value_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.index;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_id(snd_ctl_elem_value_t *obj, const snd_ctl_elem_id_t *ptr)
|
||||
{
|
||||
assert(obj && ptr);
|
||||
obj->id = *ptr;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_numid(snd_ctl_elem_value_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.numid = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_interface(snd_ctl_elem_value_t *obj, snd_ctl_elem_iface_t val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.iface = snd_enum_to_int(val);
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_device(snd_ctl_elem_value_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.device = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_subdevice(snd_ctl_elem_value_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.subdevice = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_name(snd_ctl_elem_value_t *obj, const char *val)
|
||||
{
|
||||
assert(obj);
|
||||
strncpy(obj->id.name, val, sizeof(obj->id.name));
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->id.index = val;
|
||||
}
|
||||
|
||||
long snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < sizeof(obj->value.integer.value) / sizeof(obj->value.integer.value[0]));
|
||||
return obj->value.integer.value[idx];
|
||||
}
|
||||
|
||||
long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < sizeof(obj->value.integer.value) / sizeof(obj->value.integer.value[0]));
|
||||
return obj->value.integer.value[idx];
|
||||
}
|
||||
|
||||
unsigned int snd_ctl_elem_value_get_enumerated(const snd_ctl_elem_value_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < sizeof(obj->value.enumerated.item) / sizeof(obj->value.enumerated.item[0]));
|
||||
return obj->value.enumerated.item[idx];
|
||||
}
|
||||
|
||||
unsigned char snd_ctl_elem_value_get_byte(const snd_ctl_elem_value_t *obj, unsigned int idx)
|
||||
{
|
||||
assert(obj);
|
||||
assert(idx < sizeof(obj->value.bytes.data));
|
||||
return obj->value.bytes.data[idx];
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_boolean(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->value.integer.value[idx] = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_integer(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->value.integer.value[idx] = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_enumerated(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned int val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->value.enumerated.item[idx] = val;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned char val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->value.bytes.data[idx] = val;
|
||||
}
|
||||
|
||||
const void * snd_ctl_elem_value_get_bytes(const snd_ctl_elem_value_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->value.bytes.data;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_get_iec958(const snd_ctl_elem_value_t *obj, snd_aes_iec958_t *ptr)
|
||||
{
|
||||
assert(obj && ptr);
|
||||
*ptr = obj->value.iec958;
|
||||
}
|
||||
|
||||
void snd_ctl_elem_value_set_iec958(snd_ctl_elem_value_t *obj, const snd_aes_iec958_t *ptr)
|
||||
{
|
||||
assert(obj && ptr);
|
||||
obj->value.iec958 = *ptr;
|
||||
}
|
||||
|
||||
void snd_hctl_elem_get_id(const snd_hctl_elem_t *obj, snd_ctl_elem_id_t *ptr)
|
||||
{
|
||||
assert(obj && ptr);
|
||||
*ptr = obj->id;
|
||||
}
|
||||
|
||||
unsigned int snd_hctl_elem_get_numid(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.numid;
|
||||
}
|
||||
|
||||
snd_ctl_elem_iface_t snd_hctl_elem_get_interface(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return snd_int_to_enum(obj->id.iface);
|
||||
}
|
||||
|
||||
unsigned int snd_hctl_elem_get_device(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.device;
|
||||
}
|
||||
|
||||
unsigned int snd_hctl_elem_get_subdevice(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.subdevice;
|
||||
}
|
||||
|
||||
const char *snd_hctl_elem_get_name(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.name;
|
||||
}
|
||||
|
||||
unsigned int snd_hctl_elem_get_index(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.index;
|
||||
}
|
||||
|
||||
void snd_hctl_elem_set_callback(snd_hctl_elem_t *obj, snd_hctl_elem_callback_t val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->callback = val;
|
||||
}
|
||||
|
||||
void * snd_hctl_elem_get_callback_private(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->callback_private;
|
||||
}
|
||||
|
||||
void snd_hctl_elem_set_callback_private(snd_hctl_elem_t *obj, void * val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->callback_private = val;
|
||||
}
|
||||
|
||||
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* \file control/hcontrol.c
|
||||
* \author Jaroslav Kysela <perex@suse.cz>
|
||||
* \author Abramo Bagnara <abramo@alsa-project.org>
|
||||
* \date 2000
|
||||
*
|
||||
* HCTL interface is designed to access preloaded and sorted primitive controls.
|
||||
* Callbacks may be used for event handling.
|
||||
*/
|
||||
/*
|
||||
* Control Interface - highlevel API
|
||||
* Copyright (c) 2000 by Jaroslav Kysela <perex@suse.cz>
|
||||
|
|
@ -20,6 +29,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef DOC_HIDDEN
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -34,6 +44,15 @@
|
|||
static int snd_hctl_compare_default(const snd_hctl_elem_t *c1,
|
||||
const snd_hctl_elem_t *c2);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Opens an HCTL
|
||||
* \param hctlp Returned HCTL handle
|
||||
* \param name ASCII identifier of the underlying CTL handle
|
||||
* \param mode Open mode (see #SND_CTL_NONBLOCK, #SND_CTL_ASYNC)
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*/
|
||||
int snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode)
|
||||
{
|
||||
snd_hctl_t *hctl;
|
||||
|
|
@ -54,6 +73,14 @@ int snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief close HCTL handle
|
||||
* \param hctl HCTL handle
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*
|
||||
* Closes the specified HCTL handle and frees all associated
|
||||
* resources.
|
||||
*/
|
||||
int snd_hctl_close(snd_hctl_t *hctl)
|
||||
{
|
||||
int err;
|
||||
|
|
@ -65,37 +92,72 @@ int snd_hctl_close(snd_hctl_t *hctl)
|
|||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get identifier of HCTL handle
|
||||
* \param hctl HCTL handle
|
||||
* \return ascii identifier of HCTL handle
|
||||
*
|
||||
* Returns the ASCII identifier of given HCTL handle. It's the same
|
||||
* identifier specified in snd_hctl_open().
|
||||
*/
|
||||
const char *snd_hctl_name(snd_hctl_t *hctl)
|
||||
{
|
||||
assert(hctl);
|
||||
return snd_ctl_name(hctl->ctl);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set nonblock mode
|
||||
* \param hctl HCTL handle
|
||||
* \param nonblock 0 = block, 1 = nonblock mode
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*/
|
||||
int snd_hctl_nonblock(snd_hctl_t *hctl, int nonblock)
|
||||
{
|
||||
assert(hctl);
|
||||
return snd_ctl_nonblock(hctl->ctl, nonblock);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set async mode
|
||||
* \param hctl HCTL handle
|
||||
* \param sig Signal to raise: < 0 disable, 0 default (SIGIO)
|
||||
* \param pid Process ID to signal: 0 current
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*
|
||||
* A signal is raised when a change happens.
|
||||
*/
|
||||
int snd_hctl_async(snd_hctl_t *hctl, int sig, pid_t pid)
|
||||
{
|
||||
assert(hctl);
|
||||
return snd_ctl_async(hctl->ctl, sig, pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get count of poll descriptors for HCTL handle
|
||||
* \param hctl HCTL handle
|
||||
* \return count of poll descriptors
|
||||
*/
|
||||
int snd_hctl_poll_descriptors_count(snd_hctl_t *hctl)
|
||||
{
|
||||
assert(hctl);
|
||||
return snd_ctl_poll_descriptors_count(hctl->ctl);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get poll descriptors
|
||||
* \param hctl HCTL handle
|
||||
* \param pfds array of poll descriptors
|
||||
* \param space space in the poll descriptor array
|
||||
* \return count of filled descriptors
|
||||
*/
|
||||
int snd_hctl_poll_descriptors(snd_hctl_t *hctl, struct pollfd *pfds, unsigned int space)
|
||||
{
|
||||
assert(hctl);
|
||||
return snd_ctl_poll_descriptors(hctl->ctl, pfds, space);
|
||||
}
|
||||
|
||||
int snd_hctl_throw_event(snd_hctl_t *hctl, unsigned int mask,
|
||||
static int snd_hctl_throw_event(snd_hctl_t *hctl, unsigned int mask,
|
||||
snd_hctl_elem_t *elem)
|
||||
{
|
||||
if (hctl->callback)
|
||||
|
|
@ -103,7 +165,7 @@ int snd_hctl_throw_event(snd_hctl_t *hctl, unsigned int mask,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_hctl_elem_throw_event(snd_hctl_elem_t *elem,
|
||||
static int snd_hctl_elem_throw_event(snd_hctl_elem_t *elem,
|
||||
unsigned int mask)
|
||||
{
|
||||
if (elem->callback)
|
||||
|
|
@ -274,6 +336,11 @@ static void snd_hctl_elem_remove(snd_hctl_t *hctl, unsigned int idx)
|
|||
m * sizeof(snd_hctl_elem_t *));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief free HCTL loaded elements
|
||||
* \param hctl HCTL handle
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*/
|
||||
int snd_hctl_free(snd_hctl_t *hctl)
|
||||
{
|
||||
while (hctl->count > 0)
|
||||
|
|
@ -300,14 +367,26 @@ static void snd_hctl_sort(snd_hctl_t *hctl)
|
|||
list_add_tail(&hctl->pelems[k]->list, &hctl->elems);
|
||||
}
|
||||
|
||||
int snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t hsort)
|
||||
/**
|
||||
* \brief Change HCTL compare function and reorder elements
|
||||
* \param hctl HCTL handle
|
||||
* \param compare Element compare function
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*/
|
||||
int snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t compare)
|
||||
{
|
||||
assert(hctl);
|
||||
hctl->compare = hsort == NULL ? snd_hctl_compare_default : hsort;
|
||||
hctl->compare = compare == NULL ? snd_hctl_compare_default : compare;
|
||||
snd_hctl_sort(hctl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief A "don't care" fast compare functions that may be used with #snd_hctl_set_compare
|
||||
* \param c1 First HCTL element
|
||||
* \param c2 Second HCTL element
|
||||
* \return -1 if c1 < c2, 0 if c1 == c2, 1 if c1 > c2
|
||||
*/
|
||||
int snd_hctl_compare_fast(const snd_hctl_elem_t *c1,
|
||||
const snd_hctl_elem_t *c2)
|
||||
{
|
||||
|
|
@ -333,6 +412,11 @@ static int snd_hctl_compare_default(const snd_hctl_elem_t *c1,
|
|||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get first element for an HCTL
|
||||
* \param hctl HCTL handle
|
||||
* \return pointer to first element
|
||||
*/
|
||||
snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl)
|
||||
{
|
||||
assert(hctl);
|
||||
|
|
@ -341,6 +425,11 @@ snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl)
|
|||
return list_entry(hctl->elems.next, snd_hctl_elem_t, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get last element for an HCTL
|
||||
* \param hctl HCTL handle
|
||||
* \return pointer to last element
|
||||
*/
|
||||
snd_hctl_elem_t *snd_hctl_last_elem(snd_hctl_t *hctl)
|
||||
{
|
||||
assert(hctl);
|
||||
|
|
@ -349,6 +438,11 @@ snd_hctl_elem_t *snd_hctl_last_elem(snd_hctl_t *hctl)
|
|||
return list_entry(hctl->elems.prev, snd_hctl_elem_t, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get next HCTL element
|
||||
* \param elem HCTL element
|
||||
* \return pointer to next element
|
||||
*/
|
||||
snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem)
|
||||
{
|
||||
assert(elem);
|
||||
|
|
@ -357,6 +451,11 @@ snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem)
|
|||
return list_entry(elem->list.next, snd_hctl_elem_t, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get previous HCTL element
|
||||
* \param elem HCTL element
|
||||
* \return pointer to previous element
|
||||
*/
|
||||
snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem)
|
||||
{
|
||||
assert(elem);
|
||||
|
|
@ -365,6 +464,12 @@ snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem)
|
|||
return list_entry(elem->list.prev, snd_hctl_elem_t, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Search an HCTL element
|
||||
* \param hctl HCTL handle
|
||||
* \param id Element identificator
|
||||
* \return pointer to found HCTL element or NULL if it does not exists
|
||||
*/
|
||||
snd_hctl_elem_t *snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id)
|
||||
{
|
||||
int dir;
|
||||
|
|
@ -374,6 +479,11 @@ snd_hctl_elem_t *snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *i
|
|||
return hctl->pelems[res];
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Load an HCTL with all elements and sort them
|
||||
* \param hctl HCTL handle
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*/
|
||||
int snd_hctl_load(snd_hctl_t *hctl)
|
||||
{
|
||||
snd_ctl_elem_list_t list;
|
||||
|
|
@ -435,29 +545,55 @@ int snd_hctl_load(snd_hctl_t *hctl)
|
|||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set callback function for an HCTL
|
||||
* \param hctl HCTL handle
|
||||
* \param callback callback function
|
||||
*/
|
||||
void snd_hctl_set_callback(snd_hctl_t *hctl, snd_hctl_callback_t callback)
|
||||
{
|
||||
assert(hctl);
|
||||
hctl->callback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set callback private value for an HCTL
|
||||
* \param hctl HCTL handle
|
||||
* \param callback_private callback private value
|
||||
*/
|
||||
void snd_hctl_set_callback_private(snd_hctl_t *hctl, void *callback_private)
|
||||
{
|
||||
assert(hctl);
|
||||
hctl->callback_private = callback_private;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get callback private value for an HCTL
|
||||
* \param hctl HCTL handle
|
||||
* \return callback private value
|
||||
*/
|
||||
void *snd_hctl_get_callback_private(snd_hctl_t *hctl)
|
||||
{
|
||||
assert(hctl);
|
||||
return hctl->callback_private;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get number of loaded elements for an HCTL
|
||||
* \param hctl HCTL handle
|
||||
* \return elements count
|
||||
*/
|
||||
unsigned int snd_hctl_get_count(snd_hctl_t *hctl)
|
||||
{
|
||||
return hctl->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Wait for a HCTL to become ready (i.e. at least one event pending)
|
||||
* \param hctl HCTL handle
|
||||
* \param timeout maximum time in milliseconds to wait
|
||||
* \return 0 otherwise a negative error code on failure
|
||||
*/
|
||||
int snd_hctl_wait(snd_hctl_t *hctl, int timeout)
|
||||
{
|
||||
struct pollfd pfd;
|
||||
|
|
@ -470,7 +606,7 @@ int snd_hctl_wait(snd_hctl_t *hctl, int timeout)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
|
||||
static int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
|
||||
{
|
||||
snd_hctl_elem_t *elem;
|
||||
int res;
|
||||
|
|
@ -517,6 +653,11 @@ int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Handle pending HCTL events invoking callbacks
|
||||
* \param hctl HCTL handle
|
||||
* \return 0 otherwise a negative error code on failure
|
||||
*/
|
||||
int snd_hctl_handle_events(snd_hctl_t *hctl)
|
||||
{
|
||||
snd_ctl_event_t event;
|
||||
|
|
@ -537,6 +678,12 @@ int snd_hctl_handle_events(snd_hctl_t *hctl)
|
|||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get information for an HCTL element
|
||||
* \param elem HCTL element
|
||||
* \param info HCTL element information
|
||||
* \return 0 otherwise a negative error code on failure
|
||||
*/
|
||||
int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t *info)
|
||||
{
|
||||
assert(elem);
|
||||
|
|
@ -546,6 +693,12 @@ int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t *info)
|
|||
return snd_ctl_elem_info(elem->hctl->ctl, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get value for an HCTL element
|
||||
* \param elem HCTL element
|
||||
* \param value HCTL element value
|
||||
* \return 0 otherwise a negative error code on failure
|
||||
*/
|
||||
int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
|
||||
{
|
||||
assert(elem);
|
||||
|
|
@ -555,6 +708,12 @@ int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
|
|||
return snd_ctl_elem_read(elem->hctl->ctl, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set value for an HCTL element
|
||||
* \param elem HCTL element
|
||||
* \param value HCTL element value
|
||||
* \return 0 otherwise a negative error code on failure
|
||||
*/
|
||||
int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
|
||||
{
|
||||
assert(elem);
|
||||
|
|
@ -564,8 +723,124 @@ int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
|
|||
return snd_ctl_elem_write(elem->hctl->ctl, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get HCTL handle for an HCTL element
|
||||
* \param elem HCTL element
|
||||
* \return HCTL handle
|
||||
*/
|
||||
snd_hctl_t *snd_hctl_elem_get_hctl(snd_hctl_elem_t *elem)
|
||||
{
|
||||
assert(elem);
|
||||
return elem->hctl;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get CTL element identificator of a CTL element id/value
|
||||
* \param obj CTL element id/value
|
||||
* \param ptr Pointer to returned CTL element identificator
|
||||
*/
|
||||
void snd_hctl_elem_get_id(const snd_hctl_elem_t *obj, snd_ctl_elem_id_t *ptr)
|
||||
{
|
||||
assert(obj && ptr);
|
||||
*ptr = obj->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get element numeric identificator of a CTL element id/value
|
||||
* \param obj CTL element id/value
|
||||
* \return element numeric identificator
|
||||
*/
|
||||
unsigned int snd_hctl_elem_get_numid(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.numid;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get interface part of CTL element identificator of a CTL element id/value
|
||||
* \param obj CTL element id/value
|
||||
* \return interface part of element identificator
|
||||
*/
|
||||
snd_ctl_elem_iface_t snd_hctl_elem_get_interface(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return snd_int_to_enum(obj->id.iface);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get device part of CTL element identificator of a CTL element id/value
|
||||
* \param obj CTL element id/value
|
||||
* \return device part of element identificator
|
||||
*/
|
||||
unsigned int snd_hctl_elem_get_device(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.device;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get subdevice part of CTL element identificator of a CTL element id/value
|
||||
* \param obj CTL element id/value
|
||||
* \return subdevice part of element identificator
|
||||
*/
|
||||
unsigned int snd_hctl_elem_get_subdevice(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.subdevice;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get name part of CTL element identificator of a CTL element id/value
|
||||
* \param obj CTL element id/value
|
||||
* \return name part of element identificator
|
||||
*/
|
||||
const char *snd_hctl_elem_get_name(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get index part of CTL element identificator of a CTL element id/value
|
||||
* \param obj CTL element id/value
|
||||
* \return index part of element identificator
|
||||
*/
|
||||
unsigned int snd_hctl_elem_get_index(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->id.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set callback function for an HCTL element
|
||||
* \param obj HCTL element
|
||||
* \param val callback function
|
||||
*/
|
||||
void snd_hctl_elem_set_callback(snd_hctl_elem_t *obj, snd_hctl_elem_callback_t val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->callback = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set callback private value for an HCTL element
|
||||
* \param obj HCTL element
|
||||
* \param val callback private value
|
||||
*/
|
||||
void snd_hctl_elem_set_callback_private(snd_hctl_elem_t *obj, void * val)
|
||||
{
|
||||
assert(obj);
|
||||
obj->callback_private = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get callback private value for an HCTL element
|
||||
* \param obj HCTL element
|
||||
* \return callback private value
|
||||
*/
|
||||
void * snd_hctl_elem_get_callback_private(const snd_hctl_elem_t *obj)
|
||||
{
|
||||
assert(obj);
|
||||
return obj->callback_private;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,12 +79,10 @@ static void snd_lib_error_default(const char *file, int line, const char *functi
|
|||
va_end(arg);
|
||||
}
|
||||
|
||||
#ifndef DOC_HIDDEN
|
||||
/**
|
||||
* Pointer to the error handler function.
|
||||
*/
|
||||
snd_lib_error_handler_t *snd_lib_error = snd_lib_error_default;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Set the error handler.
|
||||
|
|
|
|||
|
|
@ -192,12 +192,13 @@ int snd_input_stdio_attach(snd_input_t **inputp, FILE *fp, int close)
|
|||
* \brief Open a new input from a file
|
||||
* \param inputp Pointer to returned input handle
|
||||
* \param file File name
|
||||
* \param mode fopen(3) open mode
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*/
|
||||
int snd_input_stdio_open(snd_input_t **inputp, const char *file)
|
||||
int snd_input_stdio_open(snd_input_t **inputp, const char *file, const char *mode)
|
||||
{
|
||||
int err;
|
||||
FILE *fp = fopen(file, "r");
|
||||
FILE *fp = fopen(file, mode);
|
||||
if (!fp) {
|
||||
//SYSERR("fopen");
|
||||
return -errno;
|
||||
|
|
|
|||
11
src/output.c
11
src/output.c
|
|
@ -187,10 +187,17 @@ int snd_output_stdio_attach(snd_output_t **outputp, FILE *fp, int close)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_output_stdio_open(snd_output_t **outputp, const char *file)
|
||||
/**
|
||||
* \brief Open a new output to a file
|
||||
* \param outputp Pointer to returned output handle
|
||||
* \param file File name
|
||||
* \param mode fopen(3) open mode
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*/
|
||||
int snd_output_stdio_open(snd_output_t **outputp, const char *file, const char *mode)
|
||||
{
|
||||
int err;
|
||||
FILE *fp = fopen(file, "w");
|
||||
FILE *fp = fopen(file, mode);
|
||||
if (!fp) {
|
||||
//SYSERR("fopen");
|
||||
return -errno;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue