Răsfoiți Sursa

[ALSA] pcm core: fix silence_start calculations

The case where silence_size < boundary was broken because different
parts of the snd_pcm_playback_silence() function disagreed about whether
silence_start should point to the start or to the end of the buffer part
to be silenced.
This patch changes the code to always use to the start, which also
simplifies several calculations.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Clemens Ladisch 19 ani în urmă
părinte
comite
9a826ddba6
1 a modificat fișierele cu 3 adăugiri și 5 ștergeri
  1. 3 5
      sound/core/pcm_lib.c

+ 3 - 5
sound/core/pcm_lib.c

@@ -79,19 +79,17 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram
 			runtime->silence_filled -= frames;
 			runtime->silence_filled -= frames;
 			if ((snd_pcm_sframes_t)runtime->silence_filled < 0) {
 			if ((snd_pcm_sframes_t)runtime->silence_filled < 0) {
 				runtime->silence_filled = 0;
 				runtime->silence_filled = 0;
-				runtime->silence_start = (ofs + frames) - runtime->buffer_size;
+				runtime->silence_start = new_hw_ptr;
 			} else {
 			} else {
-				runtime->silence_start = ofs - runtime->silence_filled;
+				runtime->silence_start = ofs;
 			}
 			}
-			if ((snd_pcm_sframes_t)runtime->silence_start < 0)
-				runtime->silence_start += runtime->boundary;
 		}
 		}
 		frames = runtime->buffer_size - runtime->silence_filled;
 		frames = runtime->buffer_size - runtime->silence_filled;
 	}
 	}
 	snd_assert(frames <= runtime->buffer_size, return);
 	snd_assert(frames <= runtime->buffer_size, return);
 	if (frames == 0)
 	if (frames == 0)
 		return;
 		return;
-	ofs = (runtime->silence_start + runtime->silence_filled) % runtime->buffer_size;
+	ofs = runtime->silence_start % runtime->buffer_size;
 	while (frames > 0) {
 	while (frames > 0) {
 		transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames;
 		transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames;
 		if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED ||
 		if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED ||