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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
---
 src/modules/module-stream-restore.c | 44 +++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index d1c2597e..eb758330 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -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)))
             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)))
             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)))
             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)))
             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)
         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))) {
         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)))
         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 (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)
         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))) {
         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)))
         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 (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)
             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
            same time, in which case we want to make sure we don't
            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)
             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
            same time, in which case we want to make sure we don't
            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)
             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)))
             continue;
 
@@ -1758,6 +1797,11 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc
         if (!so->source)
             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)))
             continue;
 
-- 
2.11.0



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux