[pulseaudio-discuss] [PATCH 7/8] devices: Send a SYNC volumes message on port change to ensure volumes are propigated to the underlying device.

Colin Guthrie colin at mageia.org
Thu Jul 7 02:55:56 PDT 2011


Also add some additional debug for volume changes.
---
 src/pulsecore/sink.c   |    9 ++++++++-
 src/pulsecore/source.c |    9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index df5cd78..18be1db 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2958,6 +2958,7 @@ int pa_sink_set_port(pa_sink *s, const char *name, pa_bool_t save) {
     s->active_port = port;
     s->save_port = save;
 
+    pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_VOLUME_SYNCED, NULL, 0, NULL) == 0);
     pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_PORT_CHANGED], s);
 
     return 0;
@@ -3162,7 +3163,13 @@ void pa_sink_volume_change_push(pa_sink *s) {
     pa_sw_cvolume_divide(&nc->hw_volume, &s->real_volume, &s->soft_volume);
 
     if (!s->thread_info.volume_changes && pa_cvolume_equal(&nc->hw_volume, &s->thread_info.current_hw_volume)) {
-        pa_log_debug("Volume not changing");
+        char pcnt[PA_CVOLUME_SNPRINT_MAX];
+        char db[PA_SW_CVOLUME_SNPRINT_DB_MAX];
+
+        pa_log_debug("Volume not changing: %s (%s dB)",
+            pa_cvolume_snprint(pcnt, sizeof(pcnt), &nc->hw_volume),
+            pa_sw_cvolume_snprint_dB(db, sizeof(db), &nc->hw_volume));
+
         pa_sink_volume_change_free(nc);
         return;
     }
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index e74dcc2..30bf08e 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -2303,6 +2303,7 @@ int pa_source_set_port(pa_source *s, const char *name, pa_bool_t save) {
     s->active_port = port;
     s->save_port = save;
 
+    pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_SET_VOLUME_SYNCED, NULL, 0, NULL) == 0);
     pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_PORT_CHANGED], s);
 
     return 0;
@@ -2346,7 +2347,13 @@ void pa_source_volume_change_push(pa_source *s) {
     pa_sw_cvolume_divide(&nc->hw_volume, &s->real_volume, &s->soft_volume);
 
     if (!s->thread_info.volume_changes && pa_cvolume_equal(&nc->hw_volume, &s->thread_info.current_hw_volume)) {
-        pa_log_debug("Volume not changing");
+        char pcnt[PA_CVOLUME_SNPRINT_MAX];
+        char db[PA_SW_CVOLUME_SNPRINT_DB_MAX];
+
+        pa_log_debug("Volume not changing: %s (%s dB)",
+            pa_cvolume_snprint(pcnt, sizeof(pcnt), &nc->hw_volume),
+            pa_sw_cvolume_snprint_dB(db, sizeof(db), &nc->hw_volume));
+
         pa_source_volume_change_free(nc);
         return;
     }
-- 
1.7.6



More information about the pulseaudio-discuss mailing list