[PATCH 1/3] alsa: Don't access pa_sink/source_new_data after done() has been called

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This change doesn't affect behaviour, because accessing boolean fields
in the new data was safe even after the done() call, but it was still
bad style.
---
 src/modules/alsa/alsa-sink.c   | 10 +++++++---
 src/modules/alsa/alsa-source.c | 10 +++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index e256bbd..4ab3a22 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -2013,6 +2013,8 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     size_t frame_size;
     bool use_mmap = true, b, use_tsched = true, d, ignore_dB = false, namereg_fail = false, deferred_volume = false, set_formats = false, fixed_latency_range = false;
     pa_sink_new_data data;
+    bool volume_is_set;
+    bool mute_is_set;
     pa_alsa_profile_set *profile_set = NULL;
     void *state = NULL;
 
@@ -2294,6 +2296,8 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
 
     u->sink = pa_sink_new(m->core, &data, PA_SINK_HARDWARE | PA_SINK_LATENCY | (u->use_tsched ? PA_SINK_DYNAMIC_LATENCY : 0) |
                           (set_formats ? PA_SINK_SET_FORMATS : 0));
+    volume_is_set = data.volume_is_set;
+    mute_is_set = data.muted_is_set;
     pa_sink_new_data_done(&data);
 
     if (!u->sink) {
@@ -2377,7 +2381,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     thread_name = NULL;
 
     /* Get initial mixer settings */
-    if (data.volume_is_set) {
+    if (volume_is_set) {
         if (u->sink->set_volume)
             u->sink->set_volume(u->sink);
     } else {
@@ -2385,7 +2389,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
             u->sink->get_volume(u->sink);
     }
 
-    if (data.muted_is_set) {
+    if (mute_is_set) {
         if (u->sink->set_mute)
             u->sink->set_mute(u->sink);
     } else {
@@ -2397,7 +2401,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
         }
     }
 
-    if ((data.volume_is_set || data.muted_is_set) && u->sink->write_volume)
+    if ((volume_is_set || mute_is_set) && u->sink->write_volume)
         u->sink->write_volume(u->sink);
 
     if (set_formats) {
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 111c517..6d29942 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1730,6 +1730,8 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
     size_t frame_size;
     bool use_mmap = true, b, use_tsched = true, d, ignore_dB = false, namereg_fail = false, deferred_volume = false, fixed_latency_range = false;
     pa_source_new_data data;
+    bool volume_is_set;
+    bool mute_is_set;
     pa_alsa_profile_set *profile_set = NULL;
     void *state = NULL;
 
@@ -1999,6 +2001,8 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
         pa_alsa_add_ports(&data, u->mixer_path_set, card);
 
     u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY|(u->use_tsched ? PA_SOURCE_DYNAMIC_LATENCY : 0));
+    volume_is_set = data.volume_is_set;
+    mute_is_set = data.muted_is_set;
     pa_source_new_data_done(&data);
 
     if (!u->source) {
@@ -2075,7 +2079,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
     thread_name = NULL;
 
     /* Get initial mixer settings */
-    if (data.volume_is_set) {
+    if (volume_is_set) {
         if (u->source->set_volume)
             u->source->set_volume(u->source);
     } else {
@@ -2083,7 +2087,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
             u->source->get_volume(u->source);
     }
 
-    if (data.muted_is_set) {
+    if (mute_is_set) {
         if (u->source->set_mute)
             u->source->set_mute(u->source);
     } else {
@@ -2095,7 +2099,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
         }
     }
 
-    if ((data.volume_is_set || data.muted_is_set) && u->source->write_volume)
+    if ((volume_is_set || mute_is_set) && u->source->write_volume)
         u->source->write_volume(u->source);
 
     pa_source_put(u->source);
-- 
1.9.3



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux