@@ -424,15 +424,17 @@ static int snd_pcm_dmix_sync_ptr0(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_ptr
static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
{
snd_pcm_direct_t *dmix = pcm->private_data;
+ snd_pcm_uframes_t slave_hw_ptr;
int err;
+ if (dmix->slowptr)
+ snd_pcm_hwsync(dmix->spcm);
+ slave_hw_ptr = *dmix->spcm->hw.ptr;
err = snd_pcm_direct_check_xrun(dmix, pcm);
if (err < 0)
return err;
- if (dmix->slowptr)
- snd_pcm_hwsync(dmix->spcm);
- return snd_pcm_dmix_sync_ptr0(pcm, *dmix->spcm->hw.ptr);
+ return snd_pcm_dmix_sync_ptr0(pcm, slave_hw_ptr);
}
/*
@@ -199,15 +199,17 @@ static int snd_pcm_dshare_sync_ptr0(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_p
static int snd_pcm_dshare_sync_ptr(snd_pcm_t *pcm)
{
snd_pcm_direct_t *dshare = pcm->private_data;
+ snd_pcm_uframes_t slave_hw_ptr;
int err;
+ if (dshare->slowptr)
+ snd_pcm_hwsync(dshare->spcm);
+ slave_hw_ptr = *dshare->spcm->hw.ptr;
err = snd_pcm_direct_check_xrun(dshare, pcm);
if (err < 0)
return err;
- if (dshare->slowptr)
- snd_pcm_hwsync(dshare->spcm);
- return snd_pcm_dshare_sync_ptr0(pcm, *dshare->spcm->hw.ptr);
+ return snd_pcm_dshare_sync_ptr0(pcm, slave_hw_ptr);
}
/*
@@ -134,14 +134,14 @@ static int snd_pcm_dsnoop_sync_ptr(snd_pcm_t *pcm)
snd_pcm_sframes_t diff;
int err;
- err = snd_pcm_direct_check_xrun(dsnoop, pcm);
- if (err < 0)
- return err;
if (dsnoop->slowptr)
snd_pcm_hwsync(dsnoop->spcm);
old_slave_hw_ptr = dsnoop->slave_hw_ptr;
snoop_timestamp(pcm);
slave_hw_ptr = dsnoop->slave_hw_ptr;
+ err = snd_pcm_direct_check_xrun(dsnoop, pcm);
+ if (err < 0)
+ return err;
diff = pcm_frame_diff(slave_hw_ptr, old_slave_hw_ptr, dsnoop->slave_boundary);
if (diff == 0) /* fast path */
return 0;
The xrun/suspend may happen at any time and we should check it right after the slave hwptr update (but before the actual sync_ptr update in direct pcm side). Otherwise the hwptr value may be screwed and get unexpected large read/write. Reported-by: S.J. Wang <shengjiu.wang@nxp.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> --- src/pcm/pcm_dmix.c | 8 +++++--- src/pcm/pcm_dshare.c | 8 +++++--- src/pcm/pcm_dsnoop.c | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-)