ALSA: aloop: fix clear capture buf at wrong time

We need to use uniform current jiffies to avoid
the delta_capt too fast and the playback data is
cleared.

Change-Id: I15e46a3857d76ca37b01a4af4c4d331ec41febfc
Signed-off-by: Xing Zheng <zhengxing@rock-chips.com>
This commit is contained in:
Xing Zheng
2018-11-06 10:27:40 +08:00
committed by Sugar Zhang
parent 1a4d7e6781
commit 0dc150b7ef

View File

@@ -498,15 +498,16 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable)
cable->streams[SNDRV_PCM_STREAM_CAPTURE];
unsigned long delta_play = 0, delta_capt = 0;
unsigned int running, count1, count2;
unsigned long cur_jiffies = cycles_to_jiffies();
running = cable->running ^ cable->pause;
if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) {
delta_play = cycles_to_jiffies() - dpcm_play->last_jiffies;
delta_play = cur_jiffies - dpcm_play->last_jiffies;
dpcm_play->last_jiffies += delta_play;
}
if (running & (1 << SNDRV_PCM_STREAM_CAPTURE)) {
delta_capt = cycles_to_jiffies() - dpcm_capt->last_jiffies;
delta_capt = cur_jiffies - dpcm_capt->last_jiffies;
dpcm_capt->last_jiffies += delta_capt;
}