[pulseaudio-discuss] [PATCH 21/30] sink-input, source-output: Remove pa_sink_input/source_output_new_data_is_passthrough()

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Thu Jan 16 07:02:47 PST 2014


The functions are redundant.
---
 src/pulsecore/sink-input.c    | 22 +++++-----------------
 src/pulsecore/sink-input.h    |  1 -
 src/pulsecore/source-output.c | 20 ++++----------------
 src/pulsecore/source-output.h |  1 -
 4 files changed, 9 insertions(+), 35 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index aea25eb..80c5081 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -136,18 +136,6 @@ void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const
         data->channel_map = *map;
 }
 
-bool pa_sink_input_new_data_is_passthrough(pa_sink_input_new_data *data) {
-    pa_assert(data);
-
-    if (PA_LIKELY(data->format) && PA_UNLIKELY(!pa_format_info_is_pcm(data->format)))
-        return true;
-
-    if (PA_UNLIKELY(data->flags & PA_SINK_INPUT_PASSTHROUGH))
-        return true;
-
-    return false;
-}
-
 void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume) {
     pa_assert(data);
     pa_assert(data->volume_writable);
@@ -439,7 +427,7 @@ int pa_sink_input_new(
         goto fail;
     }
 
-    r = check_passthrough_connection(pa_sink_input_new_data_is_passthrough(data), i->sink);
+    r = check_passthrough_connection(pa_sink_input_is_passthrough(i), i->sink);
     if (r != PA_OK) {
         ret = r;
         goto fail;
@@ -467,7 +455,7 @@ int pa_sink_input_new(
 
     /* Don't restore (or save) stream volume for passthrough streams and
      * prevent attenuation/gain */
-    if (pa_sink_input_new_data_is_passthrough(data)) {
+    if (pa_sink_input_is_passthrough(i)) {
         data->volume_is_set = true;
         pa_cvolume_reset(&data->volume, data->sample_spec.channels);
         data->volume_is_absolute = true;
@@ -534,11 +522,11 @@ int pa_sink_input_new(
            module-suspend-on-idle can resume a sink */
 
         pa_log_info("Trying to change sample rate");
-        if (pa_sink_update_rate(i->sink, data->sample_spec.rate, pa_sink_input_new_data_is_passthrough(data)) >= 0)
+        if (pa_sink_update_rate(i->sink, data->sample_spec.rate, pa_sink_input_is_passthrough(i)) >= 0)
             pa_log_info("Rate changed to %u Hz", i->sink->sample_spec.rate);
     }
 
-    if (pa_sink_input_new_data_is_passthrough(data) &&
+    if (pa_sink_input_is_passthrough(i) &&
         !pa_sample_spec_equal(&data->sample_spec, &i->sink->sample_spec)) {
         /* rate update failed, or other parts of sample spec didn't match */
 
@@ -581,7 +569,7 @@ int pa_sink_input_new(
         !pa_channel_map_equal(&data->channel_map, &i->sink->channel_map)) {
 
         /* Note: for passthrough content we need to adjust the output rate to that of the current sink-input */
-        if (!pa_sink_input_new_data_is_passthrough(data)) /* no resampler for passthrough content */
+        if (!pa_sink_input_is_passthrough(i)) /* no resampler for passthrough content */
             if (!(resampler = pa_resampler_new(
                           core->mempool,
                           &data->sample_spec, &data->channel_map,
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index a773be1..97663a9 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -324,7 +324,6 @@ typedef struct pa_sink_input_new_data {
 pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data);
 void pa_sink_input_new_data_set_sample_spec(pa_sink_input_new_data *data, const pa_sample_spec *spec);
 void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const pa_channel_map *map);
-bool pa_sink_input_new_data_is_passthrough(pa_sink_input_new_data *data);
 void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume);
 void pa_sink_input_new_data_add_volume_factor(pa_sink_input_new_data *data, const char *key, const pa_cvolume *volume_factor);
 void pa_sink_input_new_data_add_volume_factor_sink(pa_sink_input_new_data *data, const char *key, const pa_cvolume *volume_factor);
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 62d421b..6a792ec 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -78,18 +78,6 @@ void pa_source_output_new_data_set_channel_map(pa_source_output_new_data *data,
         data->channel_map = *map;
 }
 
-bool pa_source_output_new_data_is_passthrough(pa_source_output_new_data *data) {
-    pa_assert(data);
-
-    if (PA_LIKELY(data->format) && PA_UNLIKELY(!pa_format_info_is_pcm(data->format)))
-        return true;
-
-    if (PA_UNLIKELY(data->flags & PA_SOURCE_OUTPUT_PASSTHROUGH))
-        return true;
-
-    return false;
-}
-
 void pa_source_output_new_data_set_volume(pa_source_output_new_data *data, const pa_cvolume *volume) {
     pa_assert(data);
     pa_assert(data->volume_writable);
@@ -394,7 +382,7 @@ int pa_source_output_new(
 
     /* Don't restore (or save) stream volume for passthrough streams and
      * prevent attenuation/gain */
-    if (pa_source_output_new_data_is_passthrough(data)) {
+    if (pa_source_output_is_passthrough(o)) {
         data->volume_is_set = true;
         pa_cvolume_reset(&data->volume, data->sample_spec.channels);
         data->volume_is_absolute = true;
@@ -477,11 +465,11 @@ int pa_source_output_new(
            module-suspend-on-idle can resume a source */
 
         pa_log_info("Trying to change sample rate");
-        if (pa_source_update_rate(o->source, data->sample_spec.rate, pa_source_output_new_data_is_passthrough(data)) >= 0)
+        if (pa_source_update_rate(o->source, data->sample_spec.rate, pa_source_output_is_passthrough(o)) >= 0)
             pa_log_info("Rate changed to %u Hz", o->source->sample_spec.rate);
     }
 
-    if (pa_source_output_new_data_is_passthrough(data) &&
+    if (pa_source_output_is_passthrough(o) &&
         !pa_sample_spec_equal(&data->sample_spec, &o->source->sample_spec)) {
         /* rate update failed, or other parts of sample spec didn't match */
 
@@ -523,7 +511,7 @@ int pa_source_output_new(
         !pa_sample_spec_equal(&data->sample_spec, &o->source->sample_spec) ||
         !pa_channel_map_equal(&data->channel_map, &o->source->channel_map)) {
 
-        if (!pa_source_output_new_data_is_passthrough(data)) /* no resampler for passthrough content */
+        if (!pa_source_output_is_passthrough(o)) /* no resampler for passthrough content */
             if (!(resampler = pa_resampler_new(
                         core->mempool,
                         &o->source->sample_spec, &o->source->channel_map,
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index 765209e..a2d4474 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -280,7 +280,6 @@ typedef struct pa_source_output_new_data {
 pa_source_output_new_data* pa_source_output_new_data_init(pa_source_output_new_data *data);
 void pa_source_output_new_data_set_sample_spec(pa_source_output_new_data *data, const pa_sample_spec *spec);
 void pa_source_output_new_data_set_channel_map(pa_source_output_new_data *data, const pa_channel_map *map);
-bool pa_source_output_new_data_is_passthrough(pa_source_output_new_data *data);
 void pa_source_output_new_data_set_volume(pa_source_output_new_data *data, const pa_cvolume *volume);
 void pa_source_output_new_data_apply_volume_factor(pa_source_output_new_data *data, const pa_cvolume *volume_factor);
 void pa_source_output_new_data_apply_volume_factor_source(pa_source_output_new_data *data, const pa_cvolume *volume_factor);
-- 
1.8.3.1



More information about the pulseaudio-discuss mailing list