]> code.delx.au - pulseaudio/blobdiff - src/modules/module-stream-restore.c
Allow read-only or non-existing sink input volume.
[pulseaudio] / src / modules / module-stream-restore.c
index f8fecd891fecf46e0980fe042acee371fc869525..f4e4a55cda04048fac98a390e83e50c34b99f237 100644 (file)
@@ -1168,6 +1168,8 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
         }
 
         if (sink_input->save_volume) {
+            pa_assert(pa_sink_input_is_volume_writable(sink_input));
+
             entry.channel_map = sink_input->channel_map;
             pa_sink_input_get_volume(sink_input, &entry.volume, FALSE);
             entry.volume_valid = TRUE;
@@ -1327,8 +1329,11 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
     if ((e = read_entry(u, name))) {
 
         if (u->restore_volume && e->volume_valid) {
-
-            if (!new_data->volume_is_set) {
+            if (!pa_sink_input_new_data_is_volume_writable(new_data))
+                pa_log_debug("Not restoring volume for sink input %s, because its volume can't be changed.", name);
+            else if (new_data->volume_is_set)
+                pa_log_debug("Not restoring volume for sink input %s, because already set.", name);
+            else {
                 pa_cvolume v;
 
                 pa_log_info("Restoring volume for sink input %s.", name);
@@ -1339,8 +1344,7 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
 
                 new_data->volume_is_absolute = FALSE;
                 new_data->save_volume = TRUE;
-            } else
-                pa_log_debug("Not restoring volume for sink input %s, because already set.", name);
+            }
         }
 
         if (u->restore_muted && e->muted_valid) {
@@ -1615,7 +1619,7 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) {
         }
         pa_xfree(n);
 
-        if (u->restore_volume && e->volume_valid) {
+        if (u->restore_volume && e->volume_valid && pa_sink_input_is_volume_writable(si)) {
             pa_cvolume v;
 
             v = e->volume;