diff options
author | David Li <dvdli@google.com> | 2022-01-06 01:31:47 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-01-06 01:31:47 +0000 |
commit | 6b2ff5d9012fc3263ee815fa6487d0c7b5d2bf3b (patch) | |
tree | 8e80614cbd82ceff4841b8eb6509e1ebcc1a71a6 | |
parent | bb86e95209c76b242032eb9bac1304b0cbd0f649 (diff) | |
parent | 73ab65f4d3f795798e4618e2775cb966183e24bd (diff) | |
download | tinyalsa_new-6b2ff5d9012fc3263ee815fa6487d0c7b5d2bf3b.tar.gz |
Merge remote-tracking branch 'aosp/upstream-master' into master am: 0d55c94d89 am: 73ab65f4d3
Original change: https://android-review.googlesource.com/c/platform/external/tinyalsa_new/+/1936212
Change-Id: I60af0347f7bba6a27e471855ba9d040ef9d0a8da
-rw-r--r-- | WORKSPACE | 2 | ||||
-rw-r--r-- | include/tinyalsa/meson.build | 2 | ||||
-rw-r--r-- | include/tinyalsa/pcm.h | 10 | ||||
-rw-r--r-- | src/mixer.c | 19 | ||||
-rw-r--r-- | src/mixer_plugin.c | 6 | ||||
-rw-r--r-- | src/pcm_plugin.c | 9 |
6 files changed, 33 insertions, 15 deletions
@@ -3,5 +3,5 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( name = "googletest", remote = "https://github.com/google/googletest", - branch = "master", + branch = "main", ) diff --git a/include/tinyalsa/meson.build b/include/tinyalsa/meson.build index d14b35b..95077be 100644 --- a/include/tinyalsa/meson.build +++ b/include/tinyalsa/meson.build @@ -1,9 +1,11 @@ tinyalsa_headers = [ 'asoundlib.h', + 'attributes.h', 'interval.h', 'limits.h', 'mixer.h', 'pcm.h', + 'plugin.h', 'version.h' ] diff --git a/include/tinyalsa/pcm.h b/include/tinyalsa/pcm.h index 5c11e2a..9fca92d 100644 --- a/include/tinyalsa/pcm.h +++ b/include/tinyalsa/pcm.h @@ -217,16 +217,16 @@ struct pcm_config { * silence_size : 0 */ /** The minimum number of frames required to start the PCM */ - unsigned int start_threshold; + unsigned long start_threshold; /** The minimum number of frames required to stop the PCM */ - unsigned int stop_threshold; + unsigned long stop_threshold; /** The minimum number of frames to silence the PCM */ - unsigned int silence_threshold; + unsigned long silence_threshold; /** The number of frames to overwrite the playback buffer when the playback underrun is greater * than the silence threshold */ - unsigned int silence_size; + unsigned long silence_size; - unsigned int avail_min; + unsigned long avail_min; }; /** Enumeration of a PCM's hardware parameters. diff --git a/src/mixer.c b/src/mixer.c index 5581e5d..afbc015 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -732,9 +732,13 @@ struct mixer_ctl *mixer_get_ctl_by_name_and_index(struct mixer *mixer, ctl = grp->ctl; for (n = 0; n < grp->count; n++) - if (!strcmp(name, (char*) ctl[n].info.id.name)) - if (index-- == 0) + if (!strcmp(name, (char*) ctl[n].info.id.name)) { + if (index == 0) { return ctl + n; + } else { + index--; + } + } } #ifdef TINYALSA_USES_PLUGINS @@ -743,9 +747,13 @@ struct mixer_ctl *mixer_get_ctl_by_name_and_index(struct mixer *mixer, ctl = grp->ctl; for (n = 0; n < grp->count; n++) - if (!strcmp(name, (char*) ctl[n].info.id.name)) - if (index-- == 0) + if (!strcmp(name, (char*) ctl[n].info.id.name)) { + if (index == 0) { return ctl + n; + } else { + index--; + } + } } #endif return NULL; @@ -1039,6 +1047,9 @@ int mixer_ctl_get_array(const struct mixer_ctl *ctl, void *array, size_t count) } case SNDRV_CTL_ELEM_TYPE_IEC958: + ret = grp->ops->ioctl(grp->data, SNDRV_CTL_IOCTL_ELEM_READ, &ev); + if (ret < 0) + return ret; size = sizeof(ev.value.iec958); source = &ev.value.iec958; break; diff --git a/src/mixer_plugin.c b/src/mixer_plugin.c index 34117a9..a07b8f6 100644 --- a/src/mixer_plugin.c +++ b/src/mixer_plugin.c @@ -82,7 +82,8 @@ static int mixer_plug_get_elem_id(struct mixer_plug_data *plug_data, id->iface = ctl->iface; strncpy((char *)id->name, (char *)ctl->name, - sizeof(id->name)); + sizeof(id->name) - 1); + ((char *)id->name)[sizeof(id->name) - 1] = '\0'; return 0; } @@ -100,7 +101,8 @@ static int mixer_plug_info_enum(struct snd_control *ctl, strncpy(einfo->value.enumerated.name, val->texts[einfo->value.enumerated.item], - sizeof(einfo->value.enumerated.name)); + sizeof(einfo->value.enumerated.name) - 1); + einfo->value.enumerated.name[sizeof(einfo->value.enumerated.name) - 1] = '\0'; return 0; } diff --git a/src/pcm_plugin.c b/src/pcm_plugin.c index 15bfc80..47bf4a5 100644 --- a/src/pcm_plugin.c +++ b/src/pcm_plugin.c @@ -153,9 +153,12 @@ static int pcm_plug_info(struct pcm_plug_data *plug_data, return ret; } - strncpy((char *)info->id, name, sizeof(info->id)); - strncpy((char *)info->name, name, sizeof(info->name)); - strncpy((char *)info->subname, name, sizeof(info->subname)); + strncpy((char *)info->id, name, sizeof(info->id) - 1); + ((char *)info->id)[sizeof(info->id) - 1] = '\0'; + strncpy((char *)info->name, name, sizeof(info->name) - 1); + ((char *)info->name)[sizeof(info->name) - 1] = '\0'; + strncpy((char *)info->subname, name, sizeof(info->subname) - 1); + ((char *)info->subname)[sizeof(info->subname) - 1] = '\0'; info->subdevices_count = 1; |