Просмотр исходного кода

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 месяцев назад
Родитель
Сommit
42ba53ea71
1 измененных файлов с 2 добавлено и 4 удалено
  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()
     }
 }