summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2012-11-15 15:51:52 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2012-11-16 23:16:04 +0530
commitcd1102cce01e47645ed03ddf46a0a8b80d65fc9e (patch)
treeb3bb0b90bca000ca907df05522561c146343ef76
parent0a0189d9727b4be636829c854c8a0d98a99f8d61 (diff)
sink, source: Prevent unnecessary rate update attempts
We don't need to try a rate update if the desired sample rate is the same as the one the sink or source is already using.
-rw-r--r--src/pulsecore/sink-input.c11
-rw-r--r--src/pulsecore/sink.c3
-rw-r--r--src/pulsecore/source-output.c11
-rw-r--r--src/pulsecore/source.c3
4 files changed, 10 insertions, 18 deletions
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 7a7575a9..a5edd21c 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -371,10 +371,7 @@ int pa_sink_input_new(
pa_log_info("Trying to change sample rate");
if (pa_sink_update_rate(data->sink, data->sample_spec.rate, pa_sink_input_new_data_is_passthrough(data)) == TRUE)
- pa_log_info("Rate changed to %u Hz",
- data->sink->sample_spec.rate);
- else
- pa_log_info("Resampling enabled to %u Hz", data->sink->sample_spec.rate);
+ pa_log_info("Rate changed to %u Hz", data->sink->sample_spec.rate);
}
/* Due to the fixing of the sample spec the volume might not match anymore */
@@ -1662,11 +1659,7 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
pa_log_info("Trying to change sample rate");
if (pa_sink_update_rate(dest, i->sample_spec.rate, pa_sink_input_is_passthrough(i)) == TRUE)
- pa_log_info("Rate changed to %u Hz",
- dest->sample_spec.rate);
- else
- pa_log_info("Resampling enabled to %u Hz",
- dest->sample_spec.rate);
+ pa_log_info("Rate changed to %u Hz", dest->sample_spec.rate);
}
if (i->moving)
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 9958be64..1ccceb4a 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1392,6 +1392,9 @@ pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough)
desired_rate = rate; /* use stream sampling rate, discard default/alternate settings */
}
+ if (desired_rate == s->sample_spec.rate)
+ return FALSE;
+
if (!passthrough && pa_sink_used_by(s) > 0)
return FALSE;
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 1297ec75..85045e75 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -350,10 +350,7 @@ int pa_source_output_new(
pa_log_info("Trying to change sample rate");
if (pa_source_update_rate(data->source, data->sample_spec.rate, pa_source_output_new_data_is_passthrough(data)) == TRUE)
- pa_log_info("Rate changed to %u Hz",
- data->source->sample_spec.rate);
- else
- pa_log_info("Resampling enabled to %u Hz", data->source->sample_spec.rate);
+ pa_log_info("Rate changed to %u Hz", data->source->sample_spec.rate);
}
if (data->resample_method == PA_RESAMPLER_INVALID)
@@ -1425,11 +1422,7 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t
pa_log_info("Trying to change sample rate");
if (pa_source_update_rate(dest, o->sample_spec.rate, pa_source_output_is_passthrough(o)) == TRUE)
- pa_log_info("Rate changed to %u Hz",
- dest->sample_spec.rate);
- else
- pa_log_info("Resampling enabled to %u Hz",
- dest->sample_spec.rate);
+ pa_log_info("Rate changed to %u Hz", dest->sample_spec.rate);
}
if (o->moving)
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 7af86f54..e9c36698 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -1000,6 +1000,9 @@ pa_bool_t pa_source_update_rate(pa_source *s, uint32_t rate, pa_bool_t passthrou
desired_rate = rate; /* use stream sampling rate, discard default/alternate settings */
}
+ if (desired_rate == s->sample_spec.rate)
+ return FALSE;
+
if (!passthrough && pa_source_used_by(s) > 0)
return FALSE;