stream-restore: Ignore sink-inputs/source-outputs that connect a filter to the master

module-stream-restore primarily uses the role of a stream for restoring. The sink-inputs
and source-outputs of filters all have role "filter", therefore currently all filters are
treated equally and are restored to the same device and volume.

This patch lets module-stream-restore ignore the streams that connect the filter to the
master.

Bug link: https://bugs.freedesktop.org/show_bug.cgi?id=100065
This commit is contained in:
Georg Chini 2017-05-31 20:54:43 +02:00
parent ea506e9e23
commit 73cc75dd86

View file

@ -1274,6 +1274,11 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
if (!(sink_input = pa_idxset_get_by_index(c->sink_inputs, idx))) if (!(sink_input = pa_idxset_get_by_index(c->sink_inputs, idx)))
return; return;
/* Ignore this sink input if it is connecting a filter sink to
* the master */
if (sink_input->origin_sink)
return;
if (!(name = pa_proplist_get_stream_group(sink_input->proplist, "sink-input", IDENTIFICATION_PROPERTY))) if (!(name = pa_proplist_get_stream_group(sink_input->proplist, "sink-input", IDENTIFICATION_PROPERTY)))
return; return;
@ -1324,6 +1329,11 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
if (!(source_output = pa_idxset_get_by_index(c->source_outputs, idx))) if (!(source_output = pa_idxset_get_by_index(c->source_outputs, idx)))
return; return;
/* Ignore this source output if it is connecting a filter source to
* the master */
if (source_output->destination_source)
return;
if (!(name = pa_proplist_get_stream_group(source_output->proplist, "source-output", IDENTIFICATION_PROPERTY))) if (!(name = pa_proplist_get_stream_group(source_output->proplist, "source-output", IDENTIFICATION_PROPERTY)))
return; return;
@ -1422,6 +1432,8 @@ static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_n
if (new_data->sink) if (new_data->sink)
pa_log_debug("Not restoring device for stream %s, because already set to '%s'.", name, new_data->sink->name); pa_log_debug("Not restoring device for stream %s, because already set to '%s'.", name, new_data->sink->name);
else if (new_data->origin_sink)
pa_log_debug("Not restoring device for stream %s, because it connects a filter to the master sink.", name);
else if ((e = entry_read(u, name))) { else if ((e = entry_read(u, name))) {
pa_sink *s = NULL; pa_sink *s = NULL;
@ -1462,6 +1474,11 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
if (!(name = pa_proplist_get_stream_group(new_data->proplist, "sink-input", IDENTIFICATION_PROPERTY))) if (!(name = pa_proplist_get_stream_group(new_data->proplist, "sink-input", IDENTIFICATION_PROPERTY)))
return PA_HOOK_OK; return PA_HOOK_OK;
if (new_data->origin_sink) {
pa_log_debug("Not restoring volume for sink input %s, because it connects a filter to the master sink.", name);
return PA_HOOK_OK;
}
if ((e = entry_read(u, name))) { if ((e = entry_read(u, name))) {
if (u->restore_volume && e->volume_valid) { if (u->restore_volume && e->volume_valid) {
@ -1518,6 +1535,8 @@ static pa_hook_result_t source_output_new_hook_callback(pa_core *c, pa_source_ou
if (new_data->source) if (new_data->source)
pa_log_debug("Not restoring device for stream %s, because already set", name); pa_log_debug("Not restoring device for stream %s, because already set", name);
else if (new_data->destination_source)
pa_log_debug("Not restoring device for stream %s, because it connects a filter to the master source.", name);
else if ((e = entry_read(u, name))) { else if ((e = entry_read(u, name))) {
pa_source *s = NULL; pa_source *s = NULL;
@ -1559,6 +1578,11 @@ static pa_hook_result_t source_output_fixate_hook_callback(pa_core *c, pa_source
if (!(name = pa_proplist_get_stream_group(new_data->proplist, "source-output", IDENTIFICATION_PROPERTY))) if (!(name = pa_proplist_get_stream_group(new_data->proplist, "source-output", IDENTIFICATION_PROPERTY)))
return PA_HOOK_OK; return PA_HOOK_OK;
if (new_data->destination_source) {
pa_log_debug("Not restoring volume for source output %s, because it connects a filter to the master source.", name);
return PA_HOOK_OK;
}
if ((e = entry_read(u, name))) { if ((e = entry_read(u, name))) {
if (u->restore_volume && e->volume_valid) { if (u->restore_volume && e->volume_valid) {
@ -1622,6 +1646,11 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, struct
if (!si->sink) if (!si->sink)
continue; continue;
/* Skip this sink input if it is connecting a filter sink to
* the master */
if (si->origin_sink)
continue;
/* It might happen that a stream and a sink are set up at the /* It might happen that a stream and a sink are set up at the
same time, in which case we want to make sure we don't same time, in which case we want to make sure we don't
interfere with that */ interfere with that */
@ -1670,6 +1699,11 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
if (!so->source) if (!so->source)
continue; continue;
/* Skip this source output if it is connecting a filter source to
* the master */
if (so->destination_source)
continue;
/* It might happen that a stream and a source are set up at the /* It might happen that a stream and a source are set up at the
same time, in which case we want to make sure we don't same time, in which case we want to make sure we don't
interfere with that */ interfere with that */
@ -1712,6 +1746,11 @@ static pa_hook_result_t sink_unlink_hook_callback(pa_core *c, pa_sink *sink, str
if (!si->sink) if (!si->sink)
continue; continue;
/* Skip this sink input if it is connecting a filter sink to
* the master */
if (si->origin_sink)
continue;
if (!(name = pa_proplist_get_stream_group(si->proplist, "sink-input", IDENTIFICATION_PROPERTY))) if (!(name = pa_proplist_get_stream_group(si->proplist, "sink-input", IDENTIFICATION_PROPERTY)))
continue; continue;
@ -1758,6 +1797,11 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc
if (!so->source) if (!so->source)
continue; continue;
/* Skip this source output if it is connecting a filter source to
* the master */
if (so->destination_source)
continue;
if (!(name = pa_proplist_get_stream_group(so->proplist, "source-output", IDENTIFICATION_PROPERTY))) if (!(name = pa_proplist_get_stream_group(so->proplist, "source-output", IDENTIFICATION_PROPERTY)))
continue; continue;