Przeglądaj źródła

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 miesięcy temu
rodzic
commit
42ba53ea71
1 zmienionych plików z 2 dodań i 4 usunięć
  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()
     }
 }