Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion alsactl/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ static int hwdep_device_list(snd_ctl_t *ctl)
static int card_info(snd_ctl_t *ctl)
{
snd_ctl_card_info_t *info;
snd_ctl_card_components_t *components;
snd_ctl_elem_list_t *clist;
int err;

snd_ctl_card_info_alloca(&info);
snd_ctl_card_components_alloca(&components);
snd_ctl_elem_list_alloca(&clist);

if ((err = snd_ctl_card_info(ctl, info)) < 0) {
Expand All @@ -211,7 +213,10 @@ static int card_info(snd_ctl_t *ctl)
snd_ctl_card_info_get_longname(info));
printf(" driver_name: %s\n", snd_ctl_card_info_get_driver(info));
printf(" mixer_name: %s\n", snd_ctl_card_info_get_mixername(info));
printf(" components: %s\n", snd_ctl_card_info_get_components(info));
if (snd_ctl_card_components(ctl, components) >= 0)
printf(" components: %s\n", snd_ctl_card_components_get_string(components));
else
printf(" components: %s\n", snd_ctl_card_info_get_components(info));
if ((err = snd_ctl_elem_list(ctl, clist)) < 0) {
error("snd_ctl_elem_list failure: %s", snd_strerror(err));
} else {
Expand Down
47 changes: 26 additions & 21 deletions amixer/amixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,28 @@ static int info(void)
snd_ctl_t *handle;
snd_mixer_t *mhandle;
snd_ctl_card_info_t *info;
snd_ctl_card_components_t *components;
snd_ctl_elem_list_t *clist;
snd_ctl_card_info_alloca(&info);
snd_ctl_card_components_alloca(&components);
snd_ctl_elem_list_alloca(&clist);

if ((err = snd_ctl_open(&handle, card, 0)) < 0) {
error("Control device %s open error: %s", card, snd_strerror(err));
return err;
}

if ((err = snd_ctl_card_info(handle, info)) < 0) {
error("Control device %s hw info error: %s", card, snd_strerror(err));
return err;
}
printf("Card %s '%s'/'%s'\n", card, snd_ctl_card_info_get_id(info),
snd_ctl_card_info_get_longname(info));
printf(" Mixer name : '%s'\n", snd_ctl_card_info_get_mixername(info));
printf(" Components : '%s'\n", snd_ctl_card_info_get_components(info));
if (snd_ctl_card_components(handle, components) >= 0)
printf(" Components : '%s'\n", snd_ctl_card_components_get_string(components));
else
printf(" Components : '%s'\n", snd_ctl_card_info_get_components(info));
if ((err = snd_ctl_elem_list(handle, clist)) < 0) {
error("snd_ctl_elem_list failure: %s", snd_strerror(err));
} else {
Expand Down Expand Up @@ -165,12 +170,12 @@ static const char *control_access(snd_ctl_elem_info_t *info)
}

#define check_range(val, min, max) \
(no_check ? (val) : ((val < min) ? (min) : (val > max) ? (max) : (val)))
(no_check ? (val) : ((val < min) ? (min) : (val > max) ? (max) : (val)))
#if 0
static int convert_range(int val, int omin, int omax, int nmin, int nmax)
{
int orange = omax - omin, nrange = nmax - nmin;

if (orange == 0)
return 0;
return rint((((double)nrange * ((double)val - (double)omin)) + ((double)orange / 2.0)) / ((double)orange + (double)nmin));
Expand All @@ -181,7 +186,7 @@ static int convert_range(int val, int omin, int omax, int nmin, int nmax)
static int convert_db_range(int val, int omin, int omax, int nmin, int nmax)
{
int orange = omax - omin, nrange = nmax - nmin;

if (orange == 0)
return 0;
return rint((((double)nrange * ((double)val - (double)omin)) + ((double)orange / 2.0)) / (double)orange + (double)nmin);
Expand Down Expand Up @@ -220,7 +225,7 @@ struct volume_ops {
int (*set)(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t c,
long value, int dir);
};

enum { VOL_RAW, VOL_DB, VOL_MAP };

struct volume_ops_set {
Expand Down Expand Up @@ -415,7 +420,7 @@ static int get_bool_simple(char **ptr, char *str, int invert, int orig)
(*ptr)++;
return orig;
}

static int simple_skip_word(char **ptr, char *str)
{
char *xptr = *ptr;
Expand All @@ -431,7 +436,7 @@ static int simple_skip_word(char **ptr, char *str)
}
return 0;
}

static void show_control_id(snd_ctl_elem_id_t *id)
{
char *str;
Expand Down Expand Up @@ -631,7 +636,7 @@ static int show_control(const char *space, snd_hctl_elem_t *elem,
printf("%s; type=%s,access=%s,values=%u", space, control_type(info), control_access(info), count);
switch (type) {
case SND_CTL_ELEM_TYPE_INTEGER:
printf(",min=%li,max=%li,step=%li\n",
printf(",min=%li,max=%li,step=%li\n",
snd_ctl_elem_info_get_min(info),
snd_ctl_elem_info_get_max(info),
snd_ctl_elem_info_get_step(info));
Expand Down Expand Up @@ -732,7 +737,7 @@ static int controls(int level)
snd_ctl_elem_info_t *info;
snd_ctl_elem_id_alloca(&id);
snd_ctl_elem_info_alloca(&info);

if ((err = snd_hctl_open(&handle, card, 0)) < 0) {
error("Control %s open error: %s", card, snd_strerror(err));
return err;
Expand All @@ -758,7 +763,7 @@ static int controls(int level)
return 0;
}

static void show_selem_volume(snd_mixer_elem_t *elem,
static void show_selem_volume(snd_mixer_elem_t *elem,
snd_mixer_selem_channel_id_t chn, int dir,
long min, long max)
{
Expand Down Expand Up @@ -786,7 +791,7 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char
int psw, csw;
int pmono, cmono, mono_ok = 0;
snd_mixer_elem_t *elem;

elem = snd_mixer_find_selem(handle, id);
if (!elem) {
error("Mixer %s simple element not found", card);
Expand Down Expand Up @@ -917,11 +922,11 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char
printf("\n");
}
pmono = snd_mixer_selem_has_playback_channel(elem, SND_MIXER_SCHN_MONO) &&
(snd_mixer_selem_is_playback_mono(elem) ||
(snd_mixer_selem_is_playback_mono(elem) ||
(!snd_mixer_selem_has_playback_volume(elem) &&
!snd_mixer_selem_has_playback_switch(elem)));
cmono = snd_mixer_selem_has_capture_channel(elem, SND_MIXER_SCHN_MONO) &&
(snd_mixer_selem_is_capture_mono(elem) ||
(snd_mixer_selem_is_capture_mono(elem) ||
(!snd_mixer_selem_has_capture_volume(elem) &&
!snd_mixer_selem_has_capture_switch(elem)));
#if 0
Expand Down Expand Up @@ -1053,7 +1058,7 @@ static int selems(int level)
snd_mixer_selem_id_t *sid;
snd_mixer_elem_t *elem;
snd_mixer_selem_id_alloca(&sid);

if ((err = snd_mixer_open(&handle, 0)) < 0) {
error("Mixer %s open error: %s", card, snd_strerror(err));
return err;
Expand Down Expand Up @@ -1290,7 +1295,7 @@ static int get_enum_item_index(snd_mixer_elem_t *elem, char **ptrp)

/* See snd_ctl_elem_init_enum_names() in sound/core/control.c. */
char name[64];

items = snd_mixer_selem_get_enum_items(elem);
if (items <= 0)
return -1;
Expand Down Expand Up @@ -1563,9 +1568,9 @@ static int element_callback(snd_hctl_elem_t *elem, unsigned int mask)
events_remove(elem);
return 0;
}
if (mask & SND_CTL_EVENT_MASK_INFO)
if (mask & SND_CTL_EVENT_MASK_INFO)
events_info(elem);
if (mask & SND_CTL_EVENT_MASK_VALUE)
if (mask & SND_CTL_EVENT_MASK_VALUE)
events_value(elem);
return 0;
}
Expand Down Expand Up @@ -1645,9 +1650,9 @@ static int melem_event(snd_mixer_elem_t *elem, unsigned int mask)
sevents_remove(sid);
return 0;
}
if (mask & SND_CTL_EVENT_MASK_INFO)
if (mask & SND_CTL_EVENT_MASK_INFO)
sevents_info(sid);
if (mask & SND_CTL_EVENT_MASK_VALUE)
if (mask & SND_CTL_EVENT_MASK_VALUE)
sevents_value(sid);
return 0;
}
Expand Down