feat: audio - add concurrent mixing, output switching, and device-aware UI

This commit is contained in:
2026-07-29 20:03:35 +01:00
parent d99dab45e5
commit 86de3400a9
25 changed files with 688 additions and 209 deletions
+52 -1
View File
@@ -125,6 +125,17 @@ void gui::desktop_draw_panel(DesktopState* ds) {
tinted[p] = ((uint32_t)a << 24) | 0x00CC3333;
}
fb.blit_alpha(vol_icon_x, vol_icon_y, 16, 16, tinted);
} else if (ds->vol_output == montauk::abi::AUDIO_OUTPUT_BLUETOOTH) {
// The speaker glyph remains recognizable while the accent tint
// communicates that audio is routed wirelessly.
uint32_t* src = ds->icon_volume.pixels;
uint32_t tinted[256];
uint32_t rgb = ds->settings.accent_color.to_pixel() & 0x00FFFFFF;
for (int p = 0; p < 16 * 16; p++) {
uint8_t a = (src[p] >> 24) & 0xFF;
tinted[p] = ((uint32_t)a << 24) | rgb;
}
fb.blit_alpha(vol_icon_x, vol_icon_y, 16, 16, tinted);
} else {
fb.blit_alpha(vol_icon_x, vol_icon_y, ds->icon_volume.width, ds->icon_volume.height, ds->icon_volume.pixels);
}
@@ -337,7 +348,7 @@ void desktop_draw_net_popup(DesktopState* ds) {
// ============================================================================
static constexpr int VOL_POPUP_W = 200;
static constexpr int VOL_POPUP_H = 120;
static constexpr int VOL_POPUP_H = 202;
static constexpr int VOL_SLIDER_X = 16;
static constexpr int VOL_SLIDER_W = VOL_POPUP_W - 32;
static constexpr int VOL_SLIDER_H = 8;
@@ -455,4 +466,44 @@ void desktop_draw_vol_popup(DesktopState* ds) {
fill_rounded_rect(fb, bx, btn_y, mute_w, btn_h, btn_rad, mute_bg);
tw = text_width("Mute");
draw_text(fb, bx + (mute_w - tw) / 2, btn_y + (btn_h - system_font_height()) / 2, "Mute", mute_fg);
// Output is a persistent selection, so present it as a conventional radio
// group rather than a second bank of action buttons.
int output_label_y = popup_y + 116;
draw_text(fb, popup_x + 16, output_label_y, "Output",
Color::from_rgb(0x77, 0x77, 0x77));
auto draw_device_row = [&](const Rect& row, const char* label,
bool selected, bool enabled) {
bool hovered = enabled && row.contains(ds->mouse.x, ds->mouse.y);
if (hovered)
fill_rounded_rect(fb, row.x, row.y, row.w, row.h, 5,
Color::from_rgb(0xF0, 0xF3, 0xF6));
int radio_size = 14;
int rx = row.x + 4;
int ry = row.y + (row.h - radio_size) / 2;
fill_rounded_rect(fb, rx, ry, radio_size, radio_size,
radio_size / 2, Color::from_rgb(0xAA, 0xAA, 0xAA));
fill_rounded_rect(fb, rx + 1, ry + 1, radio_size - 2,
radio_size - 2, (radio_size - 2) / 2, colors::WHITE);
if (selected)
fill_rounded_rect(fb, rx + 4, ry + 4, radio_size - 8,
radio_size - 8, (radio_size - 8) / 2,
ds->settings.accent_color);
Color fg = enabled ? colors::TEXT_COLOR
: Color::from_rgb(0x99, 0x99, 0x99);
draw_text(fb, rx + radio_size + 8,
row.y + (row.h - system_font_height()) / 2, label, fg);
};
Rect hda_r = {popup_x + 12, popup_y + 137, VOL_POPUP_W - 24, 25};
Rect bt_r = {hda_r.x, hda_r.y + hda_r.h, hda_r.w, hda_r.h};
bool bt_ready = ds->vol_bt_status >= 2;
draw_device_row(hda_r, "Built-in Speakers",
ds->vol_output == montauk::abi::AUDIO_OUTPUT_HDA, true);
draw_device_row(bt_r, bt_ready ? "Bluetooth" : "Bluetooth (offline)",
ds->vol_output == montauk::abi::AUDIO_OUTPUT_BLUETOOTH,
bt_ready);
}