[pulseaudio-commits] 3 commits - src/modules
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Fri Jul 6 10:39:14 PDT 2012
src/modules/alsa/alsa-mixer.c | 37 ++++++++++++++++-
src/modules/alsa/alsa-mixer.h | 4 -
src/modules/alsa/alsa-sink.c | 14 +-----
src/modules/alsa/alsa-source.c | 15 +-----
src/modules/alsa/mixer/paths/analog-output.conf.common | 3 +
5 files changed, 46 insertions(+), 27 deletions(-)
New commits:
commit 079569753e245393c3ce9ea8923a60fcd9799d34
Author: Jarkko Nikula <jarkko.nikula at bitmer.com>
Date: Thu Mar 22 11:29:12 2012 +0200
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.]
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 8423636..b46508c 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;
@@ -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;
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index 6fe9c32..ef2a02f 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -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);
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 5fe397c..fcd2b0b 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -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;
}
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 2342f40..d27cd9e 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -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;
}
commit fbb13a0dc6aca2c2e3bb746c267c717a11d6f2f0
Author: Jarkko Nikula <jarkko.nikula at bitmer.com>
Date: Thu Mar 22 11:29:11 2012 +0200
alsa: move pa_alsa_setting_select close to pa_alsa_path_select
Move pa_alsa_setting_select call just after the pa_alsa_path_select in
[sink | source]_set_port_cb functions as there is no dependency to volume
calculations that are done between these two calls. Idea here is to make
possible to merge these two functions since they are called together from
other places too.
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index a7e543e..5fe397c 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1463,11 +1463,11 @@ static int sink_set_port_cb(pa_sink *s, pa_device_port *p) {
pa_assert_se(u->mixer_path = data->path);
pa_alsa_path_select(u->mixer_path, u->mixer_handle, s->muted);
- mixer_volume_init(u);
-
if (data->setting)
pa_alsa_setting_select(data->setting, u->mixer_handle);
+ mixer_volume_init(u);
+
if (s->set_mute)
s->set_mute(s);
if (s->flags & PA_SINK_DEFERRED_VOLUME) {
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 616215e..2342f40 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1366,11 +1366,11 @@ static int source_set_port_cb(pa_source *s, pa_device_port *p) {
pa_assert_se(u->mixer_path = data->path);
pa_alsa_path_select(u->mixer_path, u->mixer_handle, s->muted);
- mixer_volume_init(u);
-
if (data->setting)
pa_alsa_setting_select(data->setting, u->mixer_handle);
+ mixer_volume_init(u);
+
if (s->set_mute)
s->set_mute(s);
if (s->flags & PA_SOURCE_DEFERRED_VOLUME) {
commit 8417cac4f6c8036d6ce65efa3df6ae8477f8e3e2
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date: Thu Mar 22 11:29:10 2012 +0200
alsa-mixer: Implement a new path option: "mute-during-activation".
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index ee59dea..8423636 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -1196,7 +1196,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) {
+int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m, bool device_is_muted) {
pa_alsa_element *e;
int r = 0;
@@ -1206,6 +1206,19 @@ int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m) {
pa_log_debug("Activating path %s", p->name);
pa_alsa_path_dump(p);
+ /* First turn on hw mute if available, to avoid noise
+ * when setting the mixer controls. */
+ if (p->mute_during_activation) {
+ PA_LLIST_FOREACH(e, p->elements) {
+ if (e->switch_use == PA_ALSA_SWITCH_MUTE)
+ /* If the muting fails here, that's not a critical problem for
+ * selecting a path, so we ignore the return value.
+ * element_set_switch() will print a warning anyway, so this
+ * won't be a silent failure either. */
+ (void) element_set_switch(e, m, FALSE);
+ }
+ }
+
PA_LLIST_FOREACH(e, p->elements) {
switch (e->switch_use) {
@@ -1244,6 +1257,16 @@ int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m) {
return -1;
}
+ /* Finally restore hw mute to the device mute status. */
+ if (p->mute_during_activation) {
+ PA_LLIST_FOREACH(e, p->elements) {
+ if (e->switch_use == PA_ALSA_SWITCH_MUTE) {
+ if (element_set_switch(e, m, !device_is_muted) < 0)
+ return -1;
+ }
+ }
+ }
+
return 0;
}
@@ -2353,12 +2376,14 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa
char *fn;
int r;
const char *n;
+ bool mute_during_activation = false;
pa_config_item items[] = {
/* [General] */
{ "priority", pa_config_parse_unsigned, NULL, "General" },
{ "description", pa_config_parse_string, NULL, "General" },
{ "name", pa_config_parse_string, NULL, "General" },
+ { "mute-during-activation", pa_config_parse_bool, NULL, "General" },
/* [Option ...] */
{ "priority", option_parse_priority, NULL, NULL },
@@ -2395,6 +2420,7 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa
items[0].data = &p->priority;
items[1].data = &p->description;
items[2].data = &p->name;
+ items[3].data = &mute_during_activation;
if (!paths_dir)
paths_dir = get_default_paths_dir();
@@ -2407,6 +2433,8 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa
if (r < 0)
goto fail;
+ p->mute_during_activation = mute_during_activation;
+
if (path_verify(p) < 0)
goto fail;
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index 111dfaa..6fe9c32 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -188,6 +188,7 @@ struct pa_alsa_path {
pa_bool_t has_mute:1;
pa_bool_t has_volume:1;
pa_bool_t has_dB:1;
+ bool mute_during_activation:1;
/* These two are used during probing only */
pa_bool_t has_req_any:1;
pa_bool_t req_any_present:1;
@@ -229,7 +230,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);
+int pa_alsa_path_select(pa_alsa_path *p, 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);
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 472d66a..a7e543e 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1461,7 +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);
+ pa_alsa_path_select(u->mixer_path, u->mixer_handle, s->muted);
mixer_volume_init(u);
@@ -1905,7 +1905,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);
+ pa_alsa_path_select(data->path, u->mixer_handle, u->sink->muted);
if (data->setting)
pa_alsa_setting_select(data->setting, u->mixer_handle);
@@ -1918,7 +1918,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);
+ pa_alsa_path_select(u->mixer_path, u->mixer_handle, u->sink->muted);
if (u->mixer_path->settings)
pa_alsa_setting_select(u->mixer_path->settings, u->mixer_handle);
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index c27bbc2..616215e 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1364,7 +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);
+ pa_alsa_path_select(u->mixer_path, u->mixer_handle, s->muted);
mixer_volume_init(u);
@@ -1642,7 +1642,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);
+ pa_alsa_path_select(data->path, u->mixer_handle, u->source->muted);
if (data->setting)
pa_alsa_setting_select(data->setting, u->mixer_handle);
@@ -1655,7 +1655,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);
+ 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);
diff --git a/src/modules/alsa/mixer/paths/analog-output.conf.common b/src/modules/alsa/mixer/paths/analog-output.conf.common
index e69615d..01835fb 100644
--- a/src/modules/alsa/mixer/paths/analog-output.conf.common
+++ b/src/modules/alsa/mixer/paths/analog-output.conf.common
@@ -56,6 +56,9 @@
; [General]
; priority = ... # Priority for this path
; description = ...
+; mute-during-activation = yes | no # If this path supports hardware mute, should the hw mute be used while activating this
+; # path? In some cases this can reduce extra noises during port switching, while in other
+; # cases this can increase such noises. Default: no.
;
; [Properties] # Property list for this path. The list is merged into the port property list.
; <key> = <value> # Each property is defined on its own line.
More information about the pulseaudio-commits
mailing list