Fennec OS 0.3.3: clear names for the sound outputs

Settings → Sound listed ALSA's descriptions, "Built-in Audio Digital
Stereo (HDMI)" and "Built-in Audio Stereo", which look alike; the second
is the 3.5 mm jack, and picking it left the TV silent. They now read
"TV · HDMI" (on the Raspberry Pi "TV · HDMI 1" / "TV · HDMI 2") and
"Jack-kimenet (3,5 mm)", listed after the TV and Bluetooth outputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tamas Csikel
2026-11-03 15:30:41 +01:00
parent 2985aa94a9
commit 5f00c0877f
3 changed files with 57 additions and 17 deletions

22
Cargo.lock generated
View File

@@ -4734,8 +4734,7 @@ dependencies = [
[[package]]
name = "sf-app"
version = "0.1.2"
source = "git+https://gitea.bluefox.support/fennec/sdk?tag=v0.1.2#cb37d872ed7195e57268e0c3a1a76367039bf959"
version = "0.1.4"
dependencies = [
"anyhow",
"log",
@@ -4745,7 +4744,7 @@ dependencies = [
[[package]]
name = "sf-compositor"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"ab_glyph",
"anyhow",
@@ -4757,7 +4756,7 @@ dependencies = [
[[package]]
name = "sf-core"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"anyhow",
"env_logger",
@@ -4772,7 +4771,7 @@ dependencies = [
[[package]]
name = "sf-dial"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"anyhow",
"log",
@@ -4782,7 +4781,7 @@ dependencies = [
[[package]]
name = "sf-ipc"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"anyhow",
"log",
@@ -4794,7 +4793,7 @@ dependencies = [
[[package]]
name = "sf-launcher"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"anyhow",
"chrono",
@@ -4814,7 +4813,7 @@ dependencies = [
[[package]]
name = "sf-miracast"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"anyhow",
"env_logger",
@@ -4826,7 +4825,7 @@ dependencies = [
[[package]]
name = "sf-remote"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"anyhow",
"bluer",
@@ -4840,8 +4839,7 @@ dependencies = [
[[package]]
name = "sf-ui"
version = "0.1.2"
source = "git+https://gitea.bluefox.support/fennec/sdk?tag=v0.1.2#cb37d872ed7195e57268e0c3a1a76367039bf959"
version = "0.1.4"
dependencies = [
"anyhow",
"glow 0.16.0",
@@ -4852,7 +4850,7 @@ dependencies = [
[[package]]
name = "sf-update"
version = "0.3.2"
version = "0.3.3"
dependencies = [
"anyhow",
"base64 0.22.1",

View File

@@ -3,7 +3,7 @@ resolver = "3"
members = ["crates/sf-ipc", "crates/sf-launcher", "crates/sf-remote", "crates/sf-dial", "crates/sf-core", "crates/sf-update", "crates/sf-miracast", "crates/sf-compositor"]
[workspace.package]
version = "0.3.2"
version = "0.3.3"
edition = "2024"
license = "MIT"
@@ -11,8 +11,8 @@ license = "MIT"
sf-ipc = { path = "crates/sf-ipc" }
# The Fennec SDK (app contract, UI kit), by tag. Working on it next to the OS:
# see "Fennec SDK" in README.md.
sf-app = { git = "https://gitea.bluefox.support/fennec/sdk", tag = "v0.1.2" }
sf-ui = { git = "https://gitea.bluefox.support/fennec/sdk", tag = "v0.1.2" }
sf-app = { git = "https://gitea.bluefox.support/fennec/sdk", tag = "v0.1.4" }
sf-ui = { git = "https://gitea.bluefox.support/fennec/sdk", tag = "v0.1.4" }
sf-dial = { path = "crates/sf-dial" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"

View File

@@ -476,14 +476,46 @@ pub fn audio_outputs() -> Result<Vec<AudioOutput>> {
for sink in sinks {
let Some(name) = sink.get("name").and_then(|v| v.as_str()) else { continue };
if name == "auto_null" { continue; }
let label = sink.get("description").and_then(|v| v.as_str()).unwrap_or(name).to_string();
let description = sink.get("description").and_then(|v| v.as_str()).unwrap_or(name);
let label = output_label(name, description);
let bluetooth = name.starts_with("bluez_output.");
outputs.push(AudioOutput { name: name.into(), label, bluetooth, selected: name == default });
}
outputs.sort_by_key(|o| (!o.selected, o.bluetooth, o.label.to_lowercase()));
// The selected one, then the TV, Bluetooth, anything else, the jack last.
let rank = |o: &AudioOutput| match () {
_ if o.label.starts_with("TV") => 0,
_ if o.bluetooth => 1,
_ if o.label.starts_with("Jack") => 3,
_ => 2,
};
outputs.sort_by_key(|o| (!o.selected, rank(o), o.label.to_lowercase()));
Ok(outputs)
}
/// A name people recognise for a sound output. ALSA's descriptions
/// ("Built-in Audio Digital Stereo (HDMI)", "Built-in Audio Stereo") look
/// alike; the analog one is the 3.5 mm jack, not the TV.
fn output_label(name: &str, description: &str) -> String {
if name.starts_with("bluez_output.") {
return description.to_string();
}
let n = name.to_ascii_lowercase();
if n.contains("hdmi") {
// Raspberry Pi 4: two HDMI ports (fef00700 = HDMI 0, fef05700 = HDMI 1).
return match () {
_ if n.contains("fef05700") => "TV · HDMI 2".into(),
_ if n.contains("fef00700") => "TV · HDMI 1".into(),
_ => "TV · HDMI".into(),
};
}
if n.starts_with("alsa_output.")
&& (n.contains("analog") || n.contains("stereo-fallback") || n.contains("headphones") || n.contains("mailbox"))
{
return "Jack-kimenet (3,5 mm)".into();
}
description.to_string()
}
pub fn set_audio_output(name: &str) -> Result<()> {
if demo() {
*DEMO_AUDIO.lock().unwrap() = Some(name.into());
@@ -1129,6 +1161,16 @@ pub fn confirm_shell_trial() {
mod tests {
use super::*;
#[test]
fn output_labels() {
assert_eq!(output_label("alsa_output.platform-fef00700.hdmi.hdmi-stereo", "Built-in Audio Digital Stereo (HDMI)"), "TV · HDMI 1");
assert_eq!(output_label("alsa_output.platform-fef05700.hdmi.hdmi-stereo", "Built-in Audio Digital Stereo (HDMI)"), "TV · HDMI 2");
assert_eq!(output_label("alsa_output.pci-0000_00_1f.3.hdmi-stereo", "HDA Intel PCH HDMI"), "TV · HDMI");
assert_eq!(output_label("alsa_output.platform-fe00b840.mailbox.stereo-fallback", "Built-in Audio Stereo"), "Jack-kimenet (3,5 mm)");
assert_eq!(output_label("alsa_output.pci-0000_00_1f.3.analog-stereo", "Built-in Audio Analog Stereo"), "Jack-kimenet (3,5 mm)");
assert_eq!(output_label("bluez_output.D8_37_3B_73_C9_45.1", "AirPods Pro"), "AirPods Pro");
}
#[test]
fn parses_wlr_randr() {
let text = "HDMI-A-1 \"Samsung Electric Company SAMSUNG (HDMI-A-1)\"\n Enabled: yes\n Modes:\n 3840x2160 px, 30.000000 Hz\n 1920x1080 px, 60.000000 Hz (preferred, current)\n 1920x1080 px, 59.940002 Hz\n 3840x2160 px, 60.000000 Hz\n 720x400 px, 70.082001 Hz\n Position: 0,0\n Transform: normal\n Scale: 1.000000\n";