Hello community, here is the log from the commit of package alsa-utils for openSUSE:Factory checked in at 2020-02-21 16:40:20 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/alsa-utils (Old) and /work/SRC/openSUSE:Factory/.alsa-utils.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "alsa-utils" Fri Feb 21 16:40:20 2020 rev:120 rq:774842 version:1.2.1 Changes: -------- --- /work/SRC/openSUSE:Factory/alsa-utils/alsa-utils.changes 2020-01-24 13:09:33.701394490 +0100 +++ /work/SRC/openSUSE:Factory/.alsa-utils.new.26092/alsa-utils.changes 2020-02-21 16:40:43.401837078 +0100 @@ -1,0 +2,16 @@ +Wed Feb 12 20:57:05 CET 2020 - [email protected] + +- Backport upstream fixes: + alsatplg fixes, misc cleanups: + 0027-alsatplg-rewrite-to-use-the-new-libatopology-functio.patch + 0028-alsatplg-add-V-version-option.patch + 0029-alsatplg-add-decode-command.patch + 0030-alsatplg-add-documentation-for-z-dapm-nosort-h.patch + 0031-configure-fix-new-libatopology-check.patch + 0032-Use-__func__-instead-of-__FUNCTION__.patch + 0033-Avoid-pointer-arithmetic-on-void.patch + 0034-Use-lli-for-long-long-in-printf.patch + 0035-Avoid-empty-initializer-list.patch +- Fix build on SLE12-* target + +------------------------------------------------------------------- New: ---- 0027-alsatplg-rewrite-to-use-the-new-libatopology-functio.patch 0028-alsatplg-add-V-version-option.patch 0029-alsatplg-add-decode-command.patch 0030-alsatplg-add-documentation-for-z-dapm-nosort-h.patch 0031-configure-fix-new-libatopology-check.patch 0032-Use-__func__-instead-of-__FUNCTION__.patch 0033-Avoid-pointer-arithmetic-on-void.patch 0034-Use-lli-for-long-long-in-printf.patch 0035-Avoid-empty-initializer-list.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ alsa-utils.spec ++++++ --- /var/tmp/diff_new_pack.3lKW90/_old 2020-02-21 16:40:45.453841178 +0100 +++ /var/tmp/diff_new_pack.3lKW90/_new 2020-02-21 16:40:45.469841210 +0100 @@ -55,6 +55,15 @@ Patch24: 0024-alsa-info.sh-Condense-nested-commands-for-formatting.patch Patch25: 0025-alsa-info.sh-Perform-test-for-wget-earlier.patch Patch26: 0026-alsa-info.sh-Warn-after-actual-upload-failure-do-not.patch +Patch27: 0027-alsatplg-rewrite-to-use-the-new-libatopology-functio.patch +Patch28: 0028-alsatplg-add-V-version-option.patch +Patch29: 0029-alsatplg-add-decode-command.patch +Patch30: 0030-alsatplg-add-documentation-for-z-dapm-nosort-h.patch +Patch31: 0031-configure-fix-new-libatopology-check.patch +Patch32: 0032-Use-__func__-instead-of-__FUNCTION__.patch +Patch33: 0033-Avoid-pointer-arithmetic-on-void.patch +Patch34: 0034-Use-lli-for-long-long-in-printf.patch +Patch35: 0035-Avoid-empty-initializer-list.patch Patch101: alsa-utils-configure-version-revert.patch BuildRequires: alsa-devel BuildRequires: alsa-topology-devel @@ -62,7 +71,11 @@ BuildRequires: libsamplerate-devel BuildRequires: ncurses-devel BuildRequires: pkgconfig +%if 0%{?suse_version} < 1500 +BuildRequires: python-docutils +%else BuildRequires: python3-docutils +%endif BuildRequires: xmlto BuildRequires: pkgconfig(systemd) BuildRequires: pkgconfig(udev) @@ -117,6 +130,15 @@ %patch24 -p1 %patch25 -p1 %patch26 -p1 +%patch27 -p1 +%patch28 -p1 +%patch29 -p1 +%patch30 -p1 +%patch31 -p1 +%patch32 -p1 +%patch33 -p1 +%patch34 -p1 +%patch35 -p1 %if 0%{?do_autoreconf} %patch101 -p1 # fix stupid automake's automatic action ++++++ 0027-alsatplg-rewrite-to-use-the-new-libatopology-functio.patch ++++++ >From cbabe7a3f0cc84ecd352d4cbf85148946fa6c0d5 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela <[email protected]> Date: Thu, 19 Dec 2019 15:36:05 +0100 Subject: [PATCH 27/35] alsatplg: rewrite to use the new libatopology functions Add '-u,--dump' operation. Add '-g,--group' and '-x,--nocheck' modifiers. Add '-z,--dapm-nosort' modifier. Allow to operate with stdin/stdout for the file input/output. Signed-off-by: Jaroslav Kysela <[email protected]> --- topology/alsatplg.rst | 17 ++- topology/topology.c | 304 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 199 insertions(+), 122 deletions(-) diff --git a/topology/alsatplg.rst b/topology/alsatplg.rst index 855edff67ecf..e09c865cc9b2 100644 --- a/topology/alsatplg.rst +++ b/topology/alsatplg.rst @@ -50,12 +50,27 @@ Available options: **-c**, **--compile** `FILE` source configuration file for the compilation + **-n**, **--normalize** `FILE` + parse and save the configuration file in the normalized format + + **-u**, **--dump** `FILE` + parse and save the configuration file in the specified format + **-o**, **--output** `FILE` - output binary file + output file **-v**, **--verbose** `LEVEL` set verbose level + **-s**, **--sort** + sort the configuration identifiers (set for normalization) + + **-x**, **--nocheck** + save the configuration without additional integrity check + + **-z**, **--dapm-nosort** + do not sort DAPM graph items (like in version 1.2.1-) + FILES ===== diff --git a/topology/topology.c b/topology/topology.c index bc5797c5f14f..a94941ae762e 100644 --- a/topology/topology.c +++ b/topology/topology.c @@ -1,4 +1,5 @@ /* + Copyright(c) 2019 Red Hat Inc. Copyright(c) 2014-2015 Intel Corporation Copyright(c) 2010-2011 Texas Instruments Incorporated, All rights reserved. @@ -44,165 +45,205 @@ _("Usage: %s [OPTIONS]...\n" "-h, --help help\n" "-c, --compile=FILE compile file\n" "-n, --normalize=FILE normalize file\n" +"-u, --dump=FILE dump (reparse) file\n" "-v, --verbose=LEVEL set verbosity level (0...1)\n" "-o, --output=FILE set output file\n" "-s, --sort sort the identifiers in the normalized output\n" +"-g, --group save configuration by group indexes\n" +"-x, --nocheck save configuration without additional integrity checks\n" ), name); } -static int _compar(const void *a, const void *b) +static int load(snd_tplg_t **tplg, const char *source_file, int cflags) { - const snd_config_t *c1 = *(snd_config_t **)a; - const snd_config_t *c2 = *(snd_config_t **)b; - const char *id1, *id2; - if (snd_config_get_id(c1, &id1)) return 0; - if (snd_config_get_id(c2, &id2)) return 0; - return strcmp(id1, id2); -} + int fd, err; + char *buf, *buf2; + size_t size, pos; + ssize_t r; -static snd_config_t *normalize_config(const char *id, snd_config_t *src, int sort) -{ - snd_config_t *dst, **a; - snd_config_iterator_t i, next; - int index, count; - - if (snd_config_get_type(src) != SND_CONFIG_TYPE_COMPOUND) { - if (snd_config_copy(&dst, src) >= 0) - return dst; - return NULL; - } - count = 0; - snd_config_for_each(i, next, src) - count++; - a = malloc(sizeof(dst) * count); - if (a == NULL) - return NULL; - index = 0; - snd_config_for_each(i, next, src) { - snd_config_t *s = snd_config_iterator_entry(i); - a[index++] = s; - } - if (sort) - qsort(a, count, sizeof(a[0]), _compar); - if (snd_config_make_compound(&dst, id, count == 1)) { - free(a); - return NULL; - } - for (index = 0; index < count; index++) { - snd_config_t *s = a[index]; - const char *id2; - if (snd_config_get_id(s, &id2)) { - snd_config_delete(dst); - free(a); - return NULL; - } - s = normalize_config(id2, s, sort); - if (s == NULL || snd_config_add(dst, s)) { - if (s) - snd_config_delete(s); - snd_config_delete(dst); - free(a); - return NULL; + if (strcmp(source_file, "-") == 0) { + fd = fileno(stdin); + } else { + fd = open(source_file, O_RDONLY); + if (fd < 0) { + fprintf(stderr, _("Unable to open input file '%s': %s\n"), + source_file, strerror(-errno)); + return 1; } } - free(a); - return dst; -} -static int compile(const char *source_file, const char *output_file, int verbose) -{ - snd_tplg_t *snd_tplg; - int err; + size = 16*1024; + pos = 0; + buf = malloc(size); + if (buf == NULL) + goto _nomem; + while (1) { + r = read(fd, buf + pos, size - pos); + if (r < 0 && (errno == EAGAIN || errno == EINTR)) + continue; + if (r <= 0) + break; + pos += r; + size += 8*1024; + buf2 = realloc(buf, size); + if (buf2 == NULL) { + free(buf); + goto _nomem; + } + buf = buf2; + } + if (fd != fileno(stdin)) + close(fd); + if (r < 0) { + fprintf(stderr, _("Read error: %s\n"), strerror(-errno)); + free(buf); + goto _err; + } - snd_tplg = snd_tplg_new(); - if (snd_tplg == NULL) { + *tplg = snd_tplg_create(cflags); + if (*tplg == NULL) { fprintf(stderr, _("failed to create new topology context\n")); + free(buf); return 1; } - snd_tplg_verbose(snd_tplg, verbose); - - err = snd_tplg_build_file(snd_tplg, source_file, output_file); + err = snd_tplg_load(*tplg, buf, pos); + free(buf); if (err < 0) { - fprintf(stderr, _("failed to compile context %s\n"), source_file); - snd_tplg_free(snd_tplg); - unlink(output_file); + fprintf(stderr, _("Unable to load configuration: %s\n"), + snd_strerror(-err)); + snd_tplg_free(*tplg); return 1; } - snd_tplg_free(snd_tplg); + return 0; + +_nomem: + fprintf(stderr, _("No enough memory\n")); +_err: + if (fd != fileno(stdin)) + close(fd); + free(buf); return 1; } -static int normalize(const char *source_file, const char *output_file, int sort) +static int save(const char *output_file, void *buf, size_t size) { - snd_input_t *input; - snd_output_t *output; - snd_config_t *top, *norm; - int err; + char *fname = NULL; + int fd; + ssize_t r; - err = snd_input_stdio_open(&input, source_file, "r"); - if (err < 0) { - fprintf(stderr, "Unable to open source file '%s': %s\n", source_file, snd_strerror(-err)); - return 0; + if (strcmp(output_file, "-") == 0) { + fd = fileno(stdout); + } else { + fname = alloca(strlen(output_file) + 5); + strcpy(fname, output_file); + strcat(fname, ".new"); + fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + if (fd < 0) { + fprintf(stderr, _("Unable to open output file '%s': %s\n"), + fname, strerror(-errno)); + return 1; + } } - err = snd_config_top(&top); - if (err < 0) { - snd_input_close(input); - return 1; + r = 0; + while (size > 0) { + r = write(fd, buf, size); + if (r < 0 && (errno == EAGAIN || errno == EINTR)) + continue; + if (r < 0) + break; + size -= r; + buf += r; } - err = snd_config_load(top, input); - snd_input_close(input); - if (err < 0) { - snd_config_delete(top); - fprintf(stderr, "Unable to parse source file '%s': %s\n", source_file, snd_strerror(-err)); - snd_config_delete(top); + if (r < 0) { + fprintf(stderr, _("Write error: %s\n"), strerror(-errno)); + if (fd != fileno(stdout)) { + remove(fname); + close(fd); + } return 1; } - err = snd_output_stdio_open(&output, output_file, "w+"); - if (err < 0) { - fprintf(stderr, "Unable to open output file '%s': %s\n", output_file, snd_strerror(-err)); - snd_config_delete(top); - return 1; - } + if (fd != fileno(stdout)) + close(fd); - norm = normalize_config(NULL, top, sort); - if (norm == NULL) { - fprintf(stderr, "Unable to normalize configuration (out of memory?)\n"); - snd_output_close(output); - snd_config_delete(top); + if (fname && rename(fname, output_file)) { + fprintf(stderr, _("Unable to rename file '%s' to '%s': %s\n"), + fname, output_file, strerror(-errno)); return 1; } - err = snd_config_save(norm, output); - snd_output_close(output); - snd_config_delete(norm); - snd_config_delete(top); + return 0; +} + +static int dump(const char *source_file, const char *output_file, int cflags, int sflags) +{ + snd_tplg_t *tplg; + char *text; + int err; + + err = load(&tplg, source_file, cflags); + if (err) + return err; + err = snd_tplg_save(tplg, &text, sflags); + snd_tplg_free(tplg); if (err < 0) { - fprintf(stderr, "Unable to save normalized contents: %s\n", snd_strerror(-err)); + fprintf(stderr, _("Unable to save parsed configuration: %s\n"), + snd_strerror(-err)); return 1; } + err = save(output_file, text, strlen(text)); + free(text); + return err; +} - return 0; +static int compile(const char *source_file, const char *output_file, int cflags) +{ + snd_tplg_t *tplg; + void *bin; + size_t size; + int err; + + err = load(&tplg, source_file, cflags); + if (err) + return err; + err = snd_tplg_build_bin(tplg, &bin, &size); + snd_tplg_free(tplg); + if (err < 0 || size == 0) { + fprintf(stderr, _("failed to compile context %s\n"), source_file); + return 1; + } + err = save(output_file, bin, size); + free(bin); + return err; } +#define OP_COMPILE 1 +#define OP_NORMALIZE 2 +#define OP_DUMP 3 + int main(int argc, char *argv[]) { - static const char short_options[] = "hc:n:v:o:s"; + static const char short_options[] = "hc:n:u:v:o:sgxz"; static const struct option long_options[] = { {"help", 0, NULL, 'h'}, {"verbose", 1, NULL, 'v'}, {"compile", 1, NULL, 'c'}, {"normalize", 1, NULL, 'n'}, + {"dump", 1, NULL, 'u'}, {"output", 1, NULL, 'o'}, {"sort", 0, NULL, 's'}, + {"group", 0, NULL, 'g'}, + {"nocheck", 0, NULL, 'x'}, + {"dapm-nosort", 0, NULL, 'z'}, {0, 0, 0, 0}, }; - char *source_file = NULL, *normalize_file = NULL, *output_file = NULL; - int c, err, verbose = 0, sort = 0, option_index; + char *source_file = NULL; + char *output_file = NULL; + int c, err, op = 'c', cflags = 0, sflags = 0, option_index; #ifdef ENABLE_NLS setlocale(LC_ALL, ""); @@ -218,19 +259,32 @@ int main(int argc, char *argv[]) usage(argv[0]); return 0; case 'v': - verbose = atoi(optarg); + cflags |= SND_TPLG_CREATE_VERBOSE; break; - case 'c': - source_file = optarg; + case 'z': + cflags |= SND_TPLG_CREATE_DAPM_NOSORT; break; + case 'c': case 'n': - normalize_file = optarg; + case 'u': + if (source_file) { + fprintf(stderr, _("Cannot combine operations (compile, normalize, dump)\n")); + return 1; + } + source_file = optarg; + op = c; break; case 'o': output_file = optarg; break; case 's': - sort = 1; + sflags |= SND_TPLG_SAVE_SORT; + break; + case 'g': + sflags |= SND_TPLG_SAVE_GROUPS; + break; + case 'x': + sflags |= SND_TPLG_SAVE_NOCHECK; break; default: fprintf(stderr, _("Try `%s --help' for more information.\n"), argv[0]); @@ -238,21 +292,29 @@ int main(int argc, char *argv[]) } } - if (source_file && normalize_file) { - fprintf(stderr, "Cannot normalize and compile at a time!\n"); + if (source_file == NULL || output_file == NULL) { + usage(argv[0]); return 1; } - if ((source_file == NULL && normalize_file == NULL) || output_file == NULL) { - usage(argv[0]); - return 1; + if (op == 'n') { + if (sflags != 0 && sflags != SND_TPLG_SAVE_SORT) { + fprintf(stderr, _("Wrong parameters for the normalize operation!\n")); + return 1; + } + /* normalize has predefined output */ + sflags = SND_TPLG_SAVE_SORT; } - if (source_file) - err = compile(source_file, output_file, verbose); - else - err = normalize(normalize_file, output_file, sort); + switch (op) { + case 'c': + err = compile(source_file, output_file, cflags); + break; + default: + err = dump(source_file, output_file, cflags, sflags); + break; + } snd_output_close(log); - return 0; + return err ? 1 : 0; } -- 2.16.4 ++++++ 0028-alsatplg-add-V-version-option.patch ++++++ >From 32e7016fd710f6ed9d514100c7c05453974036d0 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela <[email protected]> Date: Fri, 20 Dec 2019 15:23:27 +0100 Subject: [PATCH 28/35] alsatplg: add -V,--version option Signed-off-by: Jaroslav Kysela <[email protected]> --- topology/alsatplg.rst | 3 +++ topology/topology.c | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/topology/alsatplg.rst b/topology/alsatplg.rst index e09c865cc9b2..260454bfc526 100644 --- a/topology/alsatplg.rst +++ b/topology/alsatplg.rst @@ -47,6 +47,9 @@ Available options: **-h**, **--help** this help + **-V**, **--version** + show the utility version and versions of used libraries + **-c**, **--compile** `FILE` source configuration file for the compilation diff --git a/topology/topology.c b/topology/topology.c index a94941ae762e..101f8ccf16ea 100644 --- a/topology/topology.c +++ b/topology/topology.c @@ -34,10 +34,11 @@ #include <alsa/asoundlib.h> #include <alsa/topology.h> #include "gettext.h" +#include "version.h" static snd_output_t *log; -static void usage(char *name) +static void usage(const char *name) { printf( _("Usage: %s [OPTIONS]...\n" @@ -51,9 +52,20 @@ _("Usage: %s [OPTIONS]...\n" "-s, --sort sort the identifiers in the normalized output\n" "-g, --group save configuration by group indexes\n" "-x, --nocheck save configuration without additional integrity checks\n" +"-V, --version print version\n" ), name); } +static void version(const char *name) +{ + printf( +_("%s version %s\n" +"libasound version %s\n" +"libatopology version %s\n" +), name, SND_UTIL_VERSION_STR, + snd_asoundlib_version(), snd_tplg_version()); +} + static int load(snd_tplg_t **tplg, const char *source_file, int cflags) { int fd, err; @@ -227,7 +239,7 @@ static int compile(const char *source_file, const char *output_file, int cflags) int main(int argc, char *argv[]) { - static const char short_options[] = "hc:n:u:v:o:sgxz"; + static const char short_options[] = "hc:n:u:v:o:sgxzV"; static const struct option long_options[] = { {"help", 0, NULL, 'h'}, {"verbose", 1, NULL, 'v'}, @@ -239,6 +251,7 @@ int main(int argc, char *argv[]) {"group", 0, NULL, 'g'}, {"nocheck", 0, NULL, 'x'}, {"dapm-nosort", 0, NULL, 'z'}, + {"version", 0, NULL, 'V'}, {0, 0, 0, 0}, }; char *source_file = NULL; @@ -286,6 +299,9 @@ int main(int argc, char *argv[]) case 'x': sflags |= SND_TPLG_SAVE_NOCHECK; break; + case 'V': + version(argv[0]); + return 0; default: fprintf(stderr, _("Try `%s --help' for more information.\n"), argv[0]); return 1; -- 2.16.4 ++++++ 0029-alsatplg-add-decode-command.patch ++++++ >From 786c3ee8144893dfb56b35c46542d3ded78d746c Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela <[email protected]> Date: Sun, 22 Dec 2019 15:44:56 +0100 Subject: [PATCH 29/35] alsatplg: add decode command Signed-off-by: Jaroslav Kysela <[email protected]> --- topology/alsatplg.rst | 3 ++ topology/topology.c | 111 ++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 87 insertions(+), 27 deletions(-) diff --git a/topology/alsatplg.rst b/topology/alsatplg.rst index 260454bfc526..56324d52f883 100644 --- a/topology/alsatplg.rst +++ b/topology/alsatplg.rst @@ -53,6 +53,9 @@ Available options: **-c**, **--compile** `FILE` source configuration file for the compilation + **-d**, **--decode** `FILE` + source binary topology file for the decode + **-n**, **--normalize** `FILE` parse and save the configuration file in the normalized format diff --git a/topology/topology.c b/topology/topology.c index 101f8ccf16ea..91d2fce655fe 100644 --- a/topology/topology.c +++ b/topology/topology.c @@ -44,9 +44,10 @@ static void usage(const char *name) _("Usage: %s [OPTIONS]...\n" "\n" "-h, --help help\n" -"-c, --compile=FILE compile file\n" -"-n, --normalize=FILE normalize file\n" -"-u, --dump=FILE dump (reparse) file\n" +"-c, --compile=FILE compile configuration file\n" +"-d, --decode=FILE decode binary topology file\n" +"-n, --normalize=FILE normalize configuration file\n" +"-u, --dump=FILE dump (reparse) configuration file\n" "-v, --verbose=LEVEL set verbosity level (0...1)\n" "-o, --output=FILE set output file\n" "-s, --sort sort the identifiers in the normalized output\n" @@ -66,10 +67,10 @@ _("%s version %s\n" snd_asoundlib_version(), snd_tplg_version()); } -static int load(snd_tplg_t **tplg, const char *source_file, int cflags) +static int load(const char *source_file, void **dst, size_t *dst_size) { - int fd, err; - char *buf, *buf2; + int fd; + void *buf, *buf2; size_t size, pos; ssize_t r; @@ -112,15 +113,31 @@ static int load(snd_tplg_t **tplg, const char *source_file, int cflags) goto _err; } + *dst = buf; + *dst_size = pos; + return 0; + +_nomem: + fprintf(stderr, _("No enough memory\n")); +_err: + if (fd != fileno(stdin)) + close(fd); + free(buf); + return 1; +} + +static int load_topology(snd_tplg_t **tplg, char *config, + size_t config_size, int cflags) +{ + int err; + *tplg = snd_tplg_create(cflags); if (*tplg == NULL) { fprintf(stderr, _("failed to create new topology context\n")); - free(buf); return 1; } - err = snd_tplg_load(*tplg, buf, pos); - free(buf); + err = snd_tplg_load(*tplg, config, config_size); if (err < 0) { fprintf(stderr, _("Unable to load configuration: %s\n"), snd_strerror(-err)); @@ -129,14 +146,6 @@ static int load(snd_tplg_t **tplg, const char *source_file, int cflags) } return 0; - -_nomem: - fprintf(stderr, _("No enough memory\n")); -_err: - if (fd != fileno(stdin)) - close(fd); - free(buf); - return 1; } static int save(const char *output_file, void *buf, size_t size) @@ -194,10 +203,15 @@ static int save(const char *output_file, void *buf, size_t size) static int dump(const char *source_file, const char *output_file, int cflags, int sflags) { snd_tplg_t *tplg; - char *text; + char *config, *text; + size_t size; int err; - err = load(&tplg, source_file, cflags); + err = load(source_file, (void **)&config, &size); + if (err) + return err; + err = load_topology(&tplg, config, size, cflags); + free(config); if (err) return err; err = snd_tplg_save(tplg, &text, sflags); @@ -215,17 +229,23 @@ static int dump(const char *source_file, const char *output_file, int cflags, in static int compile(const char *source_file, const char *output_file, int cflags) { snd_tplg_t *tplg; + char *config; void *bin; - size_t size; + size_t config_size, size; int err; - err = load(&tplg, source_file, cflags); + err = load(source_file, (void **)&config, &config_size); + if (err) + return err; + err = load_topology(&tplg, config, config_size, cflags); + free(config); if (err) return err; err = snd_tplg_build_bin(tplg, &bin, &size); snd_tplg_free(tplg); if (err < 0 || size == 0) { - fprintf(stderr, _("failed to compile context %s\n"), source_file); + fprintf(stderr, _("failed to compile context %s: %s\n"), + source_file, snd_strerror(-err)); return 1; } err = save(output_file, bin, size); @@ -233,17 +253,50 @@ static int compile(const char *source_file, const char *output_file, int cflags) return err; } -#define OP_COMPILE 1 -#define OP_NORMALIZE 2 -#define OP_DUMP 3 +static int decode(const char *source_file, const char *output_file, + int cflags, int dflags, int sflags) +{ + snd_tplg_t *tplg; + void *bin; + char *text; + size_t size; + int err; + + if (load(source_file, &bin, &size)) + return 1; + tplg = snd_tplg_create(cflags); + if (tplg == NULL) { + fprintf(stderr, _("failed to create new topology context\n")); + return 1; + } + err = snd_tplg_decode(tplg, bin, size, dflags); + free(bin); + if (err < 0) { + snd_tplg_free(tplg); + fprintf(stderr, _("failed to decode context %s: %s\n"), + source_file, snd_strerror(-err)); + return 1; + } + err = snd_tplg_save(tplg, &text, sflags); + snd_tplg_free(tplg); + if (err < 0) { + fprintf(stderr, _("Unable to save parsed configuration: %s\n"), + snd_strerror(-err)); + return 1; + } + err = save(output_file, text, strlen(text)); + free(text); + return err; +} int main(int argc, char *argv[]) { - static const char short_options[] = "hc:n:u:v:o:sgxzV"; + static const char short_options[] = "hc:d:n:u:v:o:sgxzV"; static const struct option long_options[] = { {"help", 0, NULL, 'h'}, {"verbose", 1, NULL, 'v'}, {"compile", 1, NULL, 'c'}, + {"decode", 1, NULL, 'd'}, {"normalize", 1, NULL, 'n'}, {"dump", 1, NULL, 'u'}, {"output", 1, NULL, 'o'}, @@ -256,7 +309,7 @@ int main(int argc, char *argv[]) }; char *source_file = NULL; char *output_file = NULL; - int c, err, op = 'c', cflags = 0, sflags = 0, option_index; + int c, err, op = 'c', cflags = 0, dflags = 0, sflags = 0, option_index; #ifdef ENABLE_NLS setlocale(LC_ALL, ""); @@ -278,6 +331,7 @@ int main(int argc, char *argv[]) cflags |= SND_TPLG_CREATE_DAPM_NOSORT; break; case 'c': + case 'd': case 'n': case 'u': if (source_file) { @@ -326,6 +380,9 @@ int main(int argc, char *argv[]) case 'c': err = compile(source_file, output_file, cflags); break; + case 'd': + err = decode(source_file, output_file, cflags, dflags, sflags); + break; default: err = dump(source_file, output_file, cflags, sflags); break; -- 2.16.4 ++++++ 0030-alsatplg-add-documentation-for-z-dapm-nosort-h.patch ++++++ >From 56e1b879d4bccda62e7c0177b0a395d57a37931c Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela <[email protected]> Date: Wed, 1 Jan 2020 17:45:06 +0100 Subject: [PATCH 30/35] alsatplg: add documentation for -z,--dapm-nosort (-h) Signed-off-by: Jaroslav Kysela <[email protected]> --- topology/topology.c | 1 + 1 file changed, 1 insertion(+) diff --git a/topology/topology.c b/topology/topology.c index 91d2fce655fe..ad0d108562df 100644 --- a/topology/topology.c +++ b/topology/topology.c @@ -53,6 +53,7 @@ _("Usage: %s [OPTIONS]...\n" "-s, --sort sort the identifiers in the normalized output\n" "-g, --group save configuration by group indexes\n" "-x, --nocheck save configuration without additional integrity checks\n" +"-z, --dapm-nosort do not sort the DAPM widgets\n" "-V, --version print version\n" ), name); } -- 2.16.4 ++++++ 0031-configure-fix-new-libatopology-check.patch ++++++ >From 996a638e04766df43cb8026673f93927b1047639 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela <[email protected]> Date: Fri, 3 Jan 2020 23:46:51 +0100 Subject: [PATCH 31/35] configure: fix new libatopology check --- configure.ac | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 4bee49be81ba..b7ed81a0d32c 100644 --- a/configure.ac +++ b/configure.ac @@ -49,6 +49,7 @@ AC_CHECK_LIB([asound], [snd_seq_client_info_get_pid], [HAVE_SEQ_CLIENT_INFO_GET_ if test "$HAVE_SEQ_CLIENT_INFO_GET_PID" = "yes" ; then AC_DEFINE([HAVE_SEQ_CLIENT_INFO_GET_PID], 1, [alsa-lib supports snd_seq_client_info_get_pid]) fi +AC_CHECK_LIB([atopology], [snd_tplg_save], [have_topology="no"]) # # NOTE: The library 'libffado' (at least v2.4.1) executes ctor/dtor of instances @@ -70,11 +71,6 @@ AM_CONDITIONAL(HAVE_TOPOLOGY, test "$have_topology" = "yes") AM_CONDITIONAL(HAVE_SAMPLERATE, test "$have_samplerate" = "yes") AM_CONDITIONAL(HAVE_FFADO, test "$have_ffado" = "yes") -# old libasound with the topology routines in the main library -if test "x$have_topology" = "xyes" -a "x$ALSA_TOPOLOGY_LIBS" = "x"; then - ALSA_TOPOLOGY_LIBS="$ALSA_LIBS" -fi - dnl Use tinyalsa alsabat_backend_tiny= AC_ARG_ENABLE(alsabat_backend_tiny, -- 2.16.4 ++++++ 0032-Use-__func__-instead-of-__FUNCTION__.patch ++++++ >From f80a290153f210bb80165ac8dc6b1dccaa24781d Mon Sep 17 00:00:00 2001 From: Michael Forney <[email protected]> Date: Wed, 5 Feb 2020 00:12:18 -0800 Subject: [PATCH 32/35] Use __func__ instead of __FUNCTION__ They are equivalent, but __func__ is in C99. __FUNCTION__ exists only for backwards compatibility with old gcc versions. Signed-off-by: Michael Forney <[email protected]> Reviewd-by: Takashi Sakamoto <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- alsactl/alsactl.h | 16 ++++++++-------- aplay/aplay.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h index 4f969ec2a4bc..69b539ca6be0 100644 --- a/alsactl/alsactl.h +++ b/alsactl/alsactl.h @@ -13,15 +13,15 @@ void cerror_(const char *fcn, long line, int cond, const char *fmt, ...); void dbg_(const char *fcn, long line, const char *fmt, ...); #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) -#define info(...) do { info_(__FUNCTION__, __LINE__, __VA_ARGS__); } while (0) -#define error(...) do { error_(__FUNCTION__, __LINE__, __VA_ARGS__); } while (0) -#define cerror(cond, ...) do { cerror_(__FUNCTION__, __LINE__, (cond) != 0, __VA_ARGS__); } while (0) -#define dbg(...) do { dbg_(__FUNCTION__, __LINE__, __VA_ARGS__); } while (0) +#define info(...) do { info_(__func__, __LINE__, __VA_ARGS__); } while (0) +#define error(...) do { error_(__func__, __LINE__, __VA_ARGS__); } while (0) +#define cerror(cond, ...) do { cerror_(__func__, __LINE__, (cond) != 0, __VA_ARGS__); } while (0) +#define dbg(...) do { dbg_(__func__, __LINE__, __VA_ARGS__); } while (0) #else -#define info(args...) do { info_(__FUNCTION__, __LINE__, ##args); } while (0) -#define error(args...) do { error_(__FUNCTION__, __LINE__, ##args); } while (0) -#define cerror(cond, ...) do { error_(__FUNCTION__, __LINE__, (cond) != 0, ##args); } while (0) -#define dbg(args...) do { dbg_(__FUNCTION__, __LINE__, ##args); } while (0) +#define info(args...) do { info_(__func__, __LINE__, ##args); } while (0) +#define error(args...) do { error_(__func__, __LINE__, ##args); } while (0) +#define cerror(cond, ...) do { error_(__func__, __LINE__, (cond) != 0, ##args); } while (0) +#define dbg(args...) do { dbg_(__func__, __LINE__, ##args); } while (0) #endif int init(const char *file, const char *cardname); diff --git a/aplay/aplay.c b/aplay/aplay.c index 1a887e412aae..908093c45c90 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -186,13 +186,13 @@ static const struct fmt_capture { #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) #define error(...) do {\ - fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \ + fprintf(stderr, "%s: %s:%d: ", command, __func__, __LINE__); \ fprintf(stderr, __VA_ARGS__); \ putc('\n', stderr); \ } while (0) #else #define error(args...) do {\ - fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \ + fprintf(stderr, "%s: %s:%d: ", command, __func__, __LINE__); \ fprintf(stderr, ##args); \ putc('\n', stderr); \ } while (0) -- 2.16.4 ++++++ 0033-Avoid-pointer-arithmetic-on-void.patch ++++++ >From 62a765087e3885a463dbf0d888c5d666da9ee7b3 Mon Sep 17 00:00:00 2001 From: Michael Forney <[email protected]> Date: Wed, 5 Feb 2020 00:12:19 -0800 Subject: [PATCH 33/35] Avoid pointer arithmetic on `void *` The pointer operand to the binary `+` operator must be to a complete object type. Signed-off-by: Michael Forney <[email protected]> Reviewed-by: Takashi Sakamoto <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- aplay/aplay.c | 4 ++-- axfer/xfer-libasound-irq-mmap.c | 7 ++++--- axfer/xfer-libasound-timer-mmap.c | 4 ++-- bat/common.c | 2 +- seq/aplaymidi/aplaymidi.c | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/aplay/aplay.c b/aplay/aplay.c index 908093c45c90..08395f695287 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -442,7 +442,7 @@ static ssize_t xwrite(int fd, const void *buf, size_t count) size_t offset = 0; while (offset < count) { - written = write(fd, buf + offset, count - offset); + written = write(fd, (char *)buf + offset, count - offset); if (written <= 0) return written; @@ -1210,7 +1210,7 @@ static int test_au(int fd, void *buffer) hwparams.channels = BE_INT(ap->channels); if (hwparams.channels < 1 || hwparams.channels > 256) return -1; - if ((size_t)safe_read(fd, buffer + sizeof(AuHeader), BE_INT(ap->hdr_size) - sizeof(AuHeader)) != BE_INT(ap->hdr_size) - sizeof(AuHeader)) { + if ((size_t)safe_read(fd, (char *)buffer + sizeof(AuHeader), BE_INT(ap->hdr_size) - sizeof(AuHeader)) != BE_INT(ap->hdr_size) - sizeof(AuHeader)) { error(_("read error")); prg_exit(EXIT_FAILURE); } diff --git a/axfer/xfer-libasound-irq-mmap.c b/axfer/xfer-libasound-irq-mmap.c index a13b3c300354..386e741de733 100644 --- a/axfer/xfer-libasound-irq-mmap.c +++ b/axfer/xfer-libasound-irq-mmap.c @@ -146,9 +146,10 @@ static int irq_mmap_process_frames(struct libasound_state *state, // TODO: Perhaps, the complex layout can be supported as a variation of // vector type. However, there's no driver with this layout. if (layout->vector == NULL) { - frame_buf = areas[0].addr; - frame_buf += snd_pcm_frames_to_bytes(state->handle, - frame_offset); + char *buf; + buf = areas[0].addr; + buf += snd_pcm_frames_to_bytes(state->handle, frame_offset); + frame_buf = buf; } else { int i; for (i = 0; i < layout->samples_per_frame; ++i) { diff --git a/axfer/xfer-libasound-timer-mmap.c b/axfer/xfer-libasound-timer-mmap.c index 1c642fe58b28..ba26e2995f5f 100644 --- a/axfer/xfer-libasound-timer-mmap.c +++ b/axfer/xfer-libasound-timer-mmap.c @@ -100,8 +100,8 @@ static void *get_buffer(struct libasound_state *state, if (layout->vector == NULL) { char *buf; - buf = areas[0].addr + snd_pcm_frames_to_bytes(state->handle, - frame_offset); + buf = areas[0].addr; + buf += snd_pcm_frames_to_bytes(state->handle, frame_offset); frame_buf = buf; } else { int i; diff --git a/bat/common.c b/bat/common.c index d3d1f285449c..339e749fd74a 100644 --- a/bat/common.c +++ b/bat/common.c @@ -231,7 +231,7 @@ int generate_input_data(struct bat *bat, void *buffer, int bytes, int frames) load = 0; while (1) { - err = fread(buffer + load, 1, bytes - load, bat->fp); + err = fread((char *)buffer + load, 1, bytes - load, bat->fp); if (0 == err) { if (feof(bat->fp)) { fprintf(bat->log, diff --git a/seq/aplaymidi/aplaymidi.c b/seq/aplaymidi/aplaymidi.c index 12d6fac3b0dc..b086e7015aa2 100644 --- a/seq/aplaymidi/aplaymidi.c +++ b/seq/aplaymidi/aplaymidi.c @@ -633,7 +633,7 @@ static void handle_big_sysex(snd_seq_event_t *ev) check_snd("sync output", err); if (sleep(1)) fatal("aborted"); - ev->data.ext.ptr += MIDI_BYTES_PER_SEC; + ev->data.ext.ptr = (char *)ev->data.ext.ptr + MIDI_BYTES_PER_SEC; length -= MIDI_BYTES_PER_SEC; } ev->data.ext.len = length; -- 2.16.4 ++++++ 0034-Use-lli-for-long-long-in-printf.patch ++++++ >From 646b3b1c0badbfd1b2ea7b82eb59d43a460c531c Mon Sep 17 00:00:00 2001 From: Michael Forney <[email protected]> Date: Wed, 5 Feb 2020 00:12:20 -0800 Subject: [PATCH 34/35] Use %lli for long long in printf The `L` length modifier only applies to floating-point conversion specifiers, and `ll` is used for `long long` integers. Although glibc accepts %Li, musl does not and returns EINVAL. Signed-off-by: Michael Forney <[email protected]> Reviewed-by: Takashi Sakamoto <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- alsactl/state.c | 4 ++-- amixer/amixer.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/alsactl/state.c b/alsactl/state.c index 38e85c06c0b0..22e0269fd30a 100644 --- a/alsactl/state.c +++ b/alsactl/state.c @@ -336,9 +336,9 @@ static int get_control(snd_ctl_t *handle, snd_ctl_elem_id_t *id, snd_config_t *t long long max = snd_ctl_elem_info_get_max64(info); long long step = snd_ctl_elem_info_get_step64(info); if (step) - sprintf(buf, "%Li - %Li (step %Li)", min, max, step); + sprintf(buf, "%lli - %lli (step %lli)", min, max, step); else - sprintf(buf, "%Li - %Li", min, max); + sprintf(buf, "%lli - %lli", min, max); err = snd_config_string_add(comment, "range", buf); if (err < 0) { error("snd_config_string_add: %s", snd_strerror(err)); diff --git a/amixer/amixer.c b/amixer/amixer.c index 928f7c5d6482..4c19a583e5b1 100644 --- a/amixer/amixer.c +++ b/amixer/amixer.c @@ -620,7 +620,7 @@ static int show_control(const char *space, snd_hctl_elem_t *elem, snd_ctl_elem_info_get_step(info)); break; case SND_CTL_ELEM_TYPE_INTEGER64: - printf(",min=%Li,max=%Li,step=%Li\n", + printf(",min=%lli,max=%lli,step=%lli\n", snd_ctl_elem_info_get_min64(info), snd_ctl_elem_info_get_max64(info), snd_ctl_elem_info_get_step64(info)); @@ -662,7 +662,7 @@ static int show_control(const char *space, snd_hctl_elem_t *elem, printf("%li", snd_ctl_elem_value_get_integer(control, idx)); break; case SND_CTL_ELEM_TYPE_INTEGER64: - printf("%Li", snd_ctl_elem_value_get_integer64(control, idx)); + printf("%lli", snd_ctl_elem_value_get_integer64(control, idx)); break; case SND_CTL_ELEM_TYPE_ENUMERATED: printf("%u", snd_ctl_elem_value_get_enumerated(control, idx)); -- 2.16.4 ++++++ 0035-Avoid-empty-initializer-list.patch ++++++ >From cb47f6dcf4200c64559ed2f008cabf8cc5f9d9a3 Mon Sep 17 00:00:00 2001 From: Michael Forney <[email protected]> Date: Wed, 5 Feb 2020 00:12:21 -0800 Subject: [PATCH 35/35] Avoid empty initializer list To zero-initialize an object, use `{0}` instead. Signed-off-by: Michael Forney <[email protected]> Reviewed-by: Takashi Sakamoto <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- alsamixer/cli.c | 2 +- amidi/amidi.c | 2 +- seq/aplaymidi/aplaymidi.c | 2 +- seq/aplaymidi/arecordmidi.c | 2 +- seq/aseqdump/aseqdump.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/alsamixer/cli.c b/alsamixer/cli.c index 3f8f52f03d4d..74683255a30a 100644 --- a/alsamixer/cli.c +++ b/alsamixer/cli.c @@ -58,7 +58,7 @@ static void parse_options(int argc, char *argv[]) { .name = "view", .has_arg = 1, .val = 'V' }, { .name = "no-color", .val = 'g' }, { .name = "abstraction", .has_arg = 1, .val = 'a' }, - { } + { 0 } }; int option; int card_index; diff --git a/amidi/amidi.c b/amidi/amidi.c index c6268e4c2ccd..cde4697c7e30 100644 --- a/amidi/amidi.c +++ b/amidi/amidi.c @@ -469,7 +469,7 @@ int main(int argc, char *argv[]) {"active-sensing", 0, NULL, 'a'}, {"clock", 0, NULL, 'c'}, {"sysex-interval", 1, NULL, 'i'}, - { } + {0} }; int c, err, ok = 0; int ignore_active_sensing = 1; diff --git a/seq/aplaymidi/aplaymidi.c b/seq/aplaymidi/aplaymidi.c index b086e7015aa2..e8491e13148d 100644 --- a/seq/aplaymidi/aplaymidi.c +++ b/seq/aplaymidi/aplaymidi.c @@ -869,7 +869,7 @@ int main(int argc, char *argv[]) {"list", 0, NULL, 'l'}, {"port", 1, NULL, 'p'}, {"delay", 1, NULL, 'd'}, - {} + {0} }; int c; int do_list = 0; diff --git a/seq/aplaymidi/arecordmidi.c b/seq/aplaymidi/arecordmidi.c index 604cd0d29722..2034df76b679 100644 --- a/seq/aplaymidi/arecordmidi.c +++ b/seq/aplaymidi/arecordmidi.c @@ -740,7 +740,7 @@ int main(int argc, char *argv[]) {"metronome", 1, NULL, 'm'}, {"timesig", 1, NULL, 'i'}, {"num-events", 1, NULL, 'n'}, - { } + {0} }; char *filename = NULL; diff --git a/seq/aseqdump/aseqdump.c b/seq/aseqdump/aseqdump.c index 578e06fbcb22..44ae3bbc5654 100644 --- a/seq/aseqdump/aseqdump.c +++ b/seq/aseqdump/aseqdump.c @@ -357,7 +357,7 @@ int main(int argc, char *argv[]) {"version", 0, NULL, 'V'}, {"list", 0, NULL, 'l'}, {"port", 1, NULL, 'p'}, - { } + {0} }; int do_list = 0; -- 2.16.4
