mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
alsa: Merge pa_alsa_setting_select with pa_alsa_path_select
As these functions are called together and are related, we might merge them and call setting_select from pa_alsa_path_select by passing optional pa_alsa_setting argument. Make also the setting_select static as it is not called outside of alsa-mixer.c after this change. [Additional note from Tanu Kaskinen: this change improves the mute-during-activation feature, because now the mixer changes related to selecting the setting happen while the hw is muted.]
This commit is contained in:
parent
fbb13a0dc6
commit
079569753e
4 changed files with 14 additions and 27 deletions
|
|
@ -50,6 +50,8 @@
|
|||
#include "alsa-mixer.h"
|
||||
#include "alsa-util.h"
|
||||
|
||||
static int setting_select(pa_alsa_setting *s, snd_mixer_t *m);
|
||||
|
||||
struct description_map {
|
||||
const char *name;
|
||||
const char *description;
|
||||
|
|
@ -1196,7 +1198,7 @@ static int element_set_constant_volume(pa_alsa_element *e, snd_mixer_t *m) {
|
|||
return r;
|
||||
}
|
||||
|
||||
int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m, bool device_is_muted) {
|
||||
int pa_alsa_path_select(pa_alsa_path *p, pa_alsa_setting *s, snd_mixer_t *m, bool device_is_muted) {
|
||||
pa_alsa_element *e;
|
||||
int r = 0;
|
||||
|
||||
|
|
@ -1257,6 +1259,9 @@ int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m, bool device_is_muted) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (s)
|
||||
setting_select(s, m);
|
||||
|
||||
/* Finally restore hw mute to the device mute status. */
|
||||
if (p->mute_during_activation) {
|
||||
PA_LLIST_FOREACH(e, p->elements) {
|
||||
|
|
@ -2228,7 +2233,7 @@ static int element_set_option(pa_alsa_element *e, snd_mixer_t *m, int alsa_idx)
|
|||
return r;
|
||||
}
|
||||
|
||||
int pa_alsa_setting_select(pa_alsa_setting *s, snd_mixer_t *m) {
|
||||
static int setting_select(pa_alsa_setting *s, snd_mixer_t *m) {
|
||||
pa_alsa_option *o;
|
||||
uint32_t idx;
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,6 @@ struct pa_alsa_path_set {
|
|||
pa_alsa_direction_t direction;
|
||||
};
|
||||
|
||||
int pa_alsa_setting_select(pa_alsa_setting *s, snd_mixer_t *m);
|
||||
void pa_alsa_setting_dump(pa_alsa_setting *s);
|
||||
|
||||
void pa_alsa_option_dump(pa_alsa_option *o);
|
||||
|
|
@ -230,7 +229,7 @@ int pa_alsa_path_get_volume(pa_alsa_path *p, snd_mixer_t *m, const pa_channel_ma
|
|||
int pa_alsa_path_get_mute(pa_alsa_path *path, snd_mixer_t *m, pa_bool_t *muted);
|
||||
int pa_alsa_path_set_volume(pa_alsa_path *path, snd_mixer_t *m, const pa_channel_map *cm, pa_cvolume *v, pa_bool_t deferred_volume, pa_bool_t write_to_hw);
|
||||
int pa_alsa_path_set_mute(pa_alsa_path *path, snd_mixer_t *m, pa_bool_t muted);
|
||||
int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m, bool device_is_muted);
|
||||
int pa_alsa_path_select(pa_alsa_path *p, pa_alsa_setting *s, snd_mixer_t *m, bool device_is_muted);
|
||||
void pa_alsa_path_set_callback(pa_alsa_path *p, snd_mixer_t *m, snd_mixer_elem_callback_t cb, void *userdata);
|
||||
void pa_alsa_path_free(pa_alsa_path *p);
|
||||
|
||||
|
|
|
|||
|
|
@ -1461,10 +1461,7 @@ static int sink_set_port_cb(pa_sink *s, pa_device_port *p) {
|
|||
data = PA_DEVICE_PORT_DATA(p);
|
||||
|
||||
pa_assert_se(u->mixer_path = data->path);
|
||||
pa_alsa_path_select(u->mixer_path, u->mixer_handle, s->muted);
|
||||
|
||||
if (data->setting)
|
||||
pa_alsa_setting_select(data->setting, u->mixer_handle);
|
||||
pa_alsa_path_select(u->mixer_path, data->setting, u->mixer_handle, s->muted);
|
||||
|
||||
mixer_volume_init(u);
|
||||
|
||||
|
|
@ -1905,10 +1902,7 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
|
|||
data = PA_DEVICE_PORT_DATA(u->sink->active_port);
|
||||
u->mixer_path = data->path;
|
||||
|
||||
pa_alsa_path_select(data->path, u->mixer_handle, u->sink->muted);
|
||||
|
||||
if (data->setting)
|
||||
pa_alsa_setting_select(data->setting, u->mixer_handle);
|
||||
pa_alsa_path_select(data->path, data->setting, u->mixer_handle, u->sink->muted);
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -1918,10 +1912,8 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
|
|||
if (u->mixer_path) {
|
||||
/* Hmm, we have only a single path, then let's activate it */
|
||||
|
||||
pa_alsa_path_select(u->mixer_path, u->mixer_handle, u->sink->muted);
|
||||
pa_alsa_path_select(u->mixer_path, u->mixer_path->settings, u->mixer_handle, u->sink->muted);
|
||||
|
||||
if (u->mixer_path->settings)
|
||||
pa_alsa_setting_select(u->mixer_path->settings, u->mixer_handle);
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1364,10 +1364,7 @@ static int source_set_port_cb(pa_source *s, pa_device_port *p) {
|
|||
data = PA_DEVICE_PORT_DATA(p);
|
||||
|
||||
pa_assert_se(u->mixer_path = data->path);
|
||||
pa_alsa_path_select(u->mixer_path, u->mixer_handle, s->muted);
|
||||
|
||||
if (data->setting)
|
||||
pa_alsa_setting_select(data->setting, u->mixer_handle);
|
||||
pa_alsa_path_select(u->mixer_path, data->setting, u->mixer_handle, s->muted);
|
||||
|
||||
mixer_volume_init(u);
|
||||
|
||||
|
|
@ -1642,10 +1639,7 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
|
|||
data = PA_DEVICE_PORT_DATA(u->source->active_port);
|
||||
u->mixer_path = data->path;
|
||||
|
||||
pa_alsa_path_select(data->path, u->mixer_handle, u->source->muted);
|
||||
|
||||
if (data->setting)
|
||||
pa_alsa_setting_select(data->setting, u->mixer_handle);
|
||||
pa_alsa_path_select(data->path, data->setting, u->mixer_handle, u->source->muted);
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -1655,10 +1649,7 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
|
|||
if (u->mixer_path) {
|
||||
/* Hmm, we have only a single path, then let's activate it */
|
||||
|
||||
pa_alsa_path_select(u->mixer_path, u->mixer_handle, u->source->muted);
|
||||
|
||||
if (u->mixer_path->settings)
|
||||
pa_alsa_setting_select(u->mixer_path->settings, u->mixer_handle);
|
||||
pa_alsa_path_select(u->mixer_path, u->mixer_path->settings, u->mixer_handle, u->source->muted);
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue