From 6a6a70ffe715c9c61a2a2421538589de80c41df8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 29 Mar 2005 14:10:16 +0000 Subject: [PATCH] Do hwsync of slave PCM on dmix Call hwsync of slave PCM on snd_pcm_hwsync() over dmix. This reduces ocasional output noises, typically seen in xmms and bmp with multi-threading on SMP/HT systems. Disabled slowptr of default dmix definition again. --- src/conf/pcm/dmix.conf | 1 - src/pcm/pcm_dmix.c | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/conf/pcm/dmix.conf b/src/conf/pcm/dmix.conf index 5546ff39..addcaf7c 100644 --- a/src/conf/pcm/dmix.conf +++ b/src/conf/pcm/dmix.conf @@ -27,7 +27,6 @@ pcm.!dmix { type dmix ipc_key 5678293 ipc_key_add_uid yes - slowptr yes slave { pcm { type hw diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index efdfeaa4..06e82159 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -243,7 +243,7 @@ static void snd_pcm_dmix_sync_area(snd_pcm_t *pcm, snd_pcm_uframes_t size) /* * synchronize hardware pointer (hw_ptr) with ours */ -static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm) +static int _snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm, int do_slave_sync) { snd_pcm_direct_t *dmix = pcm->private_data; snd_pcm_uframes_t slave_hw_ptr, old_slave_hw_ptr, avail; @@ -256,7 +256,7 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm) default: break; } - if (dmix->slowptr) + if (do_slave_sync) snd_pcm_hwsync(dmix->spcm); old_slave_hw_ptr = dmix->slave_hw_ptr; slave_hw_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr; @@ -285,6 +285,12 @@ 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; + return _snd_pcm_dmix_sync_ptr(pcm, dmix->slowptr); +} + /* * plugin implementation */ @@ -369,7 +375,8 @@ static int snd_pcm_dmix_hwsync(snd_pcm_t *pcm) switch(dmix->state) { case SNDRV_PCM_STATE_DRAINING: case SNDRV_PCM_STATE_RUNNING: - return snd_pcm_dmix_sync_ptr(pcm); + /* sync slave PCM */ + return _snd_pcm_dmix_sync_ptr(pcm, 1); case SNDRV_PCM_STATE_PREPARED: case SNDRV_PCM_STATE_SUSPENDED: case STATE_RUN_PENDING: -- 2.47.1