* Recording doesn't end gracefully
@ 2011-07-05 10:25 Santosh Sivaraj
2011-07-05 11:21 ` Liam Girdwood
0 siblings, 1 reply; 2+ messages in thread
From: Santosh Sivaraj @ 2011-07-05 10:25 UTC (permalink / raw)
To: alsa-devel
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;
cancel_delayed_work(&rtd->delayed_work);
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: Recording doesn't end gracefully
2011-07-05 10:25 Recording doesn't end gracefully Santosh Sivaraj
@ 2011-07-05 11:21 ` Liam Girdwood
0 siblings, 0 replies; 2+ messages in thread
From: Liam Girdwood @ 2011-07-05 11:21 UTC (permalink / raw)
To: Santosh Sivaraj; +Cc: alsa-devel@alsa-project.org
On 05/07/11 11:25, Santosh Sivaraj wrote:
> 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.
>
It's helpful also to state which platform and codec drivers you are using here.
> * 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.
>
Ok, can you trace the android alsa calls ? Do you know what is different ?
> 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);
>
Ok, this check is so that we only mute the DAC when we are shutting down a playback stream. This change would always mute the DAC (even when playback is active and closing a capture stream).
> 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;
> cancel_delayed_work(&rtd->delayed_work);
>
> I am not aware of what consequences/side effects these changes can cause,
> please advice, whether it is a problem elsewhere
>
Again this creates a conflict between any playback and capture streams. i.e. starting a new capture stream will stop an old playback stream from shutting down correctly.
I think the issue here may either be with your component drivers or your Android userspace is doing something different with it's alsa-lib calls.
Regards
Liam
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-05 11:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-05 10:25 Recording doesn't end gracefully Santosh Sivaraj
2011-07-05 11:21 ` Liam Girdwood
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.