Audio pickers mark Default while the chosen device is missing (playback already falls back to it)
Browse files at this commit8a27ea6000ff1aa601bb3af5ddfefc1b2cee5683Parent: cb6d0a6- fix
- audio pickers mark Default while the chosen device is missing (playback already falls back to it)
- log the WASAPI device each open
2 changed files +13 -3
crates/client/src/gui/voice_settings.rsmodified+12 -3
| @@ -178,6 +178,12 @@ fn slider( | ||
| 178 | 178 | }) |
| 179 | 179 | } |
| 180 | 180 | |
| 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 | + | |
| 181 | 187 | fn device_list(devices: Vec<Device>) -> Vec<DeviceItem> { |
| 182 | 188 | let mut items = vec![DeviceItem::default_choice()]; |
| 183 | 189 | items.extend(devices.into_iter().map(|device| DeviceItem { |
| @@ -560,12 +566,14 @@ impl Yumush { | ||
| 560 | 566 | self.voice.input_items = inputs.clone(); |
| 561 | 567 | self.voice.output_items = outputs.clone(); |
| 562 | 568 | self.voice.inputs.update(cx, |state, cx| { |
| 569 | + let chosen = in_use(&inputs, &choice.input); | |
| 563 | 570 | 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); | |
| 565 | 572 | }); |
| 566 | 573 | self.voice.outputs.update(cx, |state, cx| { |
| 574 | + let chosen = in_use(&outputs, &choice.output); | |
| 567 | 575 | 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); | |
| 569 | 577 | }); |
| 570 | 578 | } |
| 571 | 579 | } |
| @@ -636,6 +644,7 @@ fn audio_card(entity: &Entity<Yumush>, yumush: &Yumush, side: Side, palette: Pal | ||
| 636 | 644 | voice.output_volume, |
| 637 | 645 | ), |
| 638 | 646 | }; |
| 647 | + let chosen = in_use(items, chosen); | |
| 639 | 648 | super::parts::quick(t) |
| 640 | 649 | .w(px(size::POPOVER)) |
| 641 | 650 | .children(items.iter().enumerate().map(|(index, item)| { |
| @@ -657,7 +666,7 @@ fn audio_card(entity: &Entity<Yumush>, yumush: &Yumush, side: Side, palette: Pal | ||
| 657 | 666 | }, |
| 658 | 667 | )) |
| 659 | 668 | .child(div().flex_1().min_w_0().truncate().child(item.name.clone())) |
| 660 | - .children((&item.id == chosen).then(|| { | |
| 669 | + .children((item.id == chosen).then(|| { | |
| 661 | 670 | super::parts::small_icon(IconName::Check) |
| 662 | 671 | .flex_shrink_0() |
| 663 | 672 | .text_color(palette.text) |
crates/client/src/voice/audio/wasapi.rsmodified+1 -0
| @@ -188,6 +188,7 @@ fn open( | ||
| 188 | 188 | direction, |
| 189 | 189 | choice, |
| 190 | 190 | }; |
| 191 | + tracing::info!(?direction, id = target.id, "audio device opened"); | |
| 191 | 192 | let mut client = device.get_iaudioclient()?; |
| 192 | 193 | init_shared_event(&mut client, direction)?; |
| 193 | 194 | let event = client.set_get_eventhandle()?; |