Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: soc-pcm: always cancel any pending delayed stream shutdown
@ 2014-10-22 14:14 Hector Palacios
  2014-10-22 16:28 ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Hector Palacios @ 2014-10-22 14:14 UTC (permalink / raw)
  To: alsa-devel; +Cc: hector.palacios, broonie

After playback a shutdown is scheduled to happen within 5 seconds.
If another playback takes place before the scheduled work times out,
the work is cancelled, but if a recording takes place, the work will
shutdown in the middle of the recording, causing problems.

To reproduce the issue chain the following commands:
	arecord -M --duration 5 -c 2 /tmp/test.wav;
	aplay /tmp/test.wav;
	sleep 2;
	arecord -M --duration 5 -c 2 /tmp/test.wav;
	aplay /tmp/test.wav;

The fist command records 5 seconds of audio.
The second command plays the recorded audio. At the end of the playback
a work will be scheduled to shutdown in 5 seconds, but only 2 seconds after
the first playback, we run another recording.
When we have recorded 3 seconds, the shutdown will occur which can cause
incorrect behavior and bad recorded data. As a consequence, the last
playback reproduces correct audio for the first 3 seconds and incorrect audio
after that.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
 sound/soc/soc-pcm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 642c86240752..d19a926872e8 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -760,8 +760,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 	}
 
 	/* cancel any delayed stream shutdown that is pending */
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
-	    rtd->pop_wait) {
+	if (rtd->pop_wait) {
 		rtd->pop_wait = 0;
 		cancel_delayed_work(&rtd->delayed_work);
 	}

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

end of thread, other threads:[~2014-10-28 17:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-22 14:14 [PATCH] ASoC: soc-pcm: always cancel any pending delayed stream shutdown Hector Palacios
2014-10-22 16:28 ` Mark Brown
2014-10-22 17:25   ` Palacios, Hector
2014-10-28 15:14     ` Mark Brown
2014-10-28 15:23     ` Fabio Estevam
2014-10-28 17:42       ` Palacios, Hector

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox