linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: pcm: fix incorrect hw_base increase
@ 2020-05-15  4:09 Brent Lu
  2020-05-15  7:04 ` Greg Kroah-Hartman
  2020-05-15  7:21 ` Takashi Iwai
  0 siblings, 2 replies; 10+ messages in thread
From: Brent Lu @ 2020-05-15  4:09 UTC (permalink / raw)
  To: alsa-devel
  Cc: Jaroslav Kysela, Takashi Iwai, Baolin Wang, Arnd Bergmann,
	Greg Kroah-Hartman, Richard Fontana, Thomas Gleixner, Brent Lu,
	paulhsia, linux-kernel

The hw_base will be increased by runtime->buffer_size frames
unconditionally if the runtime->status->hw_ptr is not updated for over
half of buffer time. As the hw_base increases, so does the
runtime->status->hw_ptr which could lead to invalid return value when
user space program calls snd_pcm_avail() function.

By updating runtime->hw_ptr_jiffies each time the HWSYNC is called,
the hw_base will keep the same when buffer stall happens, so does the
hw_ptr.

Signed-off-by: Brent Lu <brent.lu@intel.com>
---
 sound/core/pcm_lib.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 872a852..d531e1b 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -433,6 +433,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
 
  no_delta_check:
 	if (runtime->status->hw_ptr == new_hw_ptr) {
+		runtime->hw_ptr_jiffies = curr_jiffies;
 		update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp);
 		return 0;
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-18  4:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15  4:09 [PATCH] ALSA: pcm: fix incorrect hw_base increase Brent Lu
2020-05-15  7:04 ` Greg Kroah-Hartman
2020-05-15  9:04   ` Lu, Brent
2020-05-15  9:30     ` Jaroslav Kysela
2020-05-15 10:39       ` Takashi Iwai
2020-05-15 12:01         ` Jaroslav Kysela
2020-05-18  4:38           ` Lu, Brent
2020-05-15  7:21 ` Takashi Iwai
2020-05-15  9:36   ` Lu, Brent
2020-05-15 10:40     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).