summaryrefslogtreecommitdiff
path: root/src/modules/alsa/alsa-util.c
diff options
context:
space:
mode:
authorIgor V. Kovalenko <igor.v.kovalenko@gmail.com>2023-02-22 01:19:24 +0300
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>2023-02-25 12:00:38 +0000
commitaed52c507f345d0b5c4cd2b1d2c58dae2d904b53 (patch)
tree7f7fc3891f6cb6e11837a74ee94e587959fda15c /src/modules/alsa/alsa-util.c
parentb8e2198d34da2e085b469d7e3a472cbdaec9e5b8 (diff)
downloadpulseaudio-aed52c507f345d0b5c4cd2b1d2c58dae2d904b53.tar.gz
alsa-util: Perform format and rate detection before setting HW params
Perform detection of supported sample format and rates just after device is opened, before `snd_pcm_hw_params()` is called for the first time. This fixes a problem where device restricts available sample rates after HW params are set preventing sample rate detection (seen with UAC2 devices and kernel 6.1.9) Bug: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1414 Bug: https://github.com/alsa-project/alsa-lib/issues/119 Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/782>
Diffstat (limited to 'src/modules/alsa/alsa-util.c')
-rw-r--r--src/modules/alsa/alsa-util.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index fd30f18bd..b631c870c 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -523,6 +523,8 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto(
snd_pcm_uframes_t tsched_size,
bool *use_mmap,
bool *use_tsched,
+ pa_sample_format_t **query_supported_formats,
+ unsigned int **query_supported_rates,
pa_alsa_profile_set *ps,
pa_alsa_mapping **mapping) {
@@ -561,6 +563,8 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto(
tsched_size,
use_mmap,
use_tsched,
+ query_supported_formats,
+ query_supported_rates,
m);
if (pcm_handle) {
@@ -588,6 +592,8 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto(
tsched_size,
use_mmap,
use_tsched,
+ query_supported_formats,
+ query_supported_rates,
m);
if (pcm_handle) {
@@ -612,6 +618,8 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto(
tsched_size,
use_mmap,
use_tsched,
+ query_supported_formats,
+ query_supported_rates,
false);
pa_xfree(d);
@@ -632,6 +640,8 @@ snd_pcm_t *pa_alsa_open_by_device_id_mapping(
snd_pcm_uframes_t tsched_size,
bool *use_mmap,
bool *use_tsched,
+ pa_sample_format_t **query_supported_formats,
+ unsigned int **query_supported_rates,
pa_alsa_mapping *m) {
snd_pcm_t *pcm_handle;
@@ -661,6 +671,8 @@ snd_pcm_t *pa_alsa_open_by_device_id_mapping(
tsched_size,
use_mmap,
use_tsched,
+ query_supported_formats,
+ query_supported_rates,
pa_channel_map_valid(&m->channel_map) /* Query the channel count if we don't know what we want */);
if (!pcm_handle)
@@ -684,6 +696,8 @@ snd_pcm_t *pa_alsa_open_by_device_string(
snd_pcm_uframes_t tsched_size,
bool *use_mmap,
bool *use_tsched,
+ pa_sample_format_t **query_supported_formats,
+ unsigned int **query_supported_rates,
bool require_exact_channel_number) {
int err;
@@ -711,6 +725,12 @@ snd_pcm_t *pa_alsa_open_by_device_string(
pa_log_debug("Managed to open %s", d);
+ if (query_supported_formats)
+ *query_supported_formats = pa_alsa_get_supported_formats(pcm_handle, ss->format);
+
+ if (query_supported_rates)
+ *query_supported_rates = pa_alsa_get_supported_rates(pcm_handle, ss->rate);
+
if ((err = pa_alsa_set_hw_params(
pcm_handle,
ss,
@@ -784,6 +804,8 @@ snd_pcm_t *pa_alsa_open_by_template(
snd_pcm_uframes_t tsched_size,
bool *use_mmap,
bool *use_tsched,
+ pa_sample_format_t **query_supported_formats,
+ unsigned int **query_supported_rates,
bool require_exact_channel_number) {
snd_pcm_t *pcm_handle;
@@ -805,6 +827,8 @@ snd_pcm_t *pa_alsa_open_by_template(
tsched_size,
use_mmap,
use_tsched,
+ query_supported_formats,
+ query_supported_rates,
require_exact_channel_number);
pa_xfree(d);