diff options
author | Simon Wilson | 2011-07-27 17:08:34 -0500 |
---|---|---|
committer | Simon Wilson | 2011-07-27 17:09:09 -0500 |
commit | c1239623c178f0142352c28a0f968d826afcb078 (patch) | |
tree | 17748ff3bb998e01db594c18793c98941d56a40a | |
parent | dd88f13d9b398c132e3358c62137ff2e23f321ab (diff) | |
download | platform-external-tinyalsa-c1239623c178f0142352c28a0f968d826afcb078.tar.gz platform-external-tinyalsa-c1239623c178f0142352c28a0f968d826afcb078.tar.xz platform-external-tinyalsa-c1239623c178f0142352c28a0f968d826afcb078.zip |
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
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | include/tinyalsa/asoundlib.h | 20 | ||||
-rw-r--r-- | pcm.c | 16 | ||||
-rw-r--r-- | tinymix.c | 4 |
4 files changed, 38 insertions, 3 deletions
@@ -6,6 +6,7 @@ LOCAL_SRC_FILES:= mixer.c pcm.c | |||
6 | LOCAL_MODULE := libtinyalsa | 6 | LOCAL_MODULE := libtinyalsa |
7 | LOCAL_SHARED_LIBRARIES:= libcutils libutils | 7 | LOCAL_SHARED_LIBRARIES:= libcutils libutils |
8 | LOCAL_MODULE_TAGS := optional | 8 | LOCAL_MODULE_TAGS := optional |
9 | LOCAL_PRELINK_MODULE := false | ||
9 | 10 | ||
10 | include $(BUILD_SHARED_LIBRARY) | 11 | include $(BUILD_SHARED_LIBRARY) |
11 | 12 | ||
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h index 7b13c0d..2e8c3e0 100644 --- a/include/tinyalsa/asoundlib.h +++ b/include/tinyalsa/asoundlib.h | |||
@@ -31,6 +31,10 @@ | |||
31 | 31 | ||
32 | #include <sys/time.h> | 32 | #include <sys/time.h> |
33 | 33 | ||
34 | #if defined(__cplusplus) | ||
35 | extern "C" { | ||
36 | #endif | ||
37 | |||
34 | /* | 38 | /* |
35 | * PCM API | 39 | * PCM API |
36 | */ | 40 | */ |
@@ -55,6 +59,18 @@ struct pcm_config { | |||
55 | unsigned int period_size; | 59 | unsigned int period_size; |
56 | unsigned int period_count; | 60 | unsigned int period_count; |
57 | enum pcm_format format; | 61 | enum pcm_format format; |
62 | |||
63 | /* Values to use for the ALSA start, stop and silence thresholds. Setting | ||
64 | * any one of these values to 0 will cause the default tinyalsa values to be | ||
65 | * used instead. Tinyalsa defaults are as follows. | ||
66 | * | ||
67 | * start_threshold : period_count * period_size | ||
68 | * stop_threshold : period_count * period_size | ||
69 | * silence_threshold : 0 | ||
70 | */ | ||
71 | unsigned int start_threshold; | ||
72 | unsigned int stop_threshold; | ||
73 | unsigned int silence_threshold; | ||
58 | }; | 74 | }; |
59 | 75 | ||
60 | /* Mixer control types */ | 76 | /* Mixer control types */ |
@@ -149,4 +165,8 @@ int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string); | |||
149 | int mixer_ctl_get_range_min(struct mixer_ctl *ctl); | 165 | int mixer_ctl_get_range_min(struct mixer_ctl *ctl); |
150 | int mixer_ctl_get_range_max(struct mixer_ctl *ctl); | 166 | int mixer_ctl_get_range_max(struct mixer_ctl *ctl); |
151 | 167 | ||
168 | #if defined(__cplusplus) | ||
169 | } /* extern "C" */ | ||
170 | #endif | ||
171 | |||
152 | #endif | 172 | #endif |
@@ -427,11 +427,21 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, | |||
427 | sparams.tstamp_mode = SNDRV_PCM_TSTAMP_ENABLE; | 427 | sparams.tstamp_mode = SNDRV_PCM_TSTAMP_ENABLE; |
428 | sparams.period_step = 1; | 428 | sparams.period_step = 1; |
429 | sparams.avail_min = 1; | 429 | sparams.avail_min = 1; |
430 | sparams.start_threshold = config->period_count * config->period_size; | 430 | |
431 | sparams.stop_threshold = config->period_count * config->period_size; | 431 | if (!config->start_threshold) |
432 | sparams.start_threshold = config->period_count * config->period_size; | ||
433 | else | ||
434 | sparams.start_threshold = config->start_threshold; | ||
435 | |||
436 | if (!config->stop_threshold) | ||
437 | sparams.stop_threshold = config->period_count * config->period_size; | ||
438 | else | ||
439 | sparams.stop_threshold = config->stop_threshold; | ||
440 | |||
432 | sparams.xfer_align = config->period_size / 2; /* needed for old kernels */ | 441 | sparams.xfer_align = config->period_size / 2; /* needed for old kernels */ |
433 | sparams.silence_size = 0; | 442 | sparams.silence_size = 0; |
434 | sparams.silence_threshold = 0; | 443 | sparams.silence_threshold = config->silence_threshold; |
444 | |||
435 | 445 | ||
436 | if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) { | 446 | if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) { |
437 | oops(pcm, errno, "cannot set sw params"); | 447 | oops(pcm, errno, "cannot set sw params"); |
@@ -41,6 +41,10 @@ int main(int argc, char **argv) | |||
41 | struct mixer *mixer; | 41 | struct mixer *mixer; |
42 | 42 | ||
43 | mixer = mixer_open(0); | 43 | mixer = mixer_open(0); |
44 | if (!mixer) { | ||
45 | fprintf(stderr, "Failed to open mixer\n"); | ||
46 | return EXIT_FAILURE; | ||
47 | } | ||
44 | 48 | ||
45 | if (argc == 1) | 49 | if (argc == 1) |
46 | tinymix_list_controls(mixer); | 50 | tinymix_list_controls(mixer); |