* [PATCH] ALSA: aloop: Fix random zeros in capture data when using jiffies timer
@ 2022-09-01 14:40 ` Pattara Teerapong
0 siblings, 0 replies; 4+ messages in thread
From: Pattara Teerapong @ 2022-09-01 14:40 UTC (permalink / raw)
To: alsa-devel; +Cc: linux-kernel, Takashi Iwai, Pattara Teerapong
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>
---
sound/drivers/aloop.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 9b4a7cdb103a..12f12a294df5 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -605,17 +605,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;
}
--
2.37.2.789.g6183377224-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] ALSA: aloop: Fix random zeros in capture data when using jiffies timer
@ 2022-09-01 14:40 ` Pattara Teerapong
0 siblings, 0 replies; 4+ messages in thread
From: Pattara Teerapong @ 2022-09-01 14:40 UTC (permalink / raw)
To: alsa-devel; +Cc: Pattara Teerapong, Jaroslav Kysela, Takashi Iwai, linux-kernel
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>
---
sound/drivers/aloop.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 9b4a7cdb103a..12f12a294df5 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -605,17 +605,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;
}
--
2.37.2.789.g6183377224-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] ALSA: aloop: Fix random zeros in capture data when using jiffies timer
2022-09-01 14:40 ` Pattara Teerapong
@ 2022-09-02 6:58 ` Takashi Iwai
-1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2022-09-02 6:58 UTC (permalink / raw)
To: Pattara Teerapong; +Cc: linux-kernel, alsa-devel, Takashi Iwai
On Thu, 01 Sep 2022 16:40:36 +0200,
Pattara Teerapong wrote:
>
> 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>
Thanks, applied.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ALSA: aloop: Fix random zeros in capture data when using jiffies timer
@ 2022-09-02 6:58 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2022-09-02 6:58 UTC (permalink / raw)
To: Pattara Teerapong; +Cc: alsa-devel, Jaroslav Kysela, Takashi Iwai, linux-kernel
On Thu, 01 Sep 2022 16:40:36 +0200,
Pattara Teerapong wrote:
>
> 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>
Thanks, applied.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-02 6:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-01 14:40 [PATCH] ALSA: aloop: Fix random zeros in capture data when using jiffies timer Pattara Teerapong
2022-09-01 14:40 ` Pattara Teerapong
2022-09-02 6:58 ` Takashi Iwai
2022-09-02 6:58 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.