[alsa-devel] Recording doesn't end gracefully

Santosh Sivaraj santoshs at fossix.org
Tue Jul 5 12:25:21 CEST 2011

Hi all,

We were working on 1.0.23 version of the ALSA driver. In the following
scenario we are getting some issues with recording.

* Play some music in the sound player in the background
* Open recorder and start recording
* Since playback and recording can't happen simultaneously, we explicitly
  reset the codec device and configure it for recording.
* In this case, after some time the codec driver is powered off by the
  soc-core and only silence is recorded.

All this were done from the Android UI. When the same is repeated from the
command line with aplay and arecord we see that aplay is stopped and
recording works fine.

When we debugged the problem, we found that the following diff seems to get rid
of the above problem:

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c984996..247f4ee 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -773,7 +773,8 @@ int snd_soc_pcm_close(struct snd_pcm_substream *substream)
        /* Muting the DAC suppresses artifacts caused during digital
         * shutdown, for example from stopping clocks.
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+       if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ||
+           (substream->stream == SNDRV_PCM_STREAM_CAPTURE))
                snd_soc_dai_digital_mute(codec_dai, 1);
        if (cpu_dai->driver->ops->shutdown)
@@ -869,7 +870,8 @@ int snd_soc_pcm_prepare(struct snd_pcm_substream *substream)
        /* cancel any delayed stream shutdown that is pending */
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+       if (((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ||
+            (substream->stream == SNDRV_PCM_STREAM_CAPTURE))  &&
            codec_dai->pop_wait) {
                codec_dai->pop_wait = 0;

I am not aware of what consequences/side effects these changes can cause,
please advice, whether it is a problem elsewhere

http://fossix.org, http://dot.slashb.in
Things do not change; we change 
					-- Henry David

More information about the Alsa-devel mailing list