aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tinyalsa/asoundlib.h1
-rw-r--r--mixer.c12
-rw-r--r--pcm.c2
-rw-r--r--tinycap.c1
-rw-r--r--tinypcminfo.c2
-rw-r--r--tinyplay.c1
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);
diff --git a/mixer.c b/mixer.c
index 73ae6da..113f11e 100644
--- a/mixer.c
+++ b/mixer.c
@@ -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)
diff --git a/pcm.c b/pcm.c
index 1a5d84b..a260bfe 100644
--- a/pcm.c
+++ b/pcm.c
@@ -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;
diff --git a/tinycap.c b/tinycap.c
index b9ae251..180a2dd 100644
--- a/tinycap.c
+++ b/tinycap.c
@@ -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;
}
diff --git a/tinyplay.c b/tinyplay.c
index f4fac9f..88c54ae 100644
--- a/tinyplay.c
+++ b/tinyplay.c
@@ -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;