forge
Explore
Log in

Don't you dare go Hollow

Audio pickers mark Default while the chosen device is missing (playback already falls back to it)

Browse files at this commit

8a27ea6000ff1aa601bb3af5ddfefc1b2cee5683Ahmet Kaan GümüşParent: cb6d0a6
  • fix
    • audio pickers mark Default while the chosen device is missing (playback already falls back to it)
    • log the WASAPI device each open
Show full message
🐛 fix: audio pickers mark Default while the chosen device is missing (playback already falls back to it); log the WASAPI device each open
crates/client/src/gui/voice_settings.rsmodified+12 -3
@@ -178,6 +178,12 @@ fn slider(
178178 })
179179 }
180180
181+fn in_use(items: &[DeviceItem], chosen: &Option<String>) -> Option<String> {
182+ chosen
183+ .clone()
184+ .filter(|id| items.iter().any(|item| item.id.as_ref() == Some(id)))
185+}
186+
181187 fn device_list(devices: Vec<Device>) -> Vec<DeviceItem> {
182188 let mut items = vec![DeviceItem::default_choice()];
183189 items.extend(devices.into_iter().map(|device| DeviceItem {
@@ -560,12 +566,14 @@ impl Yumush {
560566 self.voice.input_items = inputs.clone();
561567 self.voice.output_items = outputs.clone();
562568 self.voice.inputs.update(cx, |state, cx| {
569+ let chosen = in_use(&inputs, &choice.input);
563570 state.set_items(SearchableVec::new(inputs), window, cx);
564- state.set_selected_value(&choice.input, window, cx);
571+ state.set_selected_value(&chosen, window, cx);
565572 });
566573 self.voice.outputs.update(cx, |state, cx| {
574+ let chosen = in_use(&outputs, &choice.output);
567575 state.set_items(SearchableVec::new(outputs), window, cx);
568- state.set_selected_value(&choice.output, window, cx);
576+ state.set_selected_value(&chosen, window, cx);
569577 });
570578 }
571579 }
@@ -636,6 +644,7 @@ fn audio_card(entity: &Entity<Yumush>, yumush: &Yumush, side: Side, palette: Pal
636644 voice.output_volume,
637645 ),
638646 };
647+ let chosen = in_use(items, chosen);
639648 super::parts::quick(t)
640649 .w(px(size::POPOVER))
641650 .children(items.iter().enumerate().map(|(index, item)| {
@@ -657,7 +666,7 @@ fn audio_card(entity: &Entity<Yumush>, yumush: &Yumush, side: Side, palette: Pal
657666 },
658667 ))
659668 .child(div().flex_1().min_w_0().truncate().child(item.name.clone()))
660- .children((&item.id == chosen).then(|| {
669+ .children((item.id == chosen).then(|| {
661670 super::parts::small_icon(IconName::Check)
662671 .flex_shrink_0()
663672 .text_color(palette.text)
crates/client/src/voice/audio/wasapi.rsmodified+1 -0
@@ -188,6 +188,7 @@ fn open(
188188 direction,
189189 choice,
190190 };
191+ tracing::info!(?direction, id = target.id, "audio device opened");
191192 let mut client = device.get_iaudioclient()?;
192193 init_shared_event(&mut client, direction)?;
193194 let event = client.set_get_eventhandle()?;