summaryrefslogtreecommitdiff
path: root/sound/drivers
diff options
context:
space:
mode:
authorPattara Teerapong <pteerapong@chromium.org>2022-09-01 17:40:36 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-09-15 12:32:03 +0300
commitab730d3c44918f5cb9b2abc1e463cd0b80bfaa94 (patch)
tree41aebad74f2e0b665cb3d2bf592ad985dd63f10f /sound/drivers
parent39a90720f3abe96625d1224e7a7463410875de4c (diff)
downloadlinux-ab730d3c44918f5cb9b2abc1e463cd0b80bfaa94.tar.xz
ALSA: aloop: Fix random zeros in capture data when using jiffies timer
commit 3e48940abee88b8dbbeeaf8a07e7b2b6be1271b3 upstream. In loopback_jiffies_timer_pos_update(), we are getting jiffies twice. First time for playback, second time for capture. Jiffies can be updated between these two calls and if the capture jiffies is larger, extra zeros will be filled in the capture buffer. Change to get jiffies once and use it for both playback and capture. Signed-off-by: Pattara Teerapong <pteerapong@chromium.org> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20220901144036.4049060-1-pteerapong@chromium.org Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound/drivers')
-rw-r--r--sound/drivers/aloop.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 2c5f7e905ab8..fb45a32d99cd 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -606,17 +606,18 @@ static unsigned int loopback_jiffies_timer_pos_update
cable->streams[SNDRV_PCM_STREAM_PLAYBACK];
struct loopback_pcm *dpcm_capt =
cable->streams[SNDRV_PCM_STREAM_CAPTURE];
- unsigned long delta_play = 0, delta_capt = 0;
+ unsigned long delta_play = 0, delta_capt = 0, cur_jiffies;
unsigned int running, count1, count2;
+ cur_jiffies = jiffies;
running = cable->running ^ cable->pause;
if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) {
- delta_play = 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 = jiffies - dpcm_capt->last_jiffies;
+ delta_capt = cur_jiffies - dpcm_capt->last_jiffies;
dpcm_capt->last_jiffies += delta_capt;
}