mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04: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
|
|
@ -362,7 +362,7 @@ static int add_pro_profile(pa_card *impl, uint32_t index)
|
||||||
devstr, NULL, &m->sample_spec,
|
devstr, NULL, &m->sample_spec,
|
||||||
&m->channel_map, SND_PCM_STREAM_PLAYBACK,
|
&m->channel_map, SND_PCM_STREAM_PLAYBACK,
|
||||||
&try_period_size, &try_buffer_size,
|
&try_period_size, &try_buffer_size,
|
||||||
0, NULL, NULL, NULL, NULL, false))) {
|
0, NULL, NULL, false))) {
|
||||||
pa_alsa_init_proplist_pcm(NULL, m->output_proplist, m->output_pcm);
|
pa_alsa_init_proplist_pcm(NULL, m->output_proplist, m->output_pcm);
|
||||||
pa_proplist_setf(m->output_proplist, "clock.name", "api.alsa.%u", index);
|
pa_proplist_setf(m->output_proplist, "clock.name", "api.alsa.%u", index);
|
||||||
pa_alsa_close(&m->output_pcm);
|
pa_alsa_close(&m->output_pcm);
|
||||||
|
|
@ -392,7 +392,7 @@ static int add_pro_profile(pa_card *impl, uint32_t index)
|
||||||
devstr, NULL, &m->sample_spec,
|
devstr, NULL, &m->sample_spec,
|
||||||
&m->channel_map, SND_PCM_STREAM_CAPTURE,
|
&m->channel_map, SND_PCM_STREAM_CAPTURE,
|
||||||
&try_period_size, &try_buffer_size,
|
&try_period_size, &try_buffer_size,
|
||||||
0, NULL, NULL, NULL, NULL, false))) {
|
0, NULL, NULL, false))) {
|
||||||
pa_alsa_init_proplist_pcm(NULL, m->input_proplist, m->input_pcm);
|
pa_alsa_init_proplist_pcm(NULL, m->input_proplist, m->input_pcm);
|
||||||
pa_proplist_setf(m->input_proplist, "clock.name", "api.alsa.%u", index);
|
pa_proplist_setf(m->input_proplist, "clock.name", "api.alsa.%u", index);
|
||||||
pa_alsa_close(&m->input_pcm);
|
pa_alsa_close(&m->input_pcm);
|
||||||
|
|
@ -449,8 +449,8 @@ static void add_profiles(pa_card *impl)
|
||||||
pa_dynarray_append(&impl->out.devices, dev);
|
pa_dynarray_append(&impl->out.devices, dev);
|
||||||
}
|
}
|
||||||
if (impl->use_ucm) {
|
if (impl->use_ucm) {
|
||||||
if (m->ucm_context.ucm_device) {
|
if (m->ucm_context.ucm_devices) {
|
||||||
pa_alsa_ucm_add_port(NULL, &m->ucm_context,
|
pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context,
|
||||||
true, impl->ports, ap, NULL);
|
true, impl->ports, ap, NULL);
|
||||||
pa_alsa_ucm_add_ports(&dev->ports, m->proplist, &m->ucm_context,
|
pa_alsa_ucm_add_ports(&dev->ports, m->proplist, &m->ucm_context,
|
||||||
true, impl, dev->pcm_handle, impl->profile_set->ignore_dB);
|
true, impl, dev->pcm_handle, impl->profile_set->ignore_dB);
|
||||||
|
|
@ -473,8 +473,8 @@ static void add_profiles(pa_card *impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl->use_ucm) {
|
if (impl->use_ucm) {
|
||||||
if (m->ucm_context.ucm_device) {
|
if (m->ucm_context.ucm_devices) {
|
||||||
pa_alsa_ucm_add_port(NULL, &m->ucm_context,
|
pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context,
|
||||||
false, impl->ports, ap, NULL);
|
false, impl->ports, ap, NULL);
|
||||||
pa_alsa_ucm_add_ports(&dev->ports, m->proplist, &m->ucm_context,
|
pa_alsa_ucm_add_ports(&dev->ports, m->proplist, &m->ucm_context,
|
||||||
false, impl, dev->pcm_handle, impl->profile_set->ignore_dB);
|
false, impl, dev->pcm_handle, impl->profile_set->ignore_dB);
|
||||||
|
|
@ -608,7 +608,7 @@ struct temp_port_avail {
|
||||||
static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask)
|
static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask)
|
||||||
{
|
{
|
||||||
pa_card *impl = snd_mixer_elem_get_callback_private(melem);
|
pa_card *impl = snd_mixer_elem_get_callback_private(melem);
|
||||||
snd_hctl_elem_t **_elem = snd_mixer_elem_get_private(melem), *elem;
|
snd_hctl_elem_t *elem = snd_mixer_elem_get_private(melem);
|
||||||
snd_ctl_elem_value_t *elem_value;
|
snd_ctl_elem_value_t *elem_value;
|
||||||
bool plugged_in, any_input_port_available;
|
bool plugged_in, any_input_port_available;
|
||||||
void *state;
|
void *state;
|
||||||
|
|
@ -618,8 +618,6 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask)
|
||||||
enum acp_available active_available = ACP_AVAILABLE_UNKNOWN;
|
enum acp_available active_available = ACP_AVAILABLE_UNKNOWN;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
pa_assert(_elem);
|
|
||||||
elem = *_elem;
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Changing the jack state may cause a port change, and a port change will
|
/* Changing the jack state may cause a port change, and a port change will
|
||||||
* make the sink or source change the mixer settings. If there are multiple
|
* make the sink or source change the mixer settings. If there are multiple
|
||||||
|
|
@ -888,17 +886,13 @@ static pa_device_port* find_port_with_eld_device(pa_card *impl, int device)
|
||||||
static int hdmi_eld_changed(snd_mixer_elem_t *melem, unsigned int mask)
|
static int hdmi_eld_changed(snd_mixer_elem_t *melem, unsigned int mask)
|
||||||
{
|
{
|
||||||
pa_card *impl = snd_mixer_elem_get_callback_private(melem);
|
pa_card *impl = snd_mixer_elem_get_callback_private(melem);
|
||||||
snd_hctl_elem_t **_elem = snd_mixer_elem_get_private(melem), *elem;
|
snd_hctl_elem_t *elem = snd_mixer_elem_get_private(melem);
|
||||||
int device;
|
int device = snd_hctl_elem_get_device(elem);
|
||||||
const char *old_monitor_name;
|
const char *old_monitor_name;
|
||||||
pa_device_port *p;
|
pa_device_port *p;
|
||||||
pa_hdmi_eld eld;
|
pa_hdmi_eld eld;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
pa_assert(_elem);
|
|
||||||
elem = *_elem;
|
|
||||||
device = snd_hctl_elem_get_device(elem);
|
|
||||||
|
|
||||||
if (mask == SND_CTL_EVENT_MASK_REMOVE)
|
if (mask == SND_CTL_EVENT_MASK_REMOVE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -1259,7 +1253,8 @@ static int setup_mixer(pa_card *impl, pa_alsa_device *dev, bool ignore_dB)
|
||||||
* will be NULL, but the UCM device enable sequence will still need to be
|
* will be NULL, but the UCM device enable sequence will still need to be
|
||||||
* executed. */
|
* executed. */
|
||||||
if (dev->active_port && dev->ucm_context) {
|
if (dev->active_port && dev->ucm_context) {
|
||||||
if ((res = pa_alsa_ucm_set_port(dev->ucm_context, dev->active_port)) < 0)
|
if ((res = pa_alsa_ucm_set_port(dev->ucm_context, dev->active_port,
|
||||||
|
dev->direction == PA_ALSA_DIRECTION_OUTPUT)) < 0)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1434,7 +1429,8 @@ int acp_card_set_profile(struct acp_card *card, uint32_t new_index, uint32_t fla
|
||||||
/* if UCM is available for this card then update the verb */
|
/* if UCM is available for this card then update the verb */
|
||||||
if (impl->use_ucm && !(np->profile.flags & ACP_PROFILE_PRO)) {
|
if (impl->use_ucm && !(np->profile.flags & ACP_PROFILE_PRO)) {
|
||||||
if ((res = pa_alsa_ucm_set_profile(&impl->ucm, impl,
|
if ((res = pa_alsa_ucm_set_profile(&impl->ucm, impl,
|
||||||
np->profile.flags & ACP_PROFILE_OFF ? NULL : np, op)) < 0) {
|
np->profile.flags & ACP_PROFILE_OFF ? NULL : np->profile.name,
|
||||||
|
op ? op->profile.name : NULL)) < 0) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1443,8 +1439,8 @@ int acp_card_set_profile(struct acp_card *card, uint32_t new_index, uint32_t fla
|
||||||
PA_IDXSET_FOREACH(am, np->output_mappings, idx) {
|
PA_IDXSET_FOREACH(am, np->output_mappings, idx) {
|
||||||
if (impl->use_ucm) {
|
if (impl->use_ucm) {
|
||||||
/* Update ports priorities */
|
/* Update ports priorities */
|
||||||
if (am->ucm_context.ucm_device) {
|
if (am->ucm_context.ucm_devices) {
|
||||||
pa_alsa_ucm_add_port(am->output.ports, &am->ucm_context,
|
pa_alsa_ucm_add_ports_combination(am->output.ports, &am->ucm_context,
|
||||||
true, impl->ports, np, NULL);
|
true, impl->ports, np, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1456,8 +1452,8 @@ int acp_card_set_profile(struct acp_card *card, uint32_t new_index, uint32_t fla
|
||||||
PA_IDXSET_FOREACH(am, np->input_mappings, idx) {
|
PA_IDXSET_FOREACH(am, np->input_mappings, idx) {
|
||||||
if (impl->use_ucm) {
|
if (impl->use_ucm) {
|
||||||
/* Update ports priorities */
|
/* Update ports priorities */
|
||||||
if (am->ucm_context.ucm_device) {
|
if (am->ucm_context.ucm_devices) {
|
||||||
pa_alsa_ucm_add_port(am->input.ports, &am->ucm_context,
|
pa_alsa_ucm_add_ports_combination(am->input.ports, &am->ucm_context,
|
||||||
false, impl->ports, np, NULL);
|
false, impl->ports, np, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1848,7 +1844,8 @@ int acp_device_set_port(struct acp_device *dev, uint32_t port_index, uint32_t fl
|
||||||
mixer_volume_init(impl, d);
|
mixer_volume_init(impl, d);
|
||||||
|
|
||||||
sync_mixer(d, p);
|
sync_mixer(d, p);
|
||||||
res = pa_alsa_ucm_set_port(d->ucm_context, p);
|
res = pa_alsa_ucm_set_port(d->ucm_context, p,
|
||||||
|
dev->direction == ACP_DIRECTION_PLAYBACK);
|
||||||
} else {
|
} else {
|
||||||
pa_alsa_port_data *data;
|
pa_alsa_port_data *data;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5000,7 +5000,7 @@ static snd_pcm_t* mapping_open_pcm(pa_alsa_mapping *m,
|
||||||
handle = pa_alsa_open_by_template(
|
handle = pa_alsa_open_by_template(
|
||||||
m->device_strings, dev_id, NULL, &try_ss,
|
m->device_strings, dev_id, NULL, &try_ss,
|
||||||
&try_map, mode, &try_period_size,
|
&try_map, mode, &try_period_size,
|
||||||
&try_buffer_size, 0, NULL, NULL, NULL, NULL, exact_channels);
|
&try_buffer_size, 0, NULL, NULL, exact_channels);
|
||||||
if (handle && !exact_channels && m->channel_map.channels != try_map.channels) {
|
if (handle && !exact_channels && m->channel_map.channels != try_map.channels) {
|
||||||
char buf[PA_CHANNEL_MAP_SNPRINT_MAX];
|
char buf[PA_CHANNEL_MAP_SNPRINT_MAX];
|
||||||
pa_log_debug("Channel map for mapping '%s' permanently changed to '%s'", m->name,
|
pa_log_debug("Channel map for mapping '%s' permanently changed to '%s'", m->name,
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ struct pa_alsa_mapping {
|
||||||
pa_alsa_device output;
|
pa_alsa_device output;
|
||||||
pa_alsa_device input;
|
pa_alsa_device input;
|
||||||
|
|
||||||
/* ucm device context */
|
/* ucm device context*/
|
||||||
pa_alsa_ucm_mapping_context ucm_context;
|
pa_alsa_ucm_mapping_context ucm_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -381,9 +381,6 @@ struct pa_alsa_profile {
|
||||||
pa_idxset *input_mappings;
|
pa_idxset *input_mappings;
|
||||||
pa_idxset *output_mappings;
|
pa_idxset *output_mappings;
|
||||||
|
|
||||||
/* ucm device context */
|
|
||||||
pa_alsa_ucm_profile_context ucm_context;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
pa_dynarray devices;
|
pa_dynarray devices;
|
||||||
} out;
|
} out;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -142,13 +142,12 @@ typedef struct pa_alsa_ucm_modifier pa_alsa_ucm_modifier;
|
||||||
typedef struct pa_alsa_ucm_device pa_alsa_ucm_device;
|
typedef struct pa_alsa_ucm_device pa_alsa_ucm_device;
|
||||||
typedef struct pa_alsa_ucm_config pa_alsa_ucm_config;
|
typedef struct pa_alsa_ucm_config pa_alsa_ucm_config;
|
||||||
typedef struct pa_alsa_ucm_mapping_context pa_alsa_ucm_mapping_context;
|
typedef struct pa_alsa_ucm_mapping_context pa_alsa_ucm_mapping_context;
|
||||||
typedef struct pa_alsa_ucm_profile_context pa_alsa_ucm_profile_context;
|
|
||||||
typedef struct pa_alsa_ucm_port_data pa_alsa_ucm_port_data;
|
typedef struct pa_alsa_ucm_port_data pa_alsa_ucm_port_data;
|
||||||
typedef struct pa_alsa_ucm_volume pa_alsa_ucm_volume;
|
typedef struct pa_alsa_ucm_volume pa_alsa_ucm_volume;
|
||||||
|
|
||||||
int pa_alsa_ucm_query_profiles(pa_alsa_ucm_config *ucm, int card_index);
|
int pa_alsa_ucm_query_profiles(pa_alsa_ucm_config *ucm, int card_index);
|
||||||
pa_alsa_profile_set* pa_alsa_ucm_add_profile_set(pa_alsa_ucm_config *ucm, pa_channel_map *default_channel_map);
|
pa_alsa_profile_set* pa_alsa_ucm_add_profile_set(pa_alsa_ucm_config *ucm, pa_channel_map *default_channel_map);
|
||||||
int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, pa_card *card, pa_alsa_profile *new_profile, pa_alsa_profile *old_profile);
|
int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, pa_card *card, const char *new_profile, const char *old_profile);
|
||||||
|
|
||||||
int pa_alsa_ucm_get_verb(snd_use_case_mgr_t *uc_mgr, const char *verb_name, const char *verb_desc, pa_alsa_ucm_verb **p_verb);
|
int pa_alsa_ucm_get_verb(snd_use_case_mgr_t *uc_mgr, const char *verb_name, const char *verb_desc, pa_alsa_ucm_verb **p_verb);
|
||||||
|
|
||||||
|
|
@ -160,14 +159,14 @@ void pa_alsa_ucm_add_ports(
|
||||||
pa_card *card,
|
pa_card *card,
|
||||||
snd_pcm_t *pcm_handle,
|
snd_pcm_t *pcm_handle,
|
||||||
bool ignore_dB);
|
bool ignore_dB);
|
||||||
void pa_alsa_ucm_add_port(
|
void pa_alsa_ucm_add_ports_combination(
|
||||||
pa_hashmap *hash,
|
pa_hashmap *hash,
|
||||||
pa_alsa_ucm_mapping_context *context,
|
pa_alsa_ucm_mapping_context *context,
|
||||||
bool is_sink,
|
bool is_sink,
|
||||||
pa_hashmap *ports,
|
pa_hashmap *ports,
|
||||||
pa_card_profile *cp,
|
pa_card_profile *cp,
|
||||||
pa_core *core);
|
pa_core *core);
|
||||||
int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port);
|
int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port, bool is_sink);
|
||||||
|
|
||||||
void pa_alsa_ucm_free(pa_alsa_ucm_config *ucm);
|
void pa_alsa_ucm_free(pa_alsa_ucm_config *ucm);
|
||||||
void pa_alsa_ucm_mapping_context_free(pa_alsa_ucm_mapping_context *context);
|
void pa_alsa_ucm_mapping_context_free(pa_alsa_ucm_mapping_context *context);
|
||||||
|
|
@ -224,8 +223,11 @@ struct pa_alsa_ucm_modifier {
|
||||||
|
|
||||||
pa_proplist *proplist;
|
pa_proplist *proplist;
|
||||||
|
|
||||||
pa_idxset *conflicting_devices;
|
int n_confdev;
|
||||||
pa_idxset *supported_devices;
|
int n_suppdev;
|
||||||
|
|
||||||
|
const char **conflicting_devices;
|
||||||
|
const char **supported_devices;
|
||||||
|
|
||||||
pa_direction_t action_direction;
|
pa_direction_t action_direction;
|
||||||
|
|
||||||
|
|
@ -268,23 +270,21 @@ struct pa_alsa_ucm_mapping_context {
|
||||||
pa_alsa_ucm_config *ucm;
|
pa_alsa_ucm_config *ucm;
|
||||||
pa_direction_t direction;
|
pa_direction_t direction;
|
||||||
|
|
||||||
pa_alsa_ucm_device *ucm_device;
|
pa_idxset *ucm_devices;
|
||||||
pa_alsa_ucm_modifier *ucm_modifier;
|
pa_idxset *ucm_modifiers;
|
||||||
};
|
|
||||||
|
|
||||||
struct pa_alsa_ucm_profile_context {
|
|
||||||
pa_alsa_ucm_verb *verb;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pa_alsa_ucm_port_data {
|
struct pa_alsa_ucm_port_data {
|
||||||
pa_alsa_ucm_config *ucm;
|
pa_alsa_ucm_config *ucm;
|
||||||
pa_device_port *core_port;
|
pa_device_port *core_port;
|
||||||
|
|
||||||
pa_alsa_ucm_device *device;
|
/* A single port will be associated with multiple devices if it represents
|
||||||
|
* a combination of devices. */
|
||||||
|
pa_dynarray *devices; /* pa_alsa_ucm_device */
|
||||||
|
|
||||||
/* verb name -> pa_alsa_path for volume control */
|
/* profile name -> pa_alsa_path for volume control */
|
||||||
pa_hashmap *paths;
|
pa_hashmap *paths;
|
||||||
/* Current path, set when activating verb */
|
/* Current path, set when activating profile */
|
||||||
pa_alsa_path *path;
|
pa_alsa_path *path;
|
||||||
|
|
||||||
/* ELD info */
|
/* ELD info */
|
||||||
|
|
|
||||||
|
|
@ -505,8 +505,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto(
|
||||||
snd_pcm_uframes_t tsched_size,
|
snd_pcm_uframes_t tsched_size,
|
||||||
bool *use_mmap,
|
bool *use_mmap,
|
||||||
bool *use_tsched,
|
bool *use_tsched,
|
||||||
pa_sample_format_t **query_supported_formats,
|
|
||||||
unsigned int **query_supported_rates,
|
|
||||||
pa_alsa_profile_set *ps,
|
pa_alsa_profile_set *ps,
|
||||||
pa_alsa_mapping **mapping) {
|
pa_alsa_mapping **mapping) {
|
||||||
|
|
||||||
|
|
@ -545,8 +543,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto(
|
||||||
tsched_size,
|
tsched_size,
|
||||||
use_mmap,
|
use_mmap,
|
||||||
use_tsched,
|
use_tsched,
|
||||||
query_supported_formats,
|
|
||||||
query_supported_rates,
|
|
||||||
m);
|
m);
|
||||||
|
|
||||||
if (pcm_handle) {
|
if (pcm_handle) {
|
||||||
|
|
@ -574,8 +570,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto(
|
||||||
tsched_size,
|
tsched_size,
|
||||||
use_mmap,
|
use_mmap,
|
||||||
use_tsched,
|
use_tsched,
|
||||||
query_supported_formats,
|
|
||||||
query_supported_rates,
|
|
||||||
m);
|
m);
|
||||||
|
|
||||||
if (pcm_handle) {
|
if (pcm_handle) {
|
||||||
|
|
@ -600,8 +594,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto(
|
||||||
tsched_size,
|
tsched_size,
|
||||||
use_mmap,
|
use_mmap,
|
||||||
use_tsched,
|
use_tsched,
|
||||||
query_supported_formats,
|
|
||||||
query_supported_rates,
|
|
||||||
false);
|
false);
|
||||||
pa_xfree(d);
|
pa_xfree(d);
|
||||||
|
|
||||||
|
|
@ -623,8 +615,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_mapping(
|
||||||
snd_pcm_uframes_t tsched_size,
|
snd_pcm_uframes_t tsched_size,
|
||||||
bool *use_mmap,
|
bool *use_mmap,
|
||||||
bool *use_tsched,
|
bool *use_tsched,
|
||||||
pa_sample_format_t **query_supported_formats,
|
|
||||||
unsigned int **query_supported_rates,
|
|
||||||
pa_alsa_mapping *m) {
|
pa_alsa_mapping *m) {
|
||||||
|
|
||||||
snd_pcm_t *pcm_handle;
|
snd_pcm_t *pcm_handle;
|
||||||
|
|
@ -654,8 +644,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_mapping(
|
||||||
tsched_size,
|
tsched_size,
|
||||||
use_mmap,
|
use_mmap,
|
||||||
use_tsched,
|
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 */);
|
pa_channel_map_valid(&m->channel_map) /* Query the channel count if we don't know what we want */);
|
||||||
|
|
||||||
if (!pcm_handle)
|
if (!pcm_handle)
|
||||||
|
|
@ -693,8 +681,6 @@ snd_pcm_t *pa_alsa_open_by_device_string(
|
||||||
snd_pcm_uframes_t tsched_size,
|
snd_pcm_uframes_t tsched_size,
|
||||||
bool *use_mmap,
|
bool *use_mmap,
|
||||||
bool *use_tsched,
|
bool *use_tsched,
|
||||||
pa_sample_format_t **query_supported_formats,
|
|
||||||
unsigned int **query_supported_rates,
|
|
||||||
bool require_exact_channel_number) {
|
bool require_exact_channel_number) {
|
||||||
|
|
||||||
int err;
|
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,
|
pa_log_info("ALSA device open '%s' %s: %p", d,
|
||||||
mode == SND_PCM_STREAM_CAPTURE ? "capture" : "playback", pcm_handle);
|
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(
|
if ((err = pa_alsa_set_hw_params(
|
||||||
pcm_handle,
|
pcm_handle,
|
||||||
ss,
|
ss,
|
||||||
|
|
@ -801,8 +781,6 @@ snd_pcm_t *pa_alsa_open_by_template(
|
||||||
snd_pcm_uframes_t tsched_size,
|
snd_pcm_uframes_t tsched_size,
|
||||||
bool *use_mmap,
|
bool *use_mmap,
|
||||||
bool *use_tsched,
|
bool *use_tsched,
|
||||||
pa_sample_format_t **query_supported_formats,
|
|
||||||
unsigned int **query_supported_rates,
|
|
||||||
bool require_exact_channel_number) {
|
bool require_exact_channel_number) {
|
||||||
|
|
||||||
snd_pcm_t *pcm_handle;
|
snd_pcm_t *pcm_handle;
|
||||||
|
|
@ -824,8 +802,6 @@ snd_pcm_t *pa_alsa_open_by_template(
|
||||||
tsched_size,
|
tsched_size,
|
||||||
use_mmap,
|
use_mmap,
|
||||||
use_tsched,
|
use_tsched,
|
||||||
query_supported_formats,
|
|
||||||
query_supported_rates,
|
|
||||||
require_exact_channel_number);
|
require_exact_channel_number);
|
||||||
|
|
||||||
pa_xfree(d);
|
pa_xfree(d);
|
||||||
|
|
@ -1435,24 +1411,6 @@ char *pa_alsa_get_reserve_name(const char *device) {
|
||||||
|
|
||||||
return pa_sprintf_malloc("Audio%i", i);
|
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) {
|
unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_rate) {
|
||||||
static unsigned int all_rates[] = { 8000, 11025, 12000,
|
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,
|
32000, 44100, 48000,
|
||||||
64000, 88200, 96000,
|
64000, 88200, 96000,
|
||||||
128000, 176400, 192000,
|
128000, 176400, 192000,
|
||||||
352800, 384000,
|
384000 };
|
||||||
705600, 768000 };
|
|
||||||
bool supported[PA_ELEMENTSOF(all_rates)] = { false, };
|
bool supported[PA_ELEMENTSOF(all_rates)] = { false, };
|
||||||
snd_pcm_hw_params_t *hwparams;
|
snd_pcm_hw_params_t *hwparams;
|
||||||
unsigned int i, j, n, *rates = NULL;
|
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;
|
rates[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dump_supported_rates(rates);
|
|
||||||
return rates;
|
return rates;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_sample_format_t *pa_alsa_get_supported_formats(snd_pcm_t *pcm, pa_sample_format_t fallback_format) {
|
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[] = {
|
static const snd_pcm_format_t format_trans_to_pa[] = {
|
||||||
[PA_SAMPLE_U8] = SND_PCM_FORMAT_U8,
|
[SND_PCM_FORMAT_U8] = PA_SAMPLE_U8,
|
||||||
[PA_SAMPLE_ALAW] = SND_PCM_FORMAT_A_LAW,
|
[SND_PCM_FORMAT_A_LAW] = PA_SAMPLE_ALAW,
|
||||||
[PA_SAMPLE_ULAW] = SND_PCM_FORMAT_MU_LAW,
|
[SND_PCM_FORMAT_MU_LAW] = PA_SAMPLE_ULAW,
|
||||||
[PA_SAMPLE_S16LE] = SND_PCM_FORMAT_S16_LE,
|
[SND_PCM_FORMAT_S16_LE] = PA_SAMPLE_S16LE,
|
||||||
[PA_SAMPLE_S16BE] = SND_PCM_FORMAT_S16_BE,
|
[SND_PCM_FORMAT_S16_BE] = PA_SAMPLE_S16BE,
|
||||||
[PA_SAMPLE_FLOAT32LE] = SND_PCM_FORMAT_FLOAT_LE,
|
[SND_PCM_FORMAT_FLOAT_LE] = PA_SAMPLE_FLOAT32LE,
|
||||||
[PA_SAMPLE_FLOAT32BE] = SND_PCM_FORMAT_FLOAT_BE,
|
[SND_PCM_FORMAT_FLOAT_BE] = PA_SAMPLE_FLOAT32BE,
|
||||||
[PA_SAMPLE_S32LE] = SND_PCM_FORMAT_S32_LE,
|
[SND_PCM_FORMAT_S32_LE] = PA_SAMPLE_S32LE,
|
||||||
[PA_SAMPLE_S32BE] = SND_PCM_FORMAT_S32_BE,
|
[SND_PCM_FORMAT_S32_BE] = PA_SAMPLE_S32BE,
|
||||||
[PA_SAMPLE_S24LE] = SND_PCM_FORMAT_S24_3LE,
|
[SND_PCM_FORMAT_S24_3LE] = PA_SAMPLE_S24LE,
|
||||||
[PA_SAMPLE_S24BE] = SND_PCM_FORMAT_S24_3BE,
|
[SND_PCM_FORMAT_S24_3BE] = PA_SAMPLE_S24BE,
|
||||||
[PA_SAMPLE_S24_32LE] = SND_PCM_FORMAT_S24_LE,
|
[SND_PCM_FORMAT_S24_LE] = PA_SAMPLE_S24_32LE,
|
||||||
[PA_SAMPLE_S24_32BE] = SND_PCM_FORMAT_S24_BE,
|
[SND_PCM_FORMAT_S24_BE] = PA_SAMPLE_S24_32BE,
|
||||||
};
|
};
|
||||||
static const pa_sample_format_t all_formats[] = {
|
static const snd_pcm_format_t all_formats[] = {
|
||||||
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,
|
||||||
};
|
};
|
||||||
bool supported[PA_ELEMENTSOF(all_formats)] = {
|
bool supported[PA_ELEMENTSOF(all_formats)] = {
|
||||||
false,
|
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++) {
|
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;
|
supported[i] = true;
|
||||||
n++;
|
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++) {
|
for (i = 0, j = 0; i < PA_ELEMENTSOF(all_formats); i++) {
|
||||||
if (supported[i])
|
if (supported[i])
|
||||||
formats[j++] = all_formats[i];
|
formats[j++] = format_trans_to_pa[all_formats[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
formats[j] = PA_SAMPLE_MAX;
|
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 = pa_xnew(pa_sample_format_t, 2);
|
||||||
|
|
||||||
formats[0] = fallback_format;
|
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_log_debug("snd_pcm_hw_params_set_format() failed: %s", pa_alsa_strerror(ret));
|
||||||
pa_xfree(formats);
|
pa_xfree(formats);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1584,6 +1540,7 @@ pa_sample_format_t *pa_alsa_get_supported_formats(snd_pcm_t *pcm, pa_sample_form
|
||||||
|
|
||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool pa_alsa_pcm_is_hw(snd_pcm_t *pcm) {
|
bool pa_alsa_pcm_is_hw(snd_pcm_t *pcm) {
|
||||||
snd_pcm_info_t* info;
|
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,
|
snd_ctl_elem_iface_t iface,
|
||||||
const char *name,
|
const char *name,
|
||||||
unsigned int index,
|
unsigned int index,
|
||||||
unsigned int device,
|
unsigned int device) {
|
||||||
unsigned int subdevice) {
|
|
||||||
snd_mixer_elem_t *elem;
|
snd_mixer_elem_t *elem;
|
||||||
|
|
||||||
for (elem = snd_mixer_first_elem(mixer); elem; elem = snd_mixer_elem_next(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)
|
if (snd_mixer_elem_get_type(elem) != SND_MIXER_ELEM_PULSEAUDIO)
|
||||||
continue;
|
continue;
|
||||||
_helem = snd_mixer_elem_get_private(elem);
|
helem = snd_mixer_elem_get_private(elem);
|
||||||
helem = *_helem;
|
|
||||||
if (snd_hctl_elem_get_interface(helem) != iface)
|
if (snd_hctl_elem_get_interface(helem) != iface)
|
||||||
continue;
|
continue;
|
||||||
if (!pa_streq(snd_hctl_elem_get_name(helem), name))
|
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;
|
continue;
|
||||||
if (snd_hctl_elem_get_device(helem) != device)
|
if (snd_hctl_elem_get_device(helem) != device)
|
||||||
continue;
|
continue;
|
||||||
if (snd_hctl_elem_get_subdevice(helem) != subdevice)
|
|
||||||
continue;
|
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
return NULL;
|
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) {
|
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) {
|
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)
|
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);
|
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,
|
static int mixer_class_event(snd_mixer_class_t *class, unsigned int mask,
|
||||||
snd_hctl_elem_t *helem, snd_mixer_elem_t *melem)
|
snd_hctl_elem_t *helem, snd_mixer_elem_t *melem)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
const char *name = snd_hctl_elem_get_name(helem);
|
const char *name = snd_hctl_elem_get_name(helem);
|
||||||
snd_hctl_elem_t **_helem;
|
// NOTE: The remove event defined as '~0U`.
|
||||||
/* NOTE: The remove event is defined as '~0U`. */
|
|
||||||
if (mask == SND_CTL_EVENT_MASK_REMOVE) {
|
if (mask == SND_CTL_EVENT_MASK_REMOVE) {
|
||||||
/* NOTE: Unless we remove the pointer to melem from the linked-list at
|
// NOTE: unless remove pointer to melem from link-list at private_data of helem, hits
|
||||||
* private_data of helem, an assertion will be hit in alsa-lib since
|
// assersion in alsa-lib since the list is not empty.
|
||||||
* the list is not empty. */
|
|
||||||
_helem = snd_mixer_elem_get_private(melem);
|
|
||||||
*_helem = NULL;
|
|
||||||
snd_mixer_elem_detach(melem, helem);
|
snd_mixer_elem_detach(melem, helem);
|
||||||
} else if (mask & SND_CTL_EVENT_MASK_ADD) {
|
} else if (mask & SND_CTL_EVENT_MASK_ADD) {
|
||||||
snd_ctl_elem_iface_t iface = snd_hctl_elem_get_interface(helem);
|
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 char *name = snd_hctl_elem_get_name(helem);
|
||||||
const int index = snd_hctl_elem_get_index(helem);
|
const int index = snd_hctl_elem_get_index(helem);
|
||||||
const int device = snd_hctl_elem_get_device(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;
|
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) {
|
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 */
|
/* 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));
|
pa_log_warn("snd_mixer_elem_new failed: %s", pa_alsa_strerror(err));
|
||||||
return 0;
|
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) {
|
if ((err = snd_mixer_elem_attach(new_melem, helem)) < 0) {
|
||||||
pa_log_warn("snd_mixer_elem_attach failed: %s", pa_alsa_strerror(err));
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if ((err = snd_mixer_elem_add(new_melem, class)) < 0) {
|
||||||
if ((err = snd_mixer_elem_add(new_melem, class)) < 0) {
|
pa_log_warn("snd_mixer_elem_add failed: %s", pa_alsa_strerror(err));
|
||||||
pa_log_warn("snd_mixer_elem_add failed: %s", pa_alsa_strerror(err));
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto(
|
||||||
snd_pcm_uframes_t tsched_size,
|
snd_pcm_uframes_t tsched_size,
|
||||||
bool *use_mmap, /* modified at return */
|
bool *use_mmap, /* modified at return */
|
||||||
bool *use_tsched, /* modified at return */
|
bool *use_tsched, /* modified at return */
|
||||||
pa_sample_format_t **query_supported_formats, /* modified at return */
|
|
||||||
unsigned int **query_supported_rates, /* modified at return */
|
|
||||||
pa_alsa_profile_set *ps,
|
pa_alsa_profile_set *ps,
|
||||||
pa_alsa_mapping **mapping); /* modified at return */
|
pa_alsa_mapping **mapping); /* modified at return */
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -82,8 +80,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_mapping(
|
||||||
snd_pcm_uframes_t tsched_size,
|
snd_pcm_uframes_t tsched_size,
|
||||||
bool *use_mmap, /* modified at return */
|
bool *use_mmap, /* modified at return */
|
||||||
bool *use_tsched, /* modified at return */
|
bool *use_tsched, /* modified at return */
|
||||||
pa_sample_format_t **query_supported_formats, /* modified at return */
|
|
||||||
unsigned int **query_supported_rates, /* modified at return */
|
|
||||||
pa_alsa_mapping *mapping);
|
pa_alsa_mapping *mapping);
|
||||||
|
|
||||||
/* Opens the explicit ALSA device */
|
/* Opens the explicit ALSA device */
|
||||||
|
|
@ -98,8 +94,6 @@ snd_pcm_t *pa_alsa_open_by_device_string(
|
||||||
snd_pcm_uframes_t tsched_size,
|
snd_pcm_uframes_t tsched_size,
|
||||||
bool *use_mmap, /* modified at return */
|
bool *use_mmap, /* modified at return */
|
||||||
bool *use_tsched, /* modified at return */
|
bool *use_tsched, /* modified at return */
|
||||||
pa_sample_format_t **query_supported_formats, /* modified at return */
|
|
||||||
unsigned int **query_supported_rates, /* modified at return */
|
|
||||||
bool require_exact_channel_number);
|
bool require_exact_channel_number);
|
||||||
|
|
||||||
/* Opens the explicit ALSA device with a fallback list */
|
/* Opens the explicit ALSA device with a fallback list */
|
||||||
|
|
@ -115,8 +109,6 @@ snd_pcm_t *pa_alsa_open_by_template(
|
||||||
snd_pcm_uframes_t tsched_size,
|
snd_pcm_uframes_t tsched_size,
|
||||||
bool *use_mmap, /* modified at return */
|
bool *use_mmap, /* modified at return */
|
||||||
bool *use_tsched, /* modified at return */
|
bool *use_tsched, /* modified at return */
|
||||||
pa_sample_format_t **query_supported_formats, /* modified at return */
|
|
||||||
unsigned int **query_supported_rates, /* modified at return */
|
|
||||||
bool require_exact_channel_number);
|
bool require_exact_channel_number);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,10 @@ typedef void (*pa_free_cb_t)(void *p);
|
||||||
#define PA_LIKELY(x) (__builtin_expect(!!(x),1))
|
#define PA_LIKELY(x) (__builtin_expect(!!(x),1))
|
||||||
#define PA_UNLIKELY(x) (__builtin_expect(!!(x),0))
|
#define PA_UNLIKELY(x) (__builtin_expect(!!(x),0))
|
||||||
#define PA_PRINTF_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))
|
#define PA_PRINTF_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))
|
||||||
#define PA_UNUSED __attribute__ ((unused))
|
|
||||||
#else
|
#else
|
||||||
#define PA_LIKELY(x) (x)
|
#define PA_LIKELY(x) (x)
|
||||||
#define PA_UNLIKELY(x) (x)
|
#define PA_UNLIKELY(x) (x)
|
||||||
#define PA_PRINTF_FUNC(fmt, arg1)
|
#define PA_PRINTF_FUNC(fmt, arg1)
|
||||||
#define PA_UNUSED
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PA_MIN(a,b) \
|
#define PA_MIN(a,b) \
|
||||||
|
|
@ -98,7 +96,7 @@ typedef enum pa_available {
|
||||||
PA_AVAILABLE_YES = 2,
|
PA_AVAILABLE_YES = 2,
|
||||||
} pa_available_t;
|
} pa_available_t;
|
||||||
|
|
||||||
#define PA_RATE_MAX (48000U*16U)
|
#define PA_RATE_MAX (48000U*8U)
|
||||||
|
|
||||||
typedef enum pa_sample_format {
|
typedef enum pa_sample_format {
|
||||||
PA_SAMPLE_U8, /**< Unsigned 8 Bit PCM */
|
PA_SAMPLE_U8, /**< Unsigned 8 Bit PCM */
|
||||||
|
|
|
||||||
|
|
@ -130,25 +130,13 @@ static inline unsigned pa_idxset_size(pa_idxset*s)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline pa_idxset_item *pa_idxset_search(pa_idxset *s, uint32_t *idx)
|
static inline void *pa_idxset_search(pa_idxset *s, uint32_t *idx)
|
||||||
{
|
{
|
||||||
pa_idxset_item *item;
|
pa_idxset_item *item;
|
||||||
for (item = pa_array_get_unchecked(&s->array, *idx, pa_idxset_item);
|
for (item = pa_array_get_unchecked(&s->array, *idx, pa_idxset_item);
|
||||||
pa_array_check(&s->array, item); item++, (*idx)++) {
|
pa_array_check(&s->array, item); item++, (*idx)++) {
|
||||||
if (item->ptr != NULL)
|
if (item->ptr != NULL)
|
||||||
return item;
|
return item->ptr;
|
||||||
}
|
|
||||||
*idx = PA_IDXSET_INVALID;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline pa_idxset_item *pa_idxset_reverse_search(pa_idxset *s, uint32_t *idx)
|
|
||||||
{
|
|
||||||
pa_idxset_item *item;
|
|
||||||
for (item = pa_array_get_unchecked(&s->array, *idx, pa_idxset_item);
|
|
||||||
pa_array_check(&s->array, item); item--, (*idx)--) {
|
|
||||||
if (item->ptr != NULL)
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
*idx = PA_IDXSET_INVALID;
|
*idx = PA_IDXSET_INVALID;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -156,93 +144,29 @@ static inline pa_idxset_item *pa_idxset_reverse_search(pa_idxset *s, uint32_t *i
|
||||||
|
|
||||||
static inline void *pa_idxset_next(pa_idxset *s, uint32_t *idx)
|
static inline void *pa_idxset_next(pa_idxset *s, uint32_t *idx)
|
||||||
{
|
{
|
||||||
pa_idxset_item *item;
|
|
||||||
(*idx)++;;
|
(*idx)++;;
|
||||||
item = pa_idxset_search(s, idx);
|
return pa_idxset_search(s, idx);
|
||||||
return item ? item->ptr : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void* pa_idxset_first(pa_idxset *s, uint32_t *idx)
|
static inline void* pa_idxset_first(pa_idxset *s, uint32_t *idx)
|
||||||
{
|
{
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
pa_idxset_item *item = pa_idxset_search(s, &i);
|
void *ptr = pa_idxset_search(s, &i);
|
||||||
if (idx)
|
if (idx)
|
||||||
*idx = i;
|
*idx = i;
|
||||||
return item ? item->ptr : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void* pa_idxset_last(pa_idxset *s, uint32_t *idx)
|
|
||||||
{
|
|
||||||
uint32_t i = pa_array_get_len(&s->array, pa_idxset_item) - 1;
|
|
||||||
pa_idxset_item *item = pa_idxset_reverse_search(s, &i);
|
|
||||||
if (idx)
|
|
||||||
*idx = i;
|
|
||||||
return item ? item->ptr : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void* pa_idxset_steal_last(pa_idxset *s, uint32_t *idx)
|
|
||||||
{
|
|
||||||
uint32_t i = pa_array_get_len(&s->array, pa_idxset_item) - 1;
|
|
||||||
void *ptr = NULL;
|
|
||||||
pa_idxset_item *item = pa_idxset_reverse_search(s, &i);
|
|
||||||
if (idx)
|
|
||||||
*idx = i;
|
|
||||||
if (item) {
|
|
||||||
ptr = item->ptr;
|
|
||||||
item->ptr = NULL;
|
|
||||||
pa_array_remove(&s->array, item);
|
|
||||||
}
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void* pa_idxset_get_by_data(pa_idxset*s, const void *p, uint32_t *idx)
|
static inline void* pa_idxset_get_by_data(pa_idxset*s, const void *p, uint32_t *idx)
|
||||||
{
|
{
|
||||||
pa_idxset_item *item = pa_idxset_find(s, p);
|
pa_idxset_item *item = pa_idxset_find(s, p);
|
||||||
if (item == NULL) {
|
if (item == NULL)
|
||||||
if (idx)
|
|
||||||
*idx = PA_IDXSET_INVALID;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
if (idx)
|
if (idx)
|
||||||
*idx = item - (pa_idxset_item*)s->array.data;
|
*idx = item - (pa_idxset_item*)s->array.data;
|
||||||
return item->ptr;
|
return item->ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool pa_idxset_contains(pa_idxset *s, const void *p)
|
|
||||||
{
|
|
||||||
return pa_idxset_get_by_data(s, p, NULL) == p;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool pa_idxset_isdisjoint(pa_idxset *s, pa_idxset *t)
|
|
||||||
{
|
|
||||||
pa_idxset_item *item;
|
|
||||||
pa_array_for_each(item, &s->array) {
|
|
||||||
if (item->ptr && pa_idxset_contains(t, item->ptr))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool pa_idxset_issubset(pa_idxset *s, pa_idxset *t)
|
|
||||||
{
|
|
||||||
pa_idxset_item *item;
|
|
||||||
pa_array_for_each(item, &s->array) {
|
|
||||||
if (item->ptr && !pa_idxset_contains(t, item->ptr))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool pa_idxset_issuperset(pa_idxset *s, pa_idxset *t)
|
|
||||||
{
|
|
||||||
return pa_idxset_issubset(t, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool pa_idxset_equals(pa_idxset *s, pa_idxset *t)
|
|
||||||
{
|
|
||||||
return pa_idxset_issubset(s, t) && pa_idxset_issuperset(s, t);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void* pa_idxset_get_by_index(pa_idxset*s, uint32_t idx)
|
static inline void* pa_idxset_get_by_index(pa_idxset*s, uint32_t idx)
|
||||||
{
|
{
|
||||||
pa_idxset_item *item;
|
pa_idxset_item *item;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue