alsa/0031-pcm-plugin-fix-status-code-for-capture.patch

55 lines
1.8 KiB
Diff
Raw Normal View History

Accepting request 860483 from home:tiwai:branches:multimedia:libs - Backport upstream fixes: a PCM plugin regression fix about snd_pcm_status() call, plugin directory handling fixes, missing audio timestamp types, use-after-free fix for conf parser, PCM plugin delay account fixes, etc: 0001-dlmisc-the-snd_plugin_dir_set-snd_plugin_dir-must-be.patch 0002-dlmisc-fix-snd_plugin_dir-locking-for-not-DL_ORIGIN_.patch 0003-pcm-snd_pcm_mmap_readi-fix-typo-in-comment.patch 0007-pcm-set-the-snd_pcm_ioplug_status-tstamp-field.patch 0009-pcm-Add-snd_pcm_audio_tstamp_type_t-constants.patch 0010-test-audio_time-Make-use-of-SND_PCM_AUDIO_TSTAMP_TYP.patch 0011-pcm-Fix-a-typo-in-SND_PCM_AUDIO_TSTAMP_TYPE_LAST-def.patch 0012-conf-fix-use-after-free-in-_snd_config_load_with_inc.patch 0013-ucm-fix-bad-frees-in-get_list0-and-get_list20.patch 0014-rawmidi-fix-memory-leak-in-snd_rawmidi_virtual_open.patch 0015-timer-fix-sizeof-operator-mismatch-in-snd_timer_quer.patch 0016-pcm-remove-dead-assignments-from-snd_pcm_rate_-commi.patch 0017-pcm_multi-remove-dead-assignment-from-_snd_pcm_multi.patch 0018-conf-fix-get_hexachar-return-value.patch 0019-pcm-fix-__snd_pcm_state-return-value.patch 0020-confmisc-fix-memory-leak-in-snd_func_concat.patch 0021-conf-fix-return-code-in-_snd_config_load_with_includ.patch 0022-pcm-plugin-status-fix-the-return-value-regression.patch 0023-pcm-plugin-status-revert-the-recent-changes.patch 0024-pcm-plugin-tidy-snd_pcm_plugin_avail_update.patch 0025-pcm-plugin-optimize-sync-in-snd_pcm_plugin_status.patch 0026-Revert-pcm_plugin-fix-delay.patch 0027-pcm-ioplug-fix-the-delay-calculation-in-the-status-c.patch 0028-pcm-rate-tidy-up-snd_pcm_rate_avail_update.patch 0029-pcm-ioplug-fix-the-delay-calculation-for-old-plugins.patch OBS-URL: https://build.opensuse.org/request/show/860483 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=290
2021-01-05 14:46:39 +00:00
From da5b70d3fae091a8568b80a476c1cf340965805a Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Mon, 4 Jan 2021 12:32:25 +0100
Subject: [PATCH 31/33] pcm: plugin - fix status code for capture
The recent updates do not take in account the possible
calls for the capture stream. Fix the avail and delay
inconsistencies (and assert).
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
src/pcm/pcm_plugin.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c
index 5787a43d09f4..7ed6f25a2eea 100644
--- a/src/pcm/pcm_plugin.c
+++ b/src/pcm/pcm_plugin.c
@@ -545,13 +545,30 @@ static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
static int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
{
snd_pcm_plugin_t *plugin = pcm->private_data;
- snd_pcm_sframes_t err;
+ snd_pcm_sframes_t err, diff;
err = snd_pcm_status(plugin->gen.slave, status);
if (err < 0)
return err;
- assert(status->appl_ptr == *pcm->appl.ptr);
snd_pcm_plugin_sync_hw_ptr(pcm, status->hw_ptr, status->avail);
+ /*
+ * For capture stream, the situation is more complicated, because
+ * snd_pcm_plugin_avail_update() commits the data to the slave pcm.
+ * It means that the slave appl_ptr is updated. Calculate diff and
+ * update the delay and avail.
+ *
+ * This resolves the data inconsistency for immediate calls:
+ * snd_pcm_avail_update()
+ * snd_pcm_status()
+ */
+ if (pcm->stream == SND_PCM_STREAM_CAPTURE) {
+ status->appl_ptr = *pcm->appl.ptr;
+ diff = pcm_frame_diff(status->appl_ptr, *pcm->appl.ptr, pcm->boundary);
+ status->avail += diff;
+ status->delay += diff;
+ } else {
+ assert(status->appl_ptr == *pcm->appl.ptr);
+ }
return 0;
}
--
2.26.2