From db906bd9627be9c172369eaedd8171440b8f521a1ac16dd201e9184056a1034d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 22 Jan 2021 15:15:25 +0000 Subject: [PATCH] Accepting request 866049 from home:tiwai:branches:multimedia:libs - Yet more fixes for the crash with dmix plugin (bsc#1181194): 0045-pcm-direct-Fix-the-missing-appl_ptr-update.patch 0046-pcm-ioplug-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_statu.patch 0047-pcm-null-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch 0048-pcm-share-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch OBS-URL: https://build.opensuse.org/request/show/866049 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=293 --- ...rect-Fix-the-missing-appl_ptr-update.patch | 61 +++++++++++++++++++ ...appl_ptr-and-hw_ptr-in-snd_pcm_statu.patch | 31 ++++++++++ ...ppl_ptr-and-hw_ptr-in-snd_pcm_status.patch | 29 +++++++++ ...ppl_ptr-and-hw_ptr-in-snd_pcm_status.patch | 30 +++++++++ alsa.changes | 9 +++ alsa.spec | 8 +++ 6 files changed, 168 insertions(+) create mode 100644 0045-pcm-direct-Fix-the-missing-appl_ptr-update.patch create mode 100644 0046-pcm-ioplug-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_statu.patch create mode 100644 0047-pcm-null-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch create mode 100644 0048-pcm-share-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch diff --git a/0045-pcm-direct-Fix-the-missing-appl_ptr-update.patch b/0045-pcm-direct-Fix-the-missing-appl_ptr-update.patch new file mode 100644 index 0000000..37956b8 --- /dev/null +++ b/0045-pcm-direct-Fix-the-missing-appl_ptr-update.patch @@ -0,0 +1,61 @@ +From 8e15c712ed96ea8d1314e94b15a946916394b17b Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Fri, 22 Jan 2021 15:37:08 +0100 +Subject: [PATCH 45/48] pcm: direct: Fix the missing appl_ptr update + +A snd_pcm_status() call for the direct plugins receives the status +from the slave PCM, but this doesn't contain a valid appl_ptr, since +the slave PCM for the direct plugins is in a free-wheel mode, hence +the appl_ptr is always zero. This result in the inconsistent +status->appl_ptr and pcm->appl.ptr, hitting the recently introduced +assert() call. + +Fix it by transferring the plugin's appl_ptr to the upper caller. + +BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1181194 +Signed-off-by: Takashi Iwai +--- + src/pcm/pcm_dmix.c | 1 + + src/pcm/pcm_dshare.c | 1 + + src/pcm/pcm_dsnoop.c | 1 + + 3 files changed, 3 insertions(+) + +diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c +index be2675aff0f3..d8495065d5d7 100644 +--- a/src/pcm/pcm_dmix.c ++++ b/src/pcm/pcm_dmix.c +@@ -495,6 +495,7 @@ static int snd_pcm_dmix_status(snd_pcm_t *pcm, snd_pcm_status_t * status) + } + + status->state = snd_pcm_dmix_state(pcm); ++ status->appl_ptr = *pcm->appl.ptr; /* slave PCM doesn't set appl_ptr */ + status->trigger_tstamp = dmix->trigger_tstamp; + status->avail = snd_pcm_mmap_playback_avail(pcm); + status->avail_max = status->avail > dmix->avail_max ? status->avail : dmix->avail_max; +diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c +index 10243013714d..dccb137be253 100644 +--- a/src/pcm/pcm_dshare.c ++++ b/src/pcm/pcm_dshare.c +@@ -243,6 +243,7 @@ static int snd_pcm_dshare_status(snd_pcm_t *pcm, snd_pcm_status_t * status) + break; + } + status->state = snd_pcm_dshare_state(pcm); ++ status->appl_ptr = *pcm->appl.ptr; /* slave PCM doesn't set appl_ptr */ + status->trigger_tstamp = dshare->trigger_tstamp; + status->avail = snd_pcm_mmap_playback_avail(pcm); + status->avail_max = status->avail > dshare->avail_max ? status->avail : dshare->avail_max; +diff --git a/src/pcm/pcm_dsnoop.c b/src/pcm/pcm_dsnoop.c +index c6e8cd279b53..695bf4aa340e 100644 +--- a/src/pcm/pcm_dsnoop.c ++++ b/src/pcm/pcm_dsnoop.c +@@ -193,6 +193,7 @@ static int snd_pcm_dsnoop_status(snd_pcm_t *pcm, snd_pcm_status_t * status) + snd_pcm_status(dsnoop->spcm, status); + state = snd_pcm_state(dsnoop->spcm); + status->state = state == SND_PCM_STATE_RUNNING ? dsnoop->state : state; ++ status->appl_ptr = *pcm->appl.ptr; /* slave PCM doesn't set appl_ptr */ + status->trigger_tstamp = dsnoop->trigger_tstamp; + status->avail = snd_pcm_mmap_capture_avail(pcm); + status->avail_max = status->avail > dsnoop->avail_max ? status->avail : dsnoop->avail_max; +-- +2.26.2 + diff --git a/0046-pcm-ioplug-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_statu.patch b/0046-pcm-ioplug-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_statu.patch new file mode 100644 index 0000000..114555f --- /dev/null +++ b/0046-pcm-ioplug-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_statu.patch @@ -0,0 +1,31 @@ +From 2c57c2c959941de50a4492f151cfd9973c46d41e Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Fri, 22 Jan 2021 15:41:15 +0100 +Subject: [PATCH 46/48] pcm: ioplug: Pass appl_ptr and hw_ptr in + snd_pcm_status() + +The snd_pcm_status() of the ioplug doesn't return the current +positions of hw_ptr and appl_ptr as advertised. Fix it by copying the +current values stored in the plugin data. + +Signed-off-by: Takashi Iwai +--- + src/pcm/pcm_ioplug.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c +index e141b1f98da7..a1463bf6b50a 100644 +--- a/src/pcm/pcm_ioplug.c ++++ b/src/pcm/pcm_ioplug.c +@@ -133,6 +133,8 @@ static int snd_pcm_ioplug_status(snd_pcm_t *pcm, snd_pcm_status_t * status) + gettimestamp(&status->tstamp, pcm->tstamp_type); + status->avail = snd_pcm_mmap_avail(pcm); + status->avail_max = io->avail_max; ++ status->appl_ptr = *pcm->appl.ptr; ++ status->hw_ptr = *pcm->hw.ptr; + if (snd_pcm_ioplug_delay(pcm, &sd) < 0) + sd = snd_pcm_mmap_delay(pcm); + status->delay = sd; +-- +2.26.2 + diff --git a/0047-pcm-null-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch b/0047-pcm-null-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch new file mode 100644 index 0000000..4c97a8f --- /dev/null +++ b/0047-pcm-null-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch @@ -0,0 +1,29 @@ +From 440c42ec5c90e3e345dd72c6c1d604a30b6a8e94 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Fri, 22 Jan 2021 15:42:38 +0100 +Subject: [PATCH 47/48] pcm: null: Pass appl_ptr and hw_ptr in snd_pcm_status() + +Just like the previous fix for ioplug, the null plugin also misses the +appl_ptr and hw_ptr updates for snd_pcm_status(). Fix it as well. + +Signed-off-by: Takashi Iwai +--- + src/pcm/pcm_null.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c +index 1d81548569f0..c8ea9b38785f 100644 +--- a/src/pcm/pcm_null.c ++++ b/src/pcm/pcm_null.c +@@ -96,6 +96,8 @@ static int snd_pcm_null_status(snd_pcm_t *pcm, snd_pcm_status_t * status) + memset(status, 0, sizeof(*status)); + status->state = null->state; + status->trigger_tstamp = null->trigger_tstamp; ++ status->appl_ptr = *pcm->appl.ptr; ++ status->hw_ptr = *pcm->hw.ptr; + gettimestamp(&status->tstamp, pcm->tstamp_type); + status->avail = snd_pcm_null_avail_update(pcm); + status->avail_max = pcm->buffer_size; +-- +2.26.2 + diff --git a/0048-pcm-share-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch b/0048-pcm-share-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch new file mode 100644 index 0000000..10b938e --- /dev/null +++ b/0048-pcm-share-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch @@ -0,0 +1,30 @@ +From 1705e7c0aba0a9e010e55c8e76851fe57e1e3c70 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Fri, 22 Jan 2021 15:43:28 +0100 +Subject: [PATCH 48/48] pcm: share: Pass appl_ptr and hw_ptr in + snd_pcm_status() + +This one also has the same problem as others; the appl_ptr and hw_ptr +of share plugin aren't updated in snd_pcm_status() call. Fix it. + +Signed-off-by: Takashi Iwai +--- + src/pcm/pcm_share.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c +index bff9507d6422..72509491b366 100644 +--- a/src/pcm/pcm_share.c ++++ b/src/pcm/pcm_share.c +@@ -711,6 +711,8 @@ static int snd_pcm_share_status(snd_pcm_t *pcm, snd_pcm_status_t *status) + _notrunning: + status->delay = sd + d; + status->state = share->state; ++ status->appl_ptr = *pcm->appl.ptr; ++ status->hw_ptr = *pcm->hw.ptr; + status->trigger_tstamp = share->trigger_tstamp; + _end: + Pthread_mutex_unlock(&slave->mutex); +-- +2.26.2 + diff --git a/alsa.changes b/alsa.changes index a4c9e7c..8c5aa4a 100644 --- a/alsa.changes +++ b/alsa.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Fri Jan 22 15:50:07 CET 2021 - tiwai@suse.de + +- Yet more fixes for the crash with dmix plugin (bsc#1181194): + 0045-pcm-direct-Fix-the-missing-appl_ptr-update.patch + 0046-pcm-ioplug-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_statu.patch + 0047-pcm-null-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch + 0048-pcm-share-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch + ------------------------------------------------------------------- Thu Jan 21 09:36:12 CET 2021 - tiwai@suse.de diff --git a/alsa.spec b/alsa.spec index 498f3bc..458ecd0 100644 --- a/alsa.spec +++ b/alsa.spec @@ -95,6 +95,10 @@ Patch41: 0041-conf-USB-add-Xonar-U7-MKII-to-USB-Audio.pcm.iec958_d.patch Patch42: 0042-pcm_plugin-set-the-initial-hw_ptr-appl_ptr-from-the-.patch Patch43: 0043-pcm-dmix-dshare-delay-calculation-fixes-and-cleanups.patch Patch44: 0044-topology-fix-parse_tuple_set-remove-dead-condition-c.patch +Patch45: 0045-pcm-direct-Fix-the-missing-appl_ptr-update.patch +Patch46: 0046-pcm-ioplug-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_statu.patch +Patch47: 0047-pcm-null-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch +Patch48: 0048-pcm-share-Pass-appl_ptr-and-hw_ptr-in-snd_pcm_status.patch # rest suse fixes Patch101: alsa-lib-ignore-non-accessible-ALSA_CONFIG_PATH.patch BuildRequires: doxygen @@ -226,6 +230,10 @@ This package contains the library for ALSA topology support. %patch42 -p1 %patch43 -p1 %patch44 -p1 +%patch45 -p1 +%patch46 -p1 +%patch47 -p1 +%patch48 -p1 %patch101 -p1 %build