[pulseaudio-discuss] [PATCH 3/3] alsa: Merge pa_alsa_setting_select with pa_alsa_path_select
Tanu Kaskinen
tanu.kaskinen at digia.com
Thu Mar 22 02:29:12 PDT 2012
From: Jarkko Nikula <jarkko.nikula at bitmer.com>
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.]
---
src/modules/alsa/alsa-mixer.c | 9 +++++++--
src/modules/alsa/alsa-mixer.h | 3 +--
src/modules/alsa/alsa-sink.c | 14 +++-----------
src/modules/alsa/alsa-source.c | 15 +++------------
4 files changed, 14 insertions(+), 27 deletions(-)
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index c325367..3d50e41 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -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;
@@ -1195,7 +1197,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, pa_bool_t device_is_muted) {
+int pa_alsa_path_select(pa_alsa_path *p, pa_alsa_setting *s, snd_mixer_t *m, pa_bool_t device_is_muted) {
pa_alsa_element *e;
int r = 0;
@@ -1256,6 +1258,9 @@ int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m, pa_bool_t device_is_mut
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) {
@@ -2285,7 +2290,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;
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index dbcc887..cc2dfc3 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -214,7 +214,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);
@@ -229,7 +228,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, pa_bool_t device_is_muted);
+int pa_alsa_path_select(pa_alsa_path *p, pa_alsa_setting *s, snd_mixer_t *m, pa_bool_t 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);
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index fb045d6..6e1d21c 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1458,10 +1458,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);
@@ -1897,10 +1894,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 {
@@ -1910,10 +1904,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;
}
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 20db467..cfe3634 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1361,10 +1361,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);
@@ -1634,10 +1631,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 {
@@ -1647,10 +1641,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;
}
--
1.7.8
More information about the pulseaudio-discuss
mailing list