[pulseaudio-discuss] [PATCH RFCv3 51/51] alsa: Remove redundant sample_spec parameter to reset_watermark() function

Peter Meerwald pmeerw at pmeerw.net
Tue Nov 4 15:26:46 PST 2014


From: Peter Meerwald <p.meerwald at bct-electronic.com>

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/modules/alsa/alsa-sink.c   | 24 +++++++++++++-----------
 src/modules/alsa/alsa-source.c | 24 +++++++++++++-----------
 2 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index a637462..0fb9457 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1020,16 +1020,18 @@ static int update_sw_params(struct userdata *u) {
 }
 
 /* Called from IO Context on unsuspend or from main thread when creating sink */
-static void reset_watermark(struct userdata *u, size_t tsched_watermark, pa_sample_spec *ss,
+static void reset_watermark(struct userdata *u, size_t tsched_watermark,
                             bool in_thread) {
+    pa_sample_spec *ss = &u->sink->sample_spec;
+
     u->tsched_watermark = pa_usec_to_bytes_round_up(pa_bytes_to_usec_round_up(tsched_watermark, ss),
-                                                    &u->sink->sample_spec);
+                                                    ss);
 
-    u->watermark_inc_step = PA_USEC_TO_BYTES(TSCHED_WATERMARK_INC_STEP_USEC, &u->sink->sample_spec);
-    u->watermark_dec_step = PA_USEC_TO_BYTES(TSCHED_WATERMARK_DEC_STEP_USEC, &u->sink->sample_spec);
+    u->watermark_inc_step = PA_USEC_TO_BYTES(TSCHED_WATERMARK_INC_STEP_USEC, ss);
+    u->watermark_dec_step = PA_USEC_TO_BYTES(TSCHED_WATERMARK_DEC_STEP_USEC, ss);
 
-    u->watermark_inc_threshold = pa_usec_to_bytes_round_up(TSCHED_WATERMARK_INC_THRESHOLD_USEC, &u->sink->sample_spec);
-    u->watermark_dec_threshold = pa_usec_to_bytes_round_up(TSCHED_WATERMARK_DEC_THRESHOLD_USEC, &u->sink->sample_spec);
+    u->watermark_inc_threshold = pa_usec_to_bytes_round_up(TSCHED_WATERMARK_INC_THRESHOLD_USEC, ss);
+    u->watermark_dec_threshold = pa_usec_to_bytes_round_up(TSCHED_WATERMARK_DEC_THRESHOLD_USEC, ss);
 
     fix_min_sleep_wakeup(u);
     fix_tsched_watermark(u);
@@ -1043,9 +1045,9 @@ static void reset_watermark(struct userdata *u, size_t tsched_watermark, pa_samp
                                   0,
                                   PA_BYTES_TO_USEC(u->hwbuf_size, ss));
 
-        /* work-around assert in pa_sink_set_latency_within_thead,
-           keep track of min_latency and reuse it when
-           this routine is called from IO context */
+        /* Work-around assert in pa_sink_set_latency_within_thead,
+         * keep track of min_latency and reuse it when
+         * this routine is called from IO context */
         u->min_latency_ref = u->sink->thread_info.min_latency;
     }
 
@@ -1128,7 +1130,7 @@ static int unsuspend(struct userdata *u) {
 
     /* reset the watermark to the value defined when sink was created */
     if (u->use_tsched)
-        reset_watermark(u, u->tsched_watermark_ref, &u->sink->sample_spec, true);
+        reset_watermark(u, u->tsched_watermark_ref, true);
 
     pa_log_info("Resumed successfully...");
 
@@ -2354,7 +2356,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
 
     if (u->use_tsched) {
         u->tsched_watermark_ref = tsched_watermark;
-        reset_watermark(u, u->tsched_watermark_ref, &ss, false);
+        reset_watermark(u, u->tsched_watermark_ref, false);
     } else
         pa_sink_set_fixed_latency(u->sink, PA_BYTES_TO_USEC(u->hwbuf_size, &ss));
 
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 8a027b0..8c5788b 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -913,16 +913,18 @@ static int update_sw_params(struct userdata *u) {
 }
 
 /* Called from IO Context on unsuspend or from main thread when creating source */
-static void reset_watermark(struct userdata *u, size_t tsched_watermark, pa_sample_spec *ss,
+static void reset_watermark(struct userdata *u, size_t tsched_watermark,
                             bool in_thread) {
+    pa_sample_spec *ss = &u->source->sample_spec;
+
     u->tsched_watermark = pa_usec_to_bytes_round_up(pa_bytes_to_usec_round_up(tsched_watermark, ss),
-                                                    &u->source->sample_spec);
+                                                    ss);
 
-    u->watermark_inc_step = PA_USEC_TO_BYTES(TSCHED_WATERMARK_INC_STEP_USEC, &u->source->sample_spec);
-    u->watermark_dec_step = PA_USEC_TO_BYTES(TSCHED_WATERMARK_DEC_STEP_USEC, &u->source->sample_spec);
+    u->watermark_inc_step = PA_USEC_TO_BYTES(TSCHED_WATERMARK_INC_STEP_USEC, ss);
+    u->watermark_dec_step = PA_USEC_TO_BYTES(TSCHED_WATERMARK_DEC_STEP_USEC, ss);
 
-    u->watermark_inc_threshold = pa_usec_to_bytes_round_up(TSCHED_WATERMARK_INC_THRESHOLD_USEC, &u->source->sample_spec);
-    u->watermark_dec_threshold = pa_usec_to_bytes_round_up(TSCHED_WATERMARK_DEC_THRESHOLD_USEC, &u->source->sample_spec);
+    u->watermark_inc_threshold = pa_usec_to_bytes_round_up(TSCHED_WATERMARK_INC_THRESHOLD_USEC, ss);
+    u->watermark_dec_threshold = pa_usec_to_bytes_round_up(TSCHED_WATERMARK_DEC_THRESHOLD_USEC, ss);
 
     fix_min_sleep_wakeup(u);
     fix_tsched_watermark(u);
@@ -936,9 +938,9 @@ static void reset_watermark(struct userdata *u, size_t tsched_watermark, pa_samp
                                     0,
                                     PA_BYTES_TO_USEC(u->hwbuf_size, ss));
 
-        /* work-around assert in pa_source_set_latency_within_thead,
-           keep track of min_latency and reuse it when
-           this routine is called from IO context */
+        /* Work-around assert in pa_source_set_latency_within_thead,
+         * keep track of min_latency and reuse it when
+         * this routine is called from IO context */
         u->min_latency_ref = u->source->thread_info.min_latency;
     }
 
@@ -1013,7 +1015,7 @@ static int unsuspend(struct userdata *u) {
 
     /* reset the watermark to the value defined when source was created */
     if (u->use_tsched)
-        reset_watermark(u, u->tsched_watermark_ref, &u->source->sample_spec, true);
+        reset_watermark(u, u->tsched_watermark_ref, true);
 
     pa_log_info("Resumed successfully...");
 
@@ -2051,7 +2053,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
 
     if (u->use_tsched) {
         u->tsched_watermark_ref = tsched_watermark;
-        reset_watermark(u, u->tsched_watermark_ref, &ss, false);
+        reset_watermark(u, u->tsched_watermark_ref, false);
     }
     else
         pa_source_set_fixed_latency(u->source, PA_BYTES_TO_USEC(u->hwbuf_size, &ss));
-- 
1.9.1



More information about the pulseaudio-discuss mailing list