소스 검색

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 달 전
부모
커밋
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()
     }
 }