alsa: remove double calls of snd_pcm_prepare()

In alsa-lib, snd_pcm_hw_params() internally calls snd_pcm_prepare(), thus
user space applications have no need to call snd_pcm_prepare() after calls
of snd_pcm_hw_params(). An explicit calls of snd_pcm_prepare() is expected
in a case to recover PCM substreams.

Current implementation of PulseAudio modules for ALSA playbacking/capturing
results in double calls of snd_pcm_prepare(). The second call for hw plugin
of alsa-lib executes ioctl(2) with SNDRV_PCM_IOCTL_PREPARE command in state
of SNDRV_PCM_STATE_PREPARED for the PCM substream. This has no effects to
the PCM substream as long as corresponding drivers are implemented
correctly.

This commit removes the second call for the reason.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
This commit is contained in:
Takashi Sakamoto 2016-12-30 12:05:20 +09:00 committed by Tanu Kaskinen
parent fb6b8dfdec
commit 5287f09f06
2 changed files with 0 additions and 8 deletions

View file

@ -410,11 +410,6 @@ success:
if (ss->format != _ss.format)
pa_log_info("Device %s doesn't support sample format %s, changed to %s.", snd_pcm_name(pcm_handle), pa_sample_format_to_string(ss->format), pa_sample_format_to_string(_ss.format));
if ((ret = snd_pcm_prepare(pcm_handle)) < 0) {
pa_log_info("snd_pcm_prepare() failed: %s", pa_alsa_strerror(ret));
goto finish;
}
if ((ret = snd_pcm_hw_params_current(pcm_handle, hwparams)) < 0) {
pa_log_info("snd_pcm_hw_params_current() failed: %s", pa_alsa_strerror(ret));
goto finish;

View file

@ -132,9 +132,6 @@ int main(int argc, char *argv[]) {
r = snd_pcm_sw_params(pcm, swparams);
assert(r == 0);
r = snd_pcm_prepare(pcm);
assert(r == 0);
r = snd_pcm_sw_params_current(pcm, swparams);
assert(r == 0);