Commit c1239623 authored by Simon Wilson's avatar Simon Wilson
Browse files

Update to latest tinyalsa

3bb114a pcm: add control for ASLA thresholds to pcm_open
ee99f21 include: make it easier to use this header from C++
89b3128 Makefile: Don't error out of clean if already clean
a14dad9 tinymix: Say if we can't open the mixer
49900f0 Merge pull request #3 from broonie/noprelink
ea019ef Merge pull request #2 from broonie/add-include

Change-Id: I110de23af1f43d2cefb134204cb0439a7fd4c1d0
parent dd88f13d
......@@ -6,6 +6,7 @@ LOCAL_SRC_FILES:= mixer.c pcm.c
LOCAL_MODULE := libtinyalsa
LOCAL_SHARED_LIBRARIES:= libcutils libutils
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
......
......@@ -31,6 +31,10 @@
#include <sys/time.h>
#if defined(__cplusplus)
extern "C" {
#endif
/*
* PCM API
*/
......@@ -55,6 +59,18 @@ struct pcm_config {
unsigned int period_size;
unsigned int period_count;
enum pcm_format format;
/* Values to use for the ALSA start, stop and silence thresholds. Setting
* any one of these values to 0 will cause the default tinyalsa values to be
* used instead. Tinyalsa defaults are as follows.
*
* start_threshold : period_count * period_size
* stop_threshold : period_count * period_size
* silence_threshold : 0
*/
unsigned int start_threshold;
unsigned int stop_threshold;
unsigned int silence_threshold;
};
/* Mixer control types */
......@@ -149,4 +165,8 @@ int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string);
int mixer_ctl_get_range_min(struct mixer_ctl *ctl);
int mixer_ctl_get_range_max(struct mixer_ctl *ctl);
#if defined(__cplusplus)
} /* extern "C" */
#endif
#endif
......@@ -427,11 +427,21 @@ struct pcm *pcm_open(unsigned int card, unsigned int device,
sparams.tstamp_mode = SNDRV_PCM_TSTAMP_ENABLE;
sparams.period_step = 1;
sparams.avail_min = 1;
sparams.start_threshold = config->period_count * config->period_size;
sparams.stop_threshold = config->period_count * config->period_size;
if (!config->start_threshold)
sparams.start_threshold = config->period_count * config->period_size;
else
sparams.start_threshold = config->start_threshold;
if (!config->stop_threshold)
sparams.stop_threshold = config->period_count * config->period_size;
else
sparams.stop_threshold = config->stop_threshold;
sparams.xfer_align = config->period_size / 2; /* needed for old kernels */
sparams.silence_size = 0;
sparams.silence_threshold = 0;
sparams.silence_threshold = config->silence_threshold;
if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) {
oops(pcm, errno, "cannot set sw params");
......
......@@ -41,6 +41,10 @@ int main(int argc, char **argv)
struct mixer *mixer;
mixer = mixer_open(0);
if (!mixer) {
fprintf(stderr, "Failed to open mixer\n");
return EXIT_FAILURE;
}
if (argc == 1)
tinymix_list_controls(mixer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment