diff options
| author | Michael Forney <mforney@mforney.org> | 2021-08-30 20:13:14 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2021-08-31 14:46:20 -0700 |
| commit | e4f1e4f50393a005ae1bb9a9ccbf02b8bd3c7670 (patch) | |
| tree | 467f41428cbbc0676d42d05b45168fa612fd3367 /pkg/tinyalsa | |
| parent | 80ad9f758b233dc2e806607bbae8338029093cd6 (diff) | |
Add tinyalsa 2.0.0
Diffstat (limited to 'pkg/tinyalsa')
| -rw-r--r-- | pkg/tinyalsa/gen.lua | 33 | ||||
| -rw-r--r-- | pkg/tinyalsa/patch/0001-fix-remaining_data_size-is-0-when-not-playing-a-wave.patch | 73 | ||||
| -rw-r--r-- | pkg/tinyalsa/patch/0002-fix-the-zero-fd-closing-problem.patch | 36 | ||||
| -rw-r--r-- | pkg/tinyalsa/patch/0003-make-use-of-snd_utils_close_dev_node-conditional-on-.patch | 27 | ||||
| -rw-r--r-- | pkg/tinyalsa/patch/0004-expose-pcm_state-in-public-API.patch | 25 | ||||
| m--------- | pkg/tinyalsa/src | 0 | ||||
| -rw-r--r-- | pkg/tinyalsa/ver | 1 |
7 files changed, 195 insertions, 0 deletions
diff --git a/pkg/tinyalsa/gen.lua b/pkg/tinyalsa/gen.lua new file mode 100644 index 00000000..d1713458 --- /dev/null +++ b/pkg/tinyalsa/gen.lua @@ -0,0 +1,33 @@ +cflags{ + '-std=c99', '-Wall', '-Wpedantic', '-Wno-overflow', + '-D _POSIX_C_SOURCE=201112L', + '-I $srcdir/include', + '-isystem $builddir/pkg/linux-headers/include', +} + +pkg.deps = {'pkg/linux-headers/headers'} + +pkg.hdrs = copy('$outdir/include/tinyalsa', '$srcdir/include/tinyalsa', { + 'attributes.h', + 'pcm.h', + 'mixer.h', + 'asoundlib.h', + 'version.h', +}) + +lib('libtinyalsa.a', [[ + src/( + limits.c + pcm.c + pcm_hw.c + mixer.c + mixer_hw.c + ) +]]) + +for _, tool in ipairs{'tinycap', 'tinymix', 'tinypcminfo', 'tinyplay'} do + file('bin/'..tool, '755', exe(tool, {'utils/'..tool..'.c', 'libtinyalsa.a'})) + man{'$srcdir/utils/'..tool..'.1'} +end + +fetch 'git' diff --git a/pkg/tinyalsa/patch/0001-fix-remaining_data_size-is-0-when-not-playing-a-wave.patch b/pkg/tinyalsa/patch/0001-fix-remaining_data_size-is-0-when-not-playing-a-wave.patch new file mode 100644 index 00000000..c8f3053a --- /dev/null +++ b/pkg/tinyalsa/patch/0001-fix-remaining_data_size-is-0-when-not-playing-a-wave.patch @@ -0,0 +1,73 @@ +From 7ebd3ac08a537207851eb631bdcab01f03ab91b6 Mon Sep 17 00:00:00 2001 +From: dvdli <dvdli@google.com> +Date: Tue, 29 Jun 2021 21:35:37 +0800 +Subject: [PATCH] fix remaining_data_size is 0 when not playing a wave file + +--- + utils/tinyplay.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/utils/tinyplay.c b/utils/tinyplay.c +index 4c7ccf6..b2c60bc 100644 +--- a/utils/tinyplay.c ++++ b/utils/tinyplay.c +@@ -27,6 +27,7 @@ + */ + + #include <tinyalsa/asoundlib.h> ++#include <stdbool.h> + #include <stdio.h> + #include <stdlib.h> + #include <stdint.h> +@@ -98,6 +99,7 @@ struct ctx { + struct chunk_fmt chunk_fmt; + + FILE *file; ++ size_t file_size; + }; + + int ctx_init(struct ctx* ctx, const struct cmd *cmd) +@@ -113,6 +115,9 @@ int ctx_init(struct ctx* ctx, const struct cmd *cmd) + ctx->file = stdin; + } else { + ctx->file = fopen(cmd->filename, "rb"); ++ fseek(ctx->file, 0L, SEEK_END); ++ ctx->file_size = ftell(ctx->file); ++ fseek(ctx->file, 0L, SEEK_SET); + } + + if (ctx->file == NULL) { +@@ -162,6 +167,7 @@ int ctx_init(struct ctx* ctx, const struct cmd *cmd) + config.channels = ctx->chunk_fmt.num_channels; + config.rate = ctx->chunk_fmt.sample_rate; + bits = ctx->chunk_fmt.bits_per_sample; ++ ctx->file_size = (size_t) ctx->chunk_header.sz; + } + + if (bits == 8) { +@@ -396,9 +402,10 @@ int sample_is_playable(const struct cmd *cmd) + int play_sample(struct ctx *ctx) + { + char *buffer; ++ bool is_stdin_source = ctx->file == stdin; + size_t buffer_size = 0; + size_t num_read = 0; +- size_t remaining_data_size = ctx->chunk_header.sz; ++ size_t remaining_data_size = is_stdin_source ? SIZE_MAX : ctx->file_size; + size_t read_size = 0; + const struct pcm_config *config = pcm_get_config(ctx->pcm); + +@@ -426,7 +433,9 @@ int play_sample(struct ctx *ctx) + fprintf(stderr, "error playing sample\n"); + break; + } +- remaining_data_size -= num_read; ++ if (!is_stdin_source) { ++ remaining_data_size -= num_read; ++ } + } + } while (!close && num_read > 0 && remaining_data_size > 0); + +-- +2.32.0 + diff --git a/pkg/tinyalsa/patch/0002-fix-the-zero-fd-closing-problem.patch b/pkg/tinyalsa/patch/0002-fix-the-zero-fd-closing-problem.patch new file mode 100644 index 00000000..f664502d --- /dev/null +++ b/pkg/tinyalsa/patch/0002-fix-the-zero-fd-closing-problem.patch @@ -0,0 +1,36 @@ +From 27a6c9e762297ce37f28619166b9dd134ffbdf92 Mon Sep 17 00:00:00 2001 +From: dvdli <dvdli@google.com> +Date: Tue, 13 Jul 2021 14:47:47 +0800 +Subject: [PATCH] fix the zero fd closing problem + +The pcm_hw_close refused to close the zero fd. Add "equal to" +condition and modify the type of fd to int to close the zero fd. +--- + src/pcm_hw.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/pcm_hw.c b/src/pcm_hw.c +index 38b2e83..9f01fb0 100644 +--- a/src/pcm_hw.c ++++ b/src/pcm_hw.c +@@ -50,7 +50,7 @@ struct pcm_hw_data { + /** Device number for the pcm device */ + unsigned int device; + /** File descriptor to the pcm device file node */ +- unsigned int fd; ++ int fd; + /** Pointer to the pcm node from snd card definiton */ + struct snd_node *node; + }; +@@ -59,7 +59,7 @@ static void pcm_hw_close(void *data) + { + struct pcm_hw_data *hw_data = data; + +- if (hw_data->fd > 0) ++ if (hw_data->fd >= 0) + close(hw_data->fd); + + free(hw_data); +-- +2.32.0 + diff --git a/pkg/tinyalsa/patch/0003-make-use-of-snd_utils_close_dev_node-conditional-on-.patch b/pkg/tinyalsa/patch/0003-make-use-of-snd_utils_close_dev_node-conditional-on-.patch new file mode 100644 index 00000000..13dfa27d --- /dev/null +++ b/pkg/tinyalsa/patch/0003-make-use-of-snd_utils_close_dev_node-conditional-on-.patch @@ -0,0 +1,27 @@ +From d11a02d9217b7713415be4bb6a4b6ee54df894c7 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Mon, 30 Aug 2021 20:11:37 -0700 +Subject: [PATCH] make use of snd_utils_close_dev_node conditional on + TINYALSA_USES_PLUGINS + +--- + src/pcm.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/pcm.c b/src/pcm.c +index 10e477b..8a2c6be 100644 +--- a/src/pcm.c ++++ b/src/pcm.c +@@ -975,7 +975,9 @@ int pcm_close(struct pcm *pcm) + pcm->ops->munmap(pcm->data, pcm->mmap_buffer, pcm_frames_to_bytes(pcm, pcm->buffer_size)); + } + ++#if TINYALSA_USES_PLUGINS + snd_utils_close_dev_node(pcm->snd_node); ++#endif + pcm->ops->close(pcm->data); + pcm->buffer_size = 0; + pcm->fd = -1; +-- +2.32.0 + diff --git a/pkg/tinyalsa/patch/0004-expose-pcm_state-in-public-API.patch b/pkg/tinyalsa/patch/0004-expose-pcm_state-in-public-API.patch new file mode 100644 index 00000000..bb3cf8be --- /dev/null +++ b/pkg/tinyalsa/patch/0004-expose-pcm_state-in-public-API.patch @@ -0,0 +1,25 @@ +From f5a956cbb1ad414b8da0127cf997cfe43d7a6bcb Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 31 Aug 2021 14:24:09 -0700 +Subject: [PATCH] expose pcm_state in public API + +--- + include/tinyalsa/pcm.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/tinyalsa/pcm.h b/include/tinyalsa/pcm.h +index b40550c..1d77e53 100644 +--- a/include/tinyalsa/pcm.h ++++ b/include/tinyalsa/pcm.h +@@ -359,6 +359,8 @@ int pcm_start(struct pcm *pcm); + + int pcm_stop(struct pcm *pcm); + ++int pcm_state(struct pcm *pcm); ++ + int pcm_wait(struct pcm *pcm, int timeout); + + long pcm_get_delay(struct pcm *pcm); +-- +2.32.0 + diff --git a/pkg/tinyalsa/src b/pkg/tinyalsa/src new file mode 160000 +Subproject 1c5fb68ced57d838f2b7ecd0c00bc1fefc9ab60 diff --git a/pkg/tinyalsa/ver b/pkg/tinyalsa/ver new file mode 100644 index 00000000..4614535e --- /dev/null +++ b/pkg/tinyalsa/ver @@ -0,0 +1 @@ +2.0.0 r0 |
