Skip to content

Commit 3e48940

Browse files
Pattara Teerapongtiwai
authored andcommitted
ALSA: aloop: Fix random zeros in capture data when using jiffies timer
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 <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent ff878b4 commit 3e48940

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sound/drivers/aloop.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,17 +605,18 @@ static unsigned int loopback_jiffies_timer_pos_update
605605
cable->streams[SNDRV_PCM_STREAM_PLAYBACK];
606606
struct loopback_pcm *dpcm_capt =
607607
cable->streams[SNDRV_PCM_STREAM_CAPTURE];
608-
unsigned long delta_play = 0, delta_capt = 0;
608+
unsigned long delta_play = 0, delta_capt = 0, cur_jiffies;
609609
unsigned int running, count1, count2;
610610

611+
cur_jiffies = jiffies;
611612
running = cable->running ^ cable->pause;
612613
if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) {
613-
delta_play = jiffies - dpcm_play->last_jiffies;
614+
delta_play = cur_jiffies - dpcm_play->last_jiffies;
614615
dpcm_play->last_jiffies += delta_play;
615616
}
616617

617618
if (running & (1 << SNDRV_PCM_STREAM_CAPTURE)) {
618-
delta_capt = jiffies - dpcm_capt->last_jiffies;
619+
delta_capt = cur_jiffies - dpcm_capt->last_jiffies;
619620
dpcm_capt->last_jiffies += delta_capt;
620621
}
621622

0 commit comments

Comments
 (0)