stream-restore: Restore preferred device for new streams
authorGeorg Chini <georg@chini.tk>
Mon, 6 Apr 2020 08:19:56 +0000 (10:19 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Thu, 9 Apr 2020 17:33:03 +0000 (17:33 +0000)
Currently the preferred device will not be restored for new streams if the
device is currently not avilable. This patch fixes the problem.

src/modules/module-stream-restore.c

index 6a42466..0ef30f1 100644 (file)
@@ -1450,8 +1450,10 @@ static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_n
     else if ((e = entry_read(u, name))) {
         pa_sink *s = NULL;
 
-        if (e->device_valid)
+        if (e->device_valid) {
             s = pa_namereg_get(c, e->device, PA_NAMEREG_SINK);
+            new_data->preferred_sink = pa_xstrdup(e->device);
+        }
 
         if (!s && e->card_valid) {
             pa_card *card;
@@ -1555,8 +1557,10 @@ static pa_hook_result_t source_output_new_hook_callback(pa_core *c, pa_source_ou
     else if ((e = entry_read(u, name))) {
         pa_source *s = NULL;
 
-        if (e->device_valid)
+        if (e->device_valid) {
             s = pa_namereg_get(c, e->device, PA_NAMEREG_SOURCE);
+            new_data->preferred_source = pa_xstrdup(e->device);
+        }
 
         if (!s && e->card_valid) {
             pa_card *card;