mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-11 13:30:05 -05:00
pcm: direct: Check xrun/suspend before the slave hwptr update
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> Acked-by: Shengjiu Wang <shengjiu.wang@nxp.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
3577a7a26b
commit
bb9f258e19
3 changed files with 13 additions and 9 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue