diff options
-rw-r--r-- | include/tinyalsa/asoundlib.h | 1 | ||||
-rw-r--r-- | mixer.c | 12 | ||||
-rw-r--r-- | pcm.c | 2 | ||||
-rw-r--r-- | tinycap.c | 1 | ||||
-rw-r--r-- | tinypcminfo.c | 2 | ||||
-rw-r--r-- | tinyplay.c | 1 |
6 files changed, 17 insertions, 2 deletions
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h index a85e810..584cfe1 100644 --- a/include/tinyalsa/asoundlib.h +++ b/include/tinyalsa/asoundlib.h @@ -225,6 +225,7 @@ struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id); struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name); /* Get info about mixer controls */ +unsigned int mixer_ctl_get_id(struct mixer_ctl *ctl); const char *mixer_ctl_get_name(struct mixer_ctl *ctl); enum mixer_ctl_type mixer_ctl_get_type(struct mixer_ctl *ctl); const char *mixer_ctl_get_type_string(struct mixer_ctl *ctl); @@ -33,6 +33,7 @@ #include <fcntl.h> #include <errno.h> #include <ctype.h> +#include <limits.h> #include <sys/ioctl.h> @@ -209,6 +210,17 @@ void mixer_ctl_update(struct mixer_ctl *ctl) ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_INFO, ctl->info); } +unsigned int mixer_ctl_get_id(struct mixer_ctl *ctl) +{ + if (!ctl) + return UINT_MAX; + + /* numid values start at 1, return a 0-base value that + * can be passed to mixer_get_ctl() + */ + return ctl->info->id.numid - 1; +} + const char *mixer_ctl_get_name(struct mixer_ctl *ctl) { if (!ctl) @@ -827,7 +827,7 @@ static inline int pcm_mmap_playback_avail(struct pcm *pcm) if (avail < 0) avail += pcm->boundary; - else if (avail > (int)pcm->boundary) + else if (avail >= (int)pcm->boundary) avail -= pcm->boundary; return avail; @@ -206,6 +206,7 @@ unsigned int capture_sample(FILE *file, unsigned int card, unsigned int device, unsigned int size; unsigned int bytes_read = 0; + memset(&config, 0, sizeof(config)); config.channels = channels; config.rate = rate; config.period_size = period_size; diff --git a/tinypcminfo.c b/tinypcminfo.c index b2d11bc..99eec34 100644 --- a/tinypcminfo.c +++ b/tinypcminfo.c @@ -92,7 +92,7 @@ static const char *format_lookup[] = { /* Returns a human readable name for the format associated with bit_index, * NULL if bit_index is not known. */ -inline const char *pcm_get_format_name(unsigned bit_index) +static inline const char *pcm_get_format_name(unsigned bit_index) { return bit_index < ARRAY_SIZE(format_lookup) ? format_lookup[bit_index] : NULL; } @@ -218,6 +218,7 @@ void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned in int size; int num_read; + memset(&config, 0, sizeof(config)); config.channels = channels; config.rate = rate; config.period_size = period_size; |