|
|
e11113 |
From e47c11822d6b459a9b3704b3ee6a4a5c9a1b85be Mon Sep 17 00:00:00 2001
|
|
|
e11113 |
From: Jaroslav Kysela <perex@perex.cz>
|
|
|
e11113 |
Date: Tue, 29 Jun 2021 18:02:27 +0200
|
|
|
e11113 |
Subject: [PATCH 1/2] control: remap - assign right name to the child handle
|
|
|
e11113 |
for no-op
|
|
|
e11113 |
|
|
|
e11113 |
Fixes: https://github.com/alsa-project/alsa-utils/issues/100
|
|
|
e11113 |
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
|
|
e11113 |
---
|
|
|
e11113 |
src/control/control_remap.c | 4 ++++
|
|
|
e11113 |
1 file changed, 4 insertions(+)
|
|
|
e11113 |
|
|
|
e11113 |
diff --git a/src/control/control_remap.c b/src/control/control_remap.c
|
|
|
e11113 |
index a85c1725..81524014 100644
|
|
|
e11113 |
--- a/src/control/control_remap.c
|
|
|
e11113 |
+++ b/src/control/control_remap.c
|
|
|
e11113 |
@@ -1173,6 +1173,10 @@ int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *rema
|
|
|
e11113 |
/* no-op check, remove the plugin */
|
|
|
e11113 |
if (priv->map_items == 0 && priv->remap_items == 0) {
|
|
|
e11113 |
remap_free(priv);
|
|
|
e11113 |
+ free(child->name);
|
|
|
e11113 |
+ child->name = name ? strdup(name) : NULL;
|
|
|
e11113 |
+ if (name && !child->name)
|
|
|
e11113 |
+ return -ENOMEM;
|
|
|
e11113 |
*handlep = child;
|
|
|
e11113 |
return 0;
|
|
|
e11113 |
}
|
|
|
e11113 |
--
|
|
|
e11113 |
2.31.1
|
|
|
e11113 |
|
|
|
e11113 |
|
|
|
e11113 |
From 23a191a82c693456e61431ab699cddc1e5782a26 Mon Sep 17 00:00:00 2001
|
|
|
e11113 |
From: Jaroslav Kysela <perex@perex.cz>
|
|
|
e11113 |
Date: Tue, 29 Jun 2021 19:31:28 +0200
|
|
|
e11113 |
Subject: [PATCH 2/2] control: remap - assign right name to the child handle
|
|
|
e11113 |
for no-op (2nd case)
|
|
|
e11113 |
|
|
|
e11113 |
Fixes: https://github.com/alsa-project/alsa-utils/issues/100
|
|
|
e11113 |
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
|
|
e11113 |
---
|
|
|
e11113 |
src/control/control_remap.c | 10 +++++-----
|
|
|
e11113 |
1 file changed, 5 insertions(+), 5 deletions(-)
|
|
|
e11113 |
|
|
|
e11113 |
diff --git a/src/control/control_remap.c b/src/control/control_remap.c
|
|
|
e11113 |
index 81524014..4914f960 100644
|
|
|
e11113 |
--- a/src/control/control_remap.c
|
|
|
e11113 |
+++ b/src/control/control_remap.c
|
|
|
e11113 |
@@ -1154,6 +1154,10 @@ int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *rema
|
|
|
e11113 |
snd_ctl_t *ctl;
|
|
|
e11113 |
int result, err;
|
|
|
e11113 |
|
|
|
e11113 |
+ /* no-op, remove the plugin */
|
|
|
e11113 |
+ if (!remap && !map)
|
|
|
e11113 |
+ goto _noop;
|
|
|
e11113 |
+
|
|
|
e11113 |
priv = calloc(1, sizeof(*priv));
|
|
|
e11113 |
if (priv == NULL)
|
|
|
e11113 |
return -ENOMEM;
|
|
|
e11113 |
@@ -1173,6 +1177,7 @@ int snd_ctl_remap_open(snd_ctl_t **handlep, const char *name, snd_config_t *rema
|
|
|
e11113 |
/* no-op check, remove the plugin */
|
|
|
e11113 |
if (priv->map_items == 0 && priv->remap_items == 0) {
|
|
|
e11113 |
remap_free(priv);
|
|
|
e11113 |
+ _noop:
|
|
|
e11113 |
free(child->name);
|
|
|
e11113 |
child->name = name ? strdup(name) : NULL;
|
|
|
e11113 |
if (name && !child->name)
|
|
|
e11113 |
@@ -1316,11 +1321,6 @@ int _snd_ctl_remap_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd
|
|
|
e11113 |
err = _snd_ctl_open_child(&cctl, root, child, mode, conf);
|
|
|
e11113 |
if (err < 0)
|
|
|
e11113 |
return err;
|
|
|
e11113 |
- /* no-op, remove the plugin */
|
|
|
e11113 |
- if (!remap && !map) {
|
|
|
e11113 |
- *handlep = cctl;
|
|
|
e11113 |
- return 0;
|
|
|
e11113 |
- }
|
|
|
e11113 |
err = snd_ctl_remap_open(handlep, name, remap, map, cctl, mode);
|
|
|
e11113 |
if (err < 0)
|
|
|
e11113 |
snd_ctl_close(cctl);
|
|
|
e11113 |
--
|
|
|
e11113 |
2.31.1
|
|
|
e11113 |
|
|
|
e11113 |
From dd609ef9684987d3ca61d5c5cc3c77589ff9c29f Mon Sep 17 00:00:00 2001
|
|
|
e11113 |
From: Jaroslav Kysela <perex@perex.cz>
|
|
|
e11113 |
Date: Mon, 21 Jun 2021 09:28:41 +0200
|
|
|
e11113 |
Subject: [PATCH] pcm: direct plugins - fix hw_ptr in the status callback
|
|
|
e11113 |
|
|
|
e11113 |
The parent hw_ptr may be in another range (boundary limit).
|
|
|
e11113 |
Set the correct value for the caller.
|
|
|
e11113 |
|
|
|
e11113 |
BugLink: https://github.com/alsa-project/alsa-lib/issues/155
|
|
|
e11113 |
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
|
|
e11113 |
---
|
|
|
e11113 |
src/pcm/pcm_dmix.c | 1 +
|
|
|
e11113 |
src/pcm/pcm_dshare.c | 1 +
|
|
|
e11113 |
src/pcm/pcm_dsnoop.c | 1 +
|
|
|
e11113 |
3 files changed, 3 insertions(+)
|
|
|
e11113 |
|
|
|
e11113 |
diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c
|
|
|
e11113 |
index 0d0d0bff..94dbb1e0 100644
|
|
|
e11113 |
--- a/src/pcm/pcm_dmix.c
|
|
|
e11113 |
+++ b/src/pcm/pcm_dmix.c
|
|
|
e11113 |
@@ -491,6 +491,7 @@ static int snd_pcm_dmix_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|
|
e11113 |
}
|
|
|
e11113 |
|
|
|
e11113 |
status->state = snd_pcm_dmix_state(pcm);
|
|
|
e11113 |
+ status->hw_ptr = *pcm->hw.ptr; /* boundary may be different */
|
|
|
e11113 |
status->appl_ptr = *pcm->appl.ptr; /* slave PCM doesn't set appl_ptr */
|
|
|
e11113 |
status->trigger_tstamp = dmix->trigger_tstamp;
|
|
|
e11113 |
status->avail = snd_pcm_mmap_playback_avail(pcm);
|
|
|
e11113 |
diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c
|
|
|
e11113 |
index a918512b..01814dc8 100644
|
|
|
e11113 |
--- a/src/pcm/pcm_dshare.c
|
|
|
e11113 |
+++ b/src/pcm/pcm_dshare.c
|
|
|
e11113 |
@@ -243,6 +243,7 @@ static int snd_pcm_dshare_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|
|
e11113 |
break;
|
|
|
e11113 |
}
|
|
|
e11113 |
status->state = snd_pcm_dshare_state(pcm);
|
|
|
e11113 |
+ status->hw_ptr = *pcm->hw.ptr; /* boundary may be different */
|
|
|
e11113 |
status->appl_ptr = *pcm->appl.ptr; /* slave PCM doesn't set appl_ptr */
|
|
|
e11113 |
status->trigger_tstamp = dshare->trigger_tstamp;
|
|
|
e11113 |
status->avail = snd_pcm_mmap_playback_avail(pcm);
|
|
|
e11113 |
diff --git a/src/pcm/pcm_dsnoop.c b/src/pcm/pcm_dsnoop.c
|
|
|
e11113 |
index 2c3b9f43..3f28df99 100644
|
|
|
e11113 |
--- a/src/pcm/pcm_dsnoop.c
|
|
|
e11113 |
+++ b/src/pcm/pcm_dsnoop.c
|
|
|
e11113 |
@@ -193,6 +193,7 @@ static int snd_pcm_dsnoop_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|
|
e11113 |
snd_pcm_status(dsnoop->spcm, status);
|
|
|
e11113 |
state = snd_pcm_state(dsnoop->spcm);
|
|
|
e11113 |
status->state = state == SND_PCM_STATE_RUNNING ? dsnoop->state : state;
|
|
|
e11113 |
+ status->hw_ptr = *pcm->hw.ptr; /* boundary may be different */
|
|
|
e11113 |
status->appl_ptr = *pcm->appl.ptr; /* slave PCM doesn't set appl_ptr */
|
|
|
e11113 |
status->trigger_tstamp = dsnoop->trigger_tstamp;
|
|
|
e11113 |
status->avail = snd_pcm_mmap_capture_avail(pcm);
|
|
|
e11113 |
--
|
|
|
e11113 |
2.31.1
|
|
|
e11113 |
|
|
|
e11113 |
From e0e084659083c2ab75d5c894f24227ea2f67010f Mon Sep 17 00:00:00 2001
|
|
|
e11113 |
From: Jaroslav Kysela <perex@perex.cz>
|
|
|
e11113 |
Date: Mon, 21 Jun 2021 15:14:18 +0200
|
|
|
e11113 |
Subject: [PATCH] pcm: direct plugins - fix bad memory access when channel
|
|
|
e11113 |
bindings do not match hw
|
|
|
e11113 |
|
|
|
e11113 |
Fix and cleanup snd_pcm_direct_check_interleave() function.
|
|
|
e11113 |
Add requested / hardware channel check and use goto when the interleaved
|
|
|
e11113 |
|
|
|
e11113 |
Fixes: https://github.com/alsa-project/alsa-lib/issues/117
|
|
|
e11113 |
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
|
|
e11113 |
---
|
|
|
e11113 |
src/pcm/pcm_direct.c | 40 +++++++++++++++++-----------------------
|
|
|
e11113 |
1 file changed, 17 insertions(+), 23 deletions(-)
|
|
|
e11113 |
|
|
|
e11113 |
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
|
|
|
e11113 |
index d50503e3..90417b2f 100644
|
|
|
e11113 |
--- a/src/pcm/pcm_direct.c
|
|
|
e11113 |
+++ b/src/pcm/pcm_direct.c
|
|
|
e11113 |
@@ -1627,43 +1627,37 @@ int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix)
|
|
|
e11113 |
int snd_pcm_direct_check_interleave(snd_pcm_direct_t *dmix, snd_pcm_t *pcm)
|
|
|
e11113 |
{
|
|
|
e11113 |
unsigned int chn, channels;
|
|
|
e11113 |
- int bits, interleaved = 1;
|
|
|
e11113 |
+ int bits;
|
|
|
e11113 |
const snd_pcm_channel_area_t *dst_areas;
|
|
|
e11113 |
const snd_pcm_channel_area_t *src_areas;
|
|
|
e11113 |
|
|
|
e11113 |
bits = snd_pcm_format_physical_width(pcm->format);
|
|
|
e11113 |
if ((bits % 8) != 0)
|
|
|
e11113 |
- interleaved = 0;
|
|
|
e11113 |
+ goto __nointerleaved;
|
|
|
e11113 |
channels = dmix->channels;
|
|
|
e11113 |
+ if (channels != dmix->spcm->channels)
|
|
|
e11113 |
+ goto __nointerleaved;
|
|
|
e11113 |
dst_areas = snd_pcm_mmap_areas(dmix->spcm);
|
|
|
e11113 |
src_areas = snd_pcm_mmap_areas(pcm);
|
|
|
e11113 |
for (chn = 1; chn < channels; chn++) {
|
|
|
e11113 |
- if (dst_areas[chn-1].addr != dst_areas[chn].addr) {
|
|
|
e11113 |
- interleaved = 0;
|
|
|
e11113 |
- break;
|
|
|
e11113 |
- }
|
|
|
e11113 |
- if (src_areas[chn-1].addr != src_areas[chn].addr) {
|
|
|
e11113 |
- interleaved = 0;
|
|
|
e11113 |
- break;
|
|
|
e11113 |
- }
|
|
|
e11113 |
+ if (dst_areas[chn-1].addr != dst_areas[chn].addr)
|
|
|
e11113 |
+ goto __nointerleaved;
|
|
|
e11113 |
+ if (src_areas[chn-1].addr != src_areas[chn].addr)
|
|
|
e11113 |
+ goto __nointerleaved;
|
|
|
e11113 |
}
|
|
|
e11113 |
for (chn = 0; chn < channels; chn++) {
|
|
|
e11113 |
- if (dmix->bindings && dmix->bindings[chn] != chn) {
|
|
|
e11113 |
- interleaved = 0;
|
|
|
e11113 |
- break;
|
|
|
e11113 |
- }
|
|
|
e11113 |
+ if (dmix->bindings && dmix->bindings[chn] != chn)
|
|
|
e11113 |
+ goto __nointerleaved;
|
|
|
e11113 |
if (dst_areas[chn].first != chn * bits ||
|
|
|
e11113 |
- dst_areas[chn].step != channels * bits) {
|
|
|
e11113 |
- interleaved = 0;
|
|
|
e11113 |
- break;
|
|
|
e11113 |
- }
|
|
|
e11113 |
+ dst_areas[chn].step != channels * bits)
|
|
|
e11113 |
+ goto __nointerleaved;
|
|
|
e11113 |
if (src_areas[chn].first != chn * bits ||
|
|
|
e11113 |
- src_areas[chn].step != channels * bits) {
|
|
|
e11113 |
- interleaved = 0;
|
|
|
e11113 |
- break;
|
|
|
e11113 |
- }
|
|
|
e11113 |
+ src_areas[chn].step != channels * bits)
|
|
|
e11113 |
+ goto __nointerleaved;
|
|
|
e11113 |
}
|
|
|
e11113 |
- return dmix->interleaved = interleaved;
|
|
|
e11113 |
+ return dmix->interleaved = 1;
|
|
|
e11113 |
+__nointerleaved:
|
|
|
e11113 |
+ return dmix->interleaved = 0;
|
|
|
e11113 |
}
|
|
|
e11113 |
|
|
|
e11113 |
/*
|
|
|
e11113 |
--
|
|
|
e11113 |
2.31.1
|
|
|
e11113 |
|