Sfoglia il codice sorgente

Do not crash when no audio sink device is available

The volume block would cause the main thread to panic when no default
sink device was available. This typically happens during login when
pulseaudio or wireplumber has not fully started yet.

Return an empty string for the volume block instead of crashing.
Frans Bergman 11 mesi fa
parent
commit
42ba53ea71
1 ha cambiato i file con 2 aggiunte e 4 eliminazioni
  1. 2 4
      src/block/volume.rs

+ 2 - 4
src/block/volume.rs

@@ -11,9 +11,7 @@ impl Block for Volume {
 
         handler
             .get_default_device()
-            .expect("No device")
-            .volume
-            .min()
-            .to_string()
+            .map(|device| device.volume.min().to_string())
+            .unwrap_or_default()
     }
 }