sink, source: Allow reconfigure to change the complete sample spec

For the passthrough case, we allow the entire sink sample spec to be
changed in reconfigure. This will be needed for high bitrate formats. We
duplicate this for sources to keep things in sync as well.

Relatedly, we also restore the original spec on leaving passthrough
mode. We were getting away with not doing so in the past as, while
incorrect, not restoring the rate was not disastrous. With the ability
to change channel count, not restoring breaks the meaning of profiles
entirely. The saving and restoration logic is restricted to sink/source
reconfiguration code to allow it to be self-contained and easier to
reason about.

All this also applies to the channel map. We don't actually explicitly
reconfigure the channel map at the moment, but since
pa_sink/source_reconfigure() can now change the channel count, it seems
to make sense to include the channel map along with that API change for
future use.
This commit is contained in:
Arun Raghavan 2018-05-20 08:52:10 +05:30 committed by Arun Raghavan
parent 9360dce76d
commit 0d85b18460
9 changed files with 242 additions and 76 deletions

View file

@ -380,7 +380,8 @@ int pa_source_output_new(
module-suspend-on-idle can resume a source */
pa_log_info("Trying to change sample spec");
pa_source_reconfigure(data->source, &data->sample_spec, pa_source_output_new_data_is_passthrough(data));
pa_source_reconfigure(data->source, &data->sample_spec, &data->channel_map,
pa_source_output_new_data_is_passthrough(data), false);
}
if (pa_source_output_new_data_is_passthrough(data) &&
@ -559,7 +560,7 @@ static void source_output_set_state(pa_source_output *o, pa_source_output_state_
!pa_sample_spec_equal(&o->sample_spec, &o->source->sample_spec)) {
/* We were uncorked and the source was not playing anything -- let's try
* to update the sample format and rate to avoid resampling */
pa_source_reconfigure(o->source, &o->sample_spec, pa_source_output_is_passthrough(o));
pa_source_reconfigure(o->source, &o->sample_spec, &o->channel_map, pa_source_output_is_passthrough(o), false);
}
pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL) == 0);
@ -628,9 +629,15 @@ void pa_source_output_unlink(pa_source_output*o) {
reset_callbacks(o);
if (o->source) {
if (PA_SOURCE_IS_LINKED(o->source->state))
if (PA_SOURCE_IS_LINKED(o->source->state)) {
pa_source_update_status(o->source);
if (pa_source_output_is_passthrough(o)) {
pa_log_debug("Leaving passthrough, trying to restore previous configuration");
pa_source_reconfigure(o->source, NULL, NULL, false, true);
}
}
o->source = NULL;
}
@ -1412,6 +1419,11 @@ int pa_source_output_start_move(pa_source_output *o) {
pa_source_update_status(o->source);
if (pa_source_output_is_passthrough(o)) {
pa_log_debug("Leaving passthrough, trying to restore previous configuration");
pa_source_reconfigure(o->source, NULL, NULL, false, true);
}
pa_cvolume_remap(&o->volume_factor_source, &o->source->channel_map, &o->channel_map);
o->source = NULL;
@ -1605,7 +1617,7 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, bool save
SOURCE_OUTPUT_MOVE_FINISH hook */
pa_log_info("Trying to change sample spec");
pa_source_reconfigure(dest, &o->sample_spec, pa_source_output_is_passthrough(o));
pa_source_reconfigure(dest, &o->sample_spec, &o->channel_map, pa_source_output_is_passthrough(o), false);
}
if (o->moving)