alsa/0019-pcm-dmix-Do-not-discard-slave-reported-delay-in-stat.patch
Ismail Dönmez 6117f9abfc Accepting request 442719 from home:tiwai:branches:multimedia:libs
- Backport upstream fixes (bsc#1012594):
  - A few PCM bugs have been fixed:
    * Stall of dmix and others in a wrong PCM state
    * Refactoring of PCM locking scheme
    * SHM initialization race fix
    * plug PCM memory leaks
    * Improvement of dshare/dmix delay calculation
    * Fix endless dshare draining
    * Fix semaphore discard race fix of direct plugins
  - UCM fixes and updates for DB410c and skylake-r5286
  - Mixer code cleanup not to install bogus plugin codes
  - Documentation fixes / updates
  0001-ucm-Add-ucm-files-for-DB410c-board.patch
  0002-mixer-Fix-rounding-mode-documentation.patch
  0003-pcm-Fix-shm-initialization-race-condition.patch
  0004-pcm-Better-understandable-locking-code.patch
  0005-ucm-fix-crash-when-calling-snd_use_case_geti-with-no.patch
  0006-ucm-docs-typeset-lists-of-identifiers-explicitly.patch
  0007-Update-include-sound-tlv.h-from-4.9-pre-kernel-uapi.patch
  0008-test-use-actual-information-for-TLV-operation.patch
  0009-ctl-improve-API-documentation-for-TLV-operation.patch
  0010-ctl-improve-documentation-about-TLV-related-APIs.patch
  0011-ctl-correct-documentation-about-TLV-feature.patch
  0012-conf-ucm-skylake-add-skylake-rt286-conf-files.patch
  0013-pcm_plug-Clear-plugins-on-all-error-conditions.patch
  0014-mixer-Don-t-install-smixer-modules-unless-python-is-.patch
  0015-pcm_dshare-Do-not-discard-slave-reported-delay-in-st.patch
  0016-pcm-direct-Protect-from-freeing-semaphore-when-alrea.patch
  0017-pcm-dshare-Fix-endless-playback-of-buffer.patch
  0018-pcm-Add-the-PCM-state-checks-to-plugins.patch

OBS-URL: https://build.opensuse.org/request/show/442719
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=202
2016-11-29 18:09:28 +00:00

104 lines
2.9 KiB
Diff

From 38a2d2eda880fda9ed5a4a219db498d9c0856d71 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Tue, 29 Nov 2016 14:53:53 +0100
Subject: [PATCH] pcm: dmix: Do not discard slave reported delay in status
result
Like the change done for dshare plugin, we can calculate the delay
more precisely from the slave PCM.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/pcm/pcm_dmix.c | 45 ++++++++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c
index 2fedb1c14a3b..825677ffeb3f 100644
--- a/src/pcm/pcm_dmix.c
+++ b/src/pcm/pcm_dmix.c
@@ -391,23 +391,14 @@ static void snd_pcm_dmix_sync_area(snd_pcm_t *pcm)
/*
* synchronize hardware pointer (hw_ptr) with ours
*/
-static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
+static int snd_pcm_dmix_sync_ptr0(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_ptr)
{
snd_pcm_direct_t *dmix = pcm->private_data;
- snd_pcm_uframes_t slave_hw_ptr, old_slave_hw_ptr, avail;
+ snd_pcm_uframes_t old_slave_hw_ptr, avail;
snd_pcm_sframes_t diff;
- switch (snd_pcm_state(dmix->spcm)) {
- case SND_PCM_STATE_DISCONNECTED:
- dmix->state = SND_PCM_STATE_DISCONNECTED;
- return -ENODEV;
- default:
- break;
- }
- if (dmix->slowptr)
- snd_pcm_hwsync(dmix->spcm);
old_slave_hw_ptr = dmix->slave_hw_ptr;
- slave_hw_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr;
+ dmix->slave_hw_ptr = *dmix->spcm->hw.ptr;
diff = slave_hw_ptr - old_slave_hw_ptr;
if (diff == 0) /* fast path */
return 0;
@@ -440,6 +431,24 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
return 0;
}
+static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
+{
+ snd_pcm_direct_t *dmix = pcm->private_data;
+
+ switch (snd_pcm_state(dmix->spcm)) {
+ case SND_PCM_STATE_DISCONNECTED:
+ dmix->state = SND_PCM_STATE_DISCONNECTED;
+ return -ENODEV;
+ default:
+ break;
+ }
+
+ if (dmix->slowptr)
+ snd_pcm_hwsync(dmix->spcm);
+
+ return snd_pcm_dmix_sync_ptr0(pcm, *dmix->spcm->hw.ptr);
+}
+
/*
* plugin implementation
*/
@@ -467,22 +476,24 @@ static int snd_pcm_dmix_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
{
snd_pcm_direct_t *dmix = pcm->private_data;
+ memset(status, 0, sizeof(*status));
+ snd_pcm_status(dmix->spcm, status);
+
switch (dmix->state) {
case SNDRV_PCM_STATE_DRAINING:
case SNDRV_PCM_STATE_RUNNING:
- snd_pcm_dmix_sync_ptr(pcm);
+ snd_pcm_dmix_sync_ptr0(pcm, status->hw_ptr);
+ status->delay += snd_pcm_mmap_playback_delay(pcm)
+ + status->avail - dmix->spcm->buffer_size;
break;
default:
break;
}
- memset(status, 0, sizeof(*status));
- snd_pcm_status(dmix->spcm, status);
- status->state = snd_pcm_dmix_state(pcm);
+
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;
dmix->avail_max = 0;
- status->delay = snd_pcm_mmap_playback_delay(pcm);
return 0;
}
--
2.10.2