<p></p>
<p>><br>
> as suggested by<br>
> <a href="https://bugs.freedesktop.org/show_bug.cgi?id=84804">https://bugs.freedesktop.org/show_bug.cgi?id=84804</a><br>
><br>
> Signed-off-by: Peter Meerwald <<a href="mailto:pmeerw@pmeerw.net">pmeerw@pmeerw.net</a>><br>
> ---<br>
> src/modules/alsa/alsa-util.c | 15 +++++++++++++++<br>
> 1 file changed, 15 insertions(+)<br>
><br>
> diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c<br>
> index 4131cff..e382d4f 100644<br>
> --- a/src/modules/alsa/alsa-util.c<br>
> +++ b/src/modules/alsa/alsa-util.c<br>
> @@ -183,6 +183,19 @@ static int set_buffer_size(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams,<br>
> return 0;<br>
> }<br>
><br>
> +static void check_access(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, bool use_mmap) {<br>
> + if ((use_mmap && !snd_pcm_hw_params_test_access(pcm_handle, hwparams, SND_PCM_ACCESS_MMAP_INTERLEAVED)) ||<br>
> + !snd_pcm_hw_params_test_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED))<br>
> + pa_log_error("Weird, PCM claims to support interleaved access, but snd_pcm_hw_params_set_access() failed.");<br></p>
<p>HW Params of device "hw:0,0":<br>
--------------------<br>
ACCESS: MMAP_NONINTERLEAVED RW_NONINTERLEAVED<br>
FORMAT: S32_LE<br>
SUBFORMAT: STD<br>
SAMPLE_BITS: 32<br>
FRAME_BITS: [448 832]<br>
CHANNELS: [14 26]<br>
RATE: [32000 96000]<br>
PERIOD_TIME: (666 256000]<br>
PERIOD_SIZE: [64 8192]<br>
PERIOD_BYTES: [3584 851968]<br>
PERIODS: 2<br>
BUFFER_TIME: (1333 512000]<br>
BUFFER_SIZE: [128 16384]<br>
BUFFER_BYTES: [7168 1703936]<br>
TICK_TIME: ALL<br></p>
<p>if use of test_access is to prevent set_access corrupt the configuration space of hw_param when access is not supported,<br><br></p>
<p> if (snd_pcm_hw_params_test_access(pcm_handle, hwparams, SND_PCM_ACCESS_MMAP_INTERLEAVED) == 0) {<br>
ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_MMAP_INTERLEAVED);<br>
pa_log_error("snd_pcm_hw_params_set_access() failed: %s", pa_alsa_strerror(ret));<br>
goto finish;<br>
}<br>
<br>
else if (snd_pcm_hw_params_test_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED) == 0) {<br>
ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);<br>
pa_log_error("snd_pcm_hw_params_set_access() failed: %s", pa_alsa_strerror(ret));<br>
goto finish;<br>
}<br>
else {<br>
pa_log_error("Pulseaudio does not support non interleaved access nor complex access. ");<br>
goto finish;<br>
}</p>
<p>> +<br>
> + if ((use_mmap && !snd_pcm_hw_params_test_access(pcm_handle, hwparams, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) ||<br>
> + !snd_pcm_hw_params_test_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_NONINTERLEAVED))<br>
> + pa_log_error("PCM seems to support non-interleaved access, but PA doesn't.");<br>
> + else if (use_mmap && !snd_pcm_hw_params_test_access(pcm_handle, hwparams, SND_PCM_ACCESS_MMAP_COMPLEX)) {<br>
> + pa_log_error("PCM seems to support mmapped complex access, but PA doesn't.");<br>
> + }<br>
> +}<br>
> +<br>
> /* Set the hardware parameters of the given ALSA device. Returns the<br>
> * selected fragment settings in *buffer_size and *period_size. Determine<br>
> * whether mmap and tsched mode can be enabled. */<br>
> @@ -229,6 +242,7 @@ int pa_alsa_set_hw_params(<br>
><br>
> if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {<br>
> pa_log_debug("snd_pcm_hw_params_set_access() failed: %s", pa_alsa_strerror(ret));<br>
> + check_access(pcm_handle, hwparams, true);<br>
> goto finish;<br>
> }<br>
><br>
> @@ -237,6 +251,7 @@ int pa_alsa_set_hw_params(<br>
><br>
> } else if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {<br>
> pa_log_debug("snd_pcm_hw_params_set_access() failed: %s", pa_alsa_strerror(ret));<br>
> + check_access(pcm_handle, hwparams, false);<br>
> goto finish;<br>
> }<br>
><br>
</p>