[pulseaudio-discuss] [PATCH] alsa-util: No logging when sound card only supports non-interleaved sample format

Raymond Yau superquad.vortex2 at gmail.com
Sat Nov 15 18:12:46 PST 2014


>
> as suggested by
> https://bugs.freedesktop.org/show_bug.cgi?id=84804
>
> Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
> ---
>  src/modules/alsa/alsa-util.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
> index 4131cff..e382d4f 100644
> --- a/src/modules/alsa/alsa-util.c
> +++ b/src/modules/alsa/alsa-util.c
> @@ -183,6 +183,19 @@ static int set_buffer_size(snd_pcm_t *pcm_handle,
snd_pcm_hw_params_t *hwparams,
>      return 0;
>  }
>
> +static void check_access(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t
*hwparams, bool use_mmap) {
> +    if ((use_mmap && !snd_pcm_hw_params_test_access(pcm_handle,
hwparams, SND_PCM_ACCESS_MMAP_INTERLEAVED)) ||
> +        !snd_pcm_hw_params_test_access(pcm_handle, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED))
> +        pa_log_error("Weird, PCM claims to support interleaved access,
but snd_pcm_hw_params_set_access() failed.");

HW Params of device "hw:0,0":
--------------------
ACCESS:  MMAP_NONINTERLEAVED RW_NONINTERLEAVED
FORMAT:  S32_LE
SUBFORMAT:  STD
SAMPLE_BITS: 32
FRAME_BITS: [448 832]
CHANNELS: [14 26]
RATE: [32000 96000]
PERIOD_TIME: (666 256000]
PERIOD_SIZE: [64 8192]
PERIOD_BYTES: [3584 851968]
PERIODS: 2
BUFFER_TIME: (1333 512000]
BUFFER_SIZE: [128 16384]
BUFFER_BYTES: [7168 1703936]
TICK_TIME: ALL

if use of test_access is to prevent set_access corrupt the configuration
space of hw_param when access is not supported,

 if (snd_pcm_hw_params_test_access(pcm_handle, hwparams,
SND_PCM_ACCESS_MMAP_INTERLEAVED) == 0) {
     ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams,
SND_PCM_ACCESS_MMAP_INTERLEAVED);
                pa_log_error("snd_pcm_hw_params_set_access() failed: %s",
pa_alsa_strerror(ret));
                goto finish;
  }

else  if (snd_pcm_hw_params_test_access(pcm_handle, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED) == 0) {
      ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED);
                pa_log_error("snd_pcm_hw_params_set_access() failed: %s",
pa_alsa_strerror(ret));
                goto finish;
}
else {
       pa_log_error("Pulseaudio does not support non interleaved access nor
complex access. ");
       goto finish;
}

> +
> +    if ((use_mmap && !snd_pcm_hw_params_test_access(pcm_handle,
hwparams, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) ||
> +        !snd_pcm_hw_params_test_access(pcm_handle, hwparams,
SND_PCM_ACCESS_RW_NONINTERLEAVED))
> +        pa_log_error("PCM seems to support non-interleaved access, but
PA doesn't.");
> +    else if (use_mmap && !snd_pcm_hw_params_test_access(pcm_handle,
hwparams, SND_PCM_ACCESS_MMAP_COMPLEX)) {
> +        pa_log_error("PCM seems to support mmapped complex access, but
PA doesn't.");
> +    }
> +}
> +
>  /* Set the hardware parameters of the given ALSA device. Returns the
>   * selected fragment settings in *buffer_size and *period_size. Determine
>   * whether mmap and tsched mode can be enabled. */
> @@ -229,6 +242,7 @@ int pa_alsa_set_hw_params(
>
>              if ((ret = snd_pcm_hw_params_set_access(pcm_handle,
hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
>                  pa_log_debug("snd_pcm_hw_params_set_access() failed:
%s", pa_alsa_strerror(ret));
> +                check_access(pcm_handle, hwparams, true);
>                  goto finish;
>              }
>
> @@ -237,6 +251,7 @@ int pa_alsa_set_hw_params(
>
>      } else if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
>          pa_log_debug("snd_pcm_hw_params_set_access() failed: %s",
pa_alsa_strerror(ret));
> +        check_access(pcm_handle, hwparams, false);
>          goto finish;
>      }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20141116/4a08d216/attachment.html>


More information about the pulseaudio-discuss mailing list