mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-17 08:56:49 -05:00
Revert "alsa: UCM conflicting devices changes"
If needs some more work This reverts commitaae770f18b. This reverts commit2216956e05. This reverts commit1d3c4501ef. This reverts commitc7ca024607. This reverts commit8e4a5f5d5e. This reverts commit8b20675ad1. This reverts commitebe6f8b51a. This reverts commit4b97da1277. This reverts commit7c46a656c7. This reverts commit96ed03e1fc. This reverts commit43770c533c. This reverts commitccb2fce054. This reverts commit93d0ddc8b3. This reverts commit815e8c8fa0. This reverts commit97b99a0f7c. This reverts commit7e4d87402b. This reverts commit168b3ee22c. This reverts commit5128cdba31. This reverts commit31cde774c5. This reverts commitb02c8ba153. This reverts commit68ac72d098. This reverts commit96cfc9bc1a. This reverts commite2d642a20b. This reverts commit80fc80c343. This reverts commit3a68905c7c. This reverts commit7e64680a65. This reverts commit8d1e38a281. This reverts commit591188195c. This reverts commit973fe0cb79. This reverts commit4d08c9ad60. This reverts commit3dce92e580. This reverts commit6b5e232c5c. This reverts commitb1286c62c9.
This commit is contained in:
parent
5fc782b893
commit
a66d5b90f9
9 changed files with 635 additions and 930 deletions
|
|
@ -505,8 +505,6 @@ 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) {
|
||||
|
||||
|
|
@ -545,8 +543,6 @@ 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) {
|
||||
|
|
@ -574,8 +570,6 @@ 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) {
|
||||
|
|
@ -600,8 +594,6 @@ 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);
|
||||
|
||||
|
|
@ -623,8 +615,6 @@ 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;
|
||||
|
|
@ -654,8 +644,6 @@ 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)
|
||||
|
|
@ -693,8 +681,6 @@ 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;
|
||||
|
|
@ -722,12 +708,6 @@ 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,
|
||||
|
|
@ -801,8 +781,6 @@ 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;
|
||||
|
|
@ -824,8 +802,6 @@ 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);
|
||||
|
|
@ -1435,24 +1411,6 @@ 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)
|
||||
{
|
||||
pa_strbuf *buf;
|
||||
char *str;
|
||||
int i;
|
||||
|
||||
buf = pa_strbuf_new();
|
||||
|
||||
for (i = 0; values[i]; i++) {
|
||||
pa_strbuf_printf(buf, " %u", values[i]);
|
||||
}
|
||||
|
||||
str = pa_strbuf_to_string_free(buf);
|
||||
pa_log_debug("Supported rates:%s", str);
|
||||
pa_xfree(str);
|
||||
}
|
||||
|
||||
unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_rate) {
|
||||
static unsigned int all_rates[] = { 8000, 11025, 12000,
|
||||
|
|
@ -1460,8 +1418,7 @@ unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_
|
|||
32000, 44100, 48000,
|
||||
64000, 88200, 96000,
|
||||
128000, 176400, 192000,
|
||||
352800, 384000,
|
||||
705600, 768000 };
|
||||
384000 };
|
||||
bool supported[PA_ELEMENTSOF(all_rates)] = { false, };
|
||||
snd_pcm_hw_params_t *hwparams;
|
||||
unsigned int i, j, n, *rates = NULL;
|
||||
|
|
@ -1503,40 +1460,39 @@ unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_
|
|||
rates[1] = 0;
|
||||
}
|
||||
|
||||
dump_supported_rates(rates);
|
||||
return rates;
|
||||
}
|
||||
|
||||
pa_sample_format_t *pa_alsa_get_supported_formats(snd_pcm_t *pcm, pa_sample_format_t fallback_format) {
|
||||
static const snd_pcm_format_t format_trans_to_pcm[] = {
|
||||
[PA_SAMPLE_U8] = SND_PCM_FORMAT_U8,
|
||||
[PA_SAMPLE_ALAW] = SND_PCM_FORMAT_A_LAW,
|
||||
[PA_SAMPLE_ULAW] = SND_PCM_FORMAT_MU_LAW,
|
||||
[PA_SAMPLE_S16LE] = SND_PCM_FORMAT_S16_LE,
|
||||
[PA_SAMPLE_S16BE] = SND_PCM_FORMAT_S16_BE,
|
||||
[PA_SAMPLE_FLOAT32LE] = SND_PCM_FORMAT_FLOAT_LE,
|
||||
[PA_SAMPLE_FLOAT32BE] = SND_PCM_FORMAT_FLOAT_BE,
|
||||
[PA_SAMPLE_S32LE] = SND_PCM_FORMAT_S32_LE,
|
||||
[PA_SAMPLE_S32BE] = SND_PCM_FORMAT_S32_BE,
|
||||
[PA_SAMPLE_S24LE] = SND_PCM_FORMAT_S24_3LE,
|
||||
[PA_SAMPLE_S24BE] = SND_PCM_FORMAT_S24_3BE,
|
||||
[PA_SAMPLE_S24_32LE] = SND_PCM_FORMAT_S24_LE,
|
||||
[PA_SAMPLE_S24_32BE] = SND_PCM_FORMAT_S24_BE,
|
||||
static const snd_pcm_format_t format_trans_to_pa[] = {
|
||||
[SND_PCM_FORMAT_U8] = PA_SAMPLE_U8,
|
||||
[SND_PCM_FORMAT_A_LAW] = PA_SAMPLE_ALAW,
|
||||
[SND_PCM_FORMAT_MU_LAW] = PA_SAMPLE_ULAW,
|
||||
[SND_PCM_FORMAT_S16_LE] = PA_SAMPLE_S16LE,
|
||||
[SND_PCM_FORMAT_S16_BE] = PA_SAMPLE_S16BE,
|
||||
[SND_PCM_FORMAT_FLOAT_LE] = PA_SAMPLE_FLOAT32LE,
|
||||
[SND_PCM_FORMAT_FLOAT_BE] = PA_SAMPLE_FLOAT32BE,
|
||||
[SND_PCM_FORMAT_S32_LE] = PA_SAMPLE_S32LE,
|
||||
[SND_PCM_FORMAT_S32_BE] = PA_SAMPLE_S32BE,
|
||||
[SND_PCM_FORMAT_S24_3LE] = PA_SAMPLE_S24LE,
|
||||
[SND_PCM_FORMAT_S24_3BE] = PA_SAMPLE_S24BE,
|
||||
[SND_PCM_FORMAT_S24_LE] = PA_SAMPLE_S24_32LE,
|
||||
[SND_PCM_FORMAT_S24_BE] = PA_SAMPLE_S24_32BE,
|
||||
};
|
||||
static const pa_sample_format_t all_formats[] = {
|
||||
PA_SAMPLE_U8,
|
||||
PA_SAMPLE_ALAW,
|
||||
PA_SAMPLE_ULAW,
|
||||
PA_SAMPLE_S16LE,
|
||||
PA_SAMPLE_S16BE,
|
||||
PA_SAMPLE_FLOAT32LE,
|
||||
PA_SAMPLE_FLOAT32BE,
|
||||
PA_SAMPLE_S32LE,
|
||||
PA_SAMPLE_S32BE,
|
||||
PA_SAMPLE_S24LE,
|
||||
PA_SAMPLE_S24BE,
|
||||
PA_SAMPLE_S24_32LE,
|
||||
PA_SAMPLE_S24_32BE,
|
||||
static const snd_pcm_format_t all_formats[] = {
|
||||
SND_PCM_FORMAT_U8,
|
||||
SND_PCM_FORMAT_A_LAW,
|
||||
SND_PCM_FORMAT_MU_LAW,
|
||||
SND_PCM_FORMAT_S16_LE,
|
||||
SND_PCM_FORMAT_S16_BE,
|
||||
SND_PCM_FORMAT_FLOAT_LE,
|
||||
SND_PCM_FORMAT_FLOAT_BE,
|
||||
SND_PCM_FORMAT_S32_LE,
|
||||
SND_PCM_FORMAT_S32_BE,
|
||||
SND_PCM_FORMAT_S24_3LE,
|
||||
SND_PCM_FORMAT_S24_3BE,
|
||||
SND_PCM_FORMAT_S24_LE,
|
||||
SND_PCM_FORMAT_S24_BE,
|
||||
};
|
||||
bool supported[PA_ELEMENTSOF(all_formats)] = {
|
||||
false,
|
||||
|
|
@ -1554,7 +1510,7 @@ pa_sample_format_t *pa_alsa_get_supported_formats(snd_pcm_t *pcm, pa_sample_form
|
|||
}
|
||||
|
||||
for (i = 0, n = 0; i < PA_ELEMENTSOF(all_formats); i++) {
|
||||
if (snd_pcm_hw_params_test_format(pcm, hwparams, format_trans_to_pcm[all_formats[i]]) == 0) {
|
||||
if (snd_pcm_hw_params_test_format(pcm, hwparams, all_formats[i]) == 0) {
|
||||
supported[i] = true;
|
||||
n++;
|
||||
}
|
||||
|
|
@ -1565,7 +1521,7 @@ pa_sample_format_t *pa_alsa_get_supported_formats(snd_pcm_t *pcm, pa_sample_form
|
|||
|
||||
for (i = 0, j = 0; i < PA_ELEMENTSOF(all_formats); i++) {
|
||||
if (supported[i])
|
||||
formats[j++] = all_formats[i];
|
||||
formats[j++] = format_trans_to_pa[all_formats[i]];
|
||||
}
|
||||
|
||||
formats[j] = PA_SAMPLE_MAX;
|
||||
|
|
@ -1573,7 +1529,7 @@ pa_sample_format_t *pa_alsa_get_supported_formats(snd_pcm_t *pcm, pa_sample_form
|
|||
formats = pa_xnew(pa_sample_format_t, 2);
|
||||
|
||||
formats[0] = fallback_format;
|
||||
if ((ret = snd_pcm_hw_params_set_format(pcm, hwparams, format_trans_to_pcm[formats[0]])) < 0) {
|
||||
if ((ret = snd_pcm_hw_params_set_format(pcm, hwparams, format_trans_to_pa[formats[0]])) < 0) {
|
||||
pa_log_debug("snd_pcm_hw_params_set_format() failed: %s", pa_alsa_strerror(ret));
|
||||
pa_xfree(formats);
|
||||
return NULL;
|
||||
|
|
@ -1584,6 +1540,7 @@ 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;
|
||||
|
|
@ -1643,16 +1600,14 @@ static snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer,
|
|||
snd_ctl_elem_iface_t iface,
|
||||
const char *name,
|
||||
unsigned int index,
|
||||
unsigned int device,
|
||||
unsigned int subdevice) {
|
||||
unsigned int device) {
|
||||
snd_mixer_elem_t *elem;
|
||||
|
||||
for (elem = snd_mixer_first_elem(mixer); elem; elem = snd_mixer_elem_next(elem)) {
|
||||
snd_hctl_elem_t **_helem, *helem;
|
||||
snd_hctl_elem_t *helem;
|
||||
if (snd_mixer_elem_get_type(elem) != SND_MIXER_ELEM_PULSEAUDIO)
|
||||
continue;
|
||||
_helem = snd_mixer_elem_get_private(elem);
|
||||
helem = *_helem;
|
||||
helem = snd_mixer_elem_get_private(elem);
|
||||
if (snd_hctl_elem_get_interface(helem) != iface)
|
||||
continue;
|
||||
if (!pa_streq(snd_hctl_elem_get_name(helem), name))
|
||||
|
|
@ -1661,19 +1616,17 @@ static snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer,
|
|||
continue;
|
||||
if (snd_hctl_elem_get_device(helem) != device)
|
||||
continue;
|
||||
if (snd_hctl_elem_get_subdevice(helem) != subdevice)
|
||||
continue;
|
||||
return elem;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snd_mixer_elem_t *pa_alsa_mixer_find_card(snd_mixer_t *mixer, struct pa_alsa_mixer_id *alsa_id, unsigned int device) {
|
||||
return pa_alsa_mixer_find(mixer, SND_CTL_ELEM_IFACE_CARD, alsa_id->name, alsa_id->index, device, 0);
|
||||
return pa_alsa_mixer_find(mixer, SND_CTL_ELEM_IFACE_CARD, alsa_id->name, alsa_id->index, device);
|
||||
}
|
||||
|
||||
snd_mixer_elem_t *pa_alsa_mixer_find_pcm(snd_mixer_t *mixer, const char *name, unsigned int device) {
|
||||
return pa_alsa_mixer_find(mixer, SND_CTL_ELEM_IFACE_PCM, name, 0, device, 0);
|
||||
return pa_alsa_mixer_find(mixer, SND_CTL_ELEM_IFACE_PCM, name, 0, device);
|
||||
}
|
||||
|
||||
static int mixer_class_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_t *c2)
|
||||
|
|
@ -1682,26 +1635,15 @@ static int mixer_class_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_
|
|||
return c1 == c2 ? 0 : (c1 > c2 ? 1 : -1);
|
||||
}
|
||||
|
||||
static void mixer_melem_free(snd_mixer_elem_t *elem)
|
||||
{
|
||||
snd_hctl_elem_t **_helem;
|
||||
_helem = snd_mixer_elem_get_private(elem);
|
||||
pa_xfree(_helem);
|
||||
}
|
||||
|
||||
static int mixer_class_event(snd_mixer_class_t *class, unsigned int mask,
|
||||
snd_hctl_elem_t *helem, snd_mixer_elem_t *melem)
|
||||
{
|
||||
int err;
|
||||
const char *name = snd_hctl_elem_get_name(helem);
|
||||
snd_hctl_elem_t **_helem;
|
||||
/* NOTE: The remove event is defined as '~0U`. */
|
||||
// NOTE: The remove event defined as '~0U`.
|
||||
if (mask == SND_CTL_EVENT_MASK_REMOVE) {
|
||||
/* NOTE: Unless we remove the pointer to melem from the linked-list at
|
||||
* private_data of helem, an assertion will be hit in alsa-lib since
|
||||
* the list is not empty. */
|
||||
_helem = snd_mixer_elem_get_private(melem);
|
||||
*_helem = NULL;
|
||||
// NOTE: unless remove pointer to melem from link-list at private_data of helem, hits
|
||||
// assersion in alsa-lib since the list is not empty.
|
||||
snd_mixer_elem_detach(melem, helem);
|
||||
} else if (mask & SND_CTL_EVENT_MASK_ADD) {
|
||||
snd_ctl_elem_iface_t iface = snd_hctl_elem_get_interface(helem);
|
||||
|
|
@ -1711,50 +1653,26 @@ static int mixer_class_event(snd_mixer_class_t *class, unsigned int mask,
|
|||
const char *name = snd_hctl_elem_get_name(helem);
|
||||
const int index = snd_hctl_elem_get_index(helem);
|
||||
const int device = snd_hctl_elem_get_device(helem);
|
||||
const int subdevice = snd_hctl_elem_get_subdevice(helem);
|
||||
snd_mixer_elem_t *new_melem;
|
||||
bool found = true;
|
||||
|
||||
new_melem = pa_alsa_mixer_find(mixer, iface, name, index, device, subdevice);
|
||||
new_melem = pa_alsa_mixer_find(mixer, iface, name, index, device);
|
||||
if (!new_melem) {
|
||||
_helem = pa_xmalloc(sizeof(snd_hctl_elem_t *));
|
||||
*_helem = helem;
|
||||
/* Put the hctl pointer as our private data - it will be useful for callbacks */
|
||||
if ((err = snd_mixer_elem_new(&new_melem, SND_MIXER_ELEM_PULSEAUDIO, 0, _helem, mixer_melem_free)) < 0) {
|
||||
if ((err = snd_mixer_elem_new(&new_melem, SND_MIXER_ELEM_PULSEAUDIO, 0, helem, NULL)) < 0) {
|
||||
pa_log_warn("snd_mixer_elem_new failed: %s", pa_alsa_strerror(err));
|
||||
return 0;
|
||||
}
|
||||
found = false;
|
||||
} else {
|
||||
_helem = snd_mixer_elem_get_private(new_melem);
|
||||
if (_helem) {
|
||||
char *s1, *s2;
|
||||
snd_ctl_elem_id_t *id1, *id2;
|
||||
snd_ctl_elem_id_alloca(&id1);
|
||||
snd_ctl_elem_id_alloca(&id2);
|
||||
snd_hctl_elem_get_id(helem, id1);
|
||||
snd_hctl_elem_get_id(*_helem, id2);
|
||||
s1 = snd_ctl_ascii_elem_id_get(id1);
|
||||
s2 = snd_ctl_ascii_elem_id_get(id2);
|
||||
pa_log_warn("mixer_class_event - duplicate mixer controls: %s | %s", s1, s2);
|
||||
free(s2);
|
||||
free(s1);
|
||||
return 0;
|
||||
}
|
||||
*_helem = helem;
|
||||
}
|
||||
|
||||
if ((err = snd_mixer_elem_attach(new_melem, helem)) < 0) {
|
||||
pa_log_warn("snd_mixer_elem_attach failed: %s", pa_alsa_strerror(err));
|
||||
snd_mixer_elem_free(melem);
|
||||
snd_mixer_elem_free(melem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
if ((err = snd_mixer_elem_add(new_melem, class)) < 0) {
|
||||
pa_log_warn("snd_mixer_elem_add failed: %s", pa_alsa_strerror(err));
|
||||
return 0;
|
||||
}
|
||||
if ((err = snd_mixer_elem_add(new_melem, class)) < 0) {
|
||||
pa_log_warn("snd_mixer_elem_add failed: %s", pa_alsa_strerror(err));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue