sink, source: Drop return value from reconfigure function

This wasn't actually used anywhere.
This commit is contained in:
Arun Raghavan 2022-01-27 21:57:48 -05:00
parent 3de9f445fa
commit d666f44fa4
4 changed files with 21 additions and 26 deletions

View file

@ -1494,8 +1494,7 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
}
/* Called from main thread */
int pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, pa_channel_map *map, bool passthrough) {
int ret = -1;
void pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, pa_channel_map *map, bool passthrough) {
pa_sample_spec desired_spec;
pa_sample_format_t default_format = s->default_sample_spec.format;
uint32_t default_rate = s->default_sample_spec.rate;
@ -1516,34 +1515,34 @@ int pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, pa_channel_map *map, b
pa_assert(map == NULL || pa_channel_map_valid(map));
if (!restore && pa_sample_spec_equal(spec, &s->sample_spec))
return 0;
return;
if (restore && !pa_sample_spec_valid(&s->saved_spec)) {
/* If we were asked to restore and nothing was saved, this is not an
* error -- it means that no reconfiguration was required in the
* "entry" phase, so none is required in the "exit" phase either.
*/
return 0;
return;
}
if (!s->reconfigure)
return -1;
return;
if (PA_UNLIKELY(default_rate == alternate_rate && !passthrough && !restore && !avoid_resampling && !avoid_processing)) {
pa_log_debug("Default and alternate sample rates are the same, so there is no point in switching.");
return -1;
return;
}
if (PA_SINK_IS_RUNNING(s->state)) {
pa_log_info("Cannot update sample spec, SINK_IS_RUNNING, will keep using %s, %u ch and %u Hz",
pa_sample_format_to_string(s->sample_spec.format), s->sample_spec.channels, s->sample_spec.rate);
return -1;
return;
}
if (s->monitor_source) {
if (PA_SOURCE_IS_RUNNING(s->monitor_source->state) == true) {
pa_log_info("Cannot update sample spec, monitor source is RUNNING");
return -1;
return;
}
}
@ -1608,10 +1607,10 @@ int pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, pa_channel_map *map, b
/* We don't expect to change only the channel map, so we don't check that */
if (pa_sample_spec_equal(&desired_spec, &s->sample_spec) && passthrough == pa_sink_is_passthrough(s))
return 0;
return;
if (!passthrough && pa_sink_used_by(s) > 0)
return -1;
return;
pa_log_debug("Suspending sink %s due to changing format, desired format = %s rate = %u, channels = %u",
s->name, pa_sample_format_to_string(desired_spec.format), desired_spec.rate, desired_spec.channels);
@ -1685,8 +1684,6 @@ int pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, pa_channel_map *map, b
}
pa_sink_suspend(s, false, PA_SUSPEND_INTERNAL);
return ret;
}
/* Called from main thread */

View file

@ -456,7 +456,7 @@ unsigned pa_device_init_priority(pa_proplist *p);
/**** May be called by everyone, from main context */
int pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, pa_channel_map *map, bool passthrough);
void pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, pa_channel_map *map, bool passthrough);
void pa_sink_set_port_latency_offset(pa_sink *s, int64_t offset);
/* The returned value is supposed to be in the time domain of the sound card! */

View file

@ -1059,7 +1059,7 @@ void pa_source_post_direct(pa_source*s, pa_source_output *o, const pa_memchunk *
}
/* Called from main thread */
int pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, pa_channel_map *map, bool passthrough) {
void pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, pa_channel_map *map, bool passthrough) {
int ret;
pa_sample_spec desired_spec;
pa_sample_format_t default_format = s->default_sample_spec.format;
@ -1080,28 +1080,28 @@ int pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, pa_channel_map *ma
if (!restore && pa_sample_spec_equal(spec, &s->sample_spec))
return 0;
return;
if (restore && !pa_sample_spec_valid(&s->saved_spec)) {
/* If we were asked to restore and nothing was saved, this is not an
* error -- it means that no reconfiguration was required in the
* "entry" phase, so none is required in the "exit" phase either.
*/
return 0;
return;
}
if (!s->reconfigure && !s->monitor_of)
return -1;
return;
if (PA_UNLIKELY(default_rate == alternate_rate && !passthrough && !restore && !avoid_resampling && !avoid_processing)) {
pa_log_debug("Default and alternate sample rates are the same, so there is no point in switching.");
return -1;
return;
}
if (PA_SOURCE_IS_RUNNING(s->state)) {
pa_log_info("Cannot update sample spec, SOURCE_IS_RUNNING, will keep using %s, %u ch and %u Hz",
pa_sample_format_to_string(s->sample_spec.format), s->sample_spec.channels, s->sample_spec.rate);
return -1;
return;
}
if (s->monitor_of) {
@ -1109,11 +1109,11 @@ int pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, pa_channel_map *ma
if (!pa_sample_spec_equal(spec, &s->monitor_of->sample_spec) ||
!pa_channel_map_equal(map, &s->monitor_of->channel_map)) {
pa_log_info("Skipping monitor source reconfigruation to different spec from sink.");
return -1;
return;
}
if (PA_SINK_IS_RUNNING(s->monitor_of->state)) {
pa_log_info("Cannot update sample spec, this is a monitor source and the sink is running.");
return -1;
return;
}
}
@ -1178,10 +1178,10 @@ int pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, pa_channel_map *ma
/* We don't expect to change only the channel map, so we don't check that */
if (pa_sample_spec_equal(&desired_spec, &s->sample_spec) && passthrough == pa_source_is_passthrough(s))
return 0;
return;
if (!passthrough && pa_source_used_by(s) > 0)
return -1;
return;
pa_log_debug("Suspending source %s due to changing format, desired format = %s rate = %u, channels = %u",
s->name, pa_sample_format_to_string(desired_spec.format), desired_spec.rate, desired_spec.channels);
@ -1256,8 +1256,6 @@ int pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, pa_channel_map *ma
unsuspend:
pa_source_suspend(s, false, PA_SUSPEND_INTERNAL);
return ret;
}
/* Called from main thread */

View file

@ -422,7 +422,7 @@ bool pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_proplist
int pa_source_set_port(pa_source *s, const char *name, bool save);
int pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, pa_channel_map *map, bool passthrough);
void pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, pa_channel_map *map, bool passthrough);
unsigned pa_source_linked_by(pa_source *s); /* Number of connected streams */
unsigned pa_source_used_by(pa_source *s); /* Number of connected streams that are not corked */