mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-17 08:56:49 -05:00
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)
This commit is contained in:
parent
43770c533c
commit
96ed03e1fc
6 changed files with 69 additions and 5 deletions
|
|
@ -505,6 +505,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) {
|
||||
|
||||
|
|
@ -543,6 +545,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) {
|
||||
|
|
@ -570,6 +574,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) {
|
||||
|
|
@ -594,6 +600,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);
|
||||
|
||||
|
|
@ -615,6 +623,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;
|
||||
|
|
@ -644,6 +654,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)
|
||||
|
|
@ -681,6 +693,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;
|
||||
|
|
@ -708,6 +722,12 @@ snd_pcm_t *pa_alsa_open_by_device_string(
|
|||
pa_log_info("ALSA device open '%s' %s: %p", d,
|
||||
mode == SND_PCM_STREAM_CAPTURE ? "capture" : "playback", pcm_handle);
|
||||
|
||||
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,
|
||||
|
|
@ -781,6 +801,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;
|
||||
|
|
@ -802,6 +824,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);
|
||||
|
|
@ -1411,6 +1435,7 @@ char *pa_alsa_get_reserve_name(const char *device) {
|
|||
|
||||
return pa_sprintf_malloc("Audio%i", i);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void dump_supported_rates(unsigned int* values)
|
||||
{
|
||||
|
|
@ -1478,6 +1503,7 @@ unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_
|
|||
rates[1] = 0;
|
||||
}
|
||||
|
||||
dump_supported_rates(rates);
|
||||
return rates;
|
||||
}
|
||||
|
||||
|
|
@ -1558,7 +1584,6 @@ pa_sample_format_t *pa_alsa_get_supported_formats(snd_pcm_t *pcm, pa_sample_form
|
|||
|
||||
return formats;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool pa_alsa_pcm_is_hw(snd_pcm_t *pcm) {
|
||||
snd_pcm_info_t* info;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue