fix(audio): play Linux call tones on the saved Pulse sink (#141)
Co-authored-by: Matteo Lombardi <93079933+matteolomba@users.noreply.github.com>
@@ -14,13 +14,14 @@ runs:
14
14
run: |
15
15
# README: "Linux build needs clang + mold (set in .cargo/config.toml)".
16
16
# The rest are headers the calling stack probes at build time: glib for webrtc-sys,
17
# alsa for cpal, v4l2 for nokhwa (bindgen wants libclang), xkbcommon and fontconfig
18
# for GPUI (font lookup via yeslogic-fontconfig-sys),
17
# alsa for cpal, Pulse for call tones (libpulse-simple), v4l2 for nokhwa
18
# (bindgen wants libclang), xkbcommon and fontconfig for GPUI
19
# (font lookup via yeslogic-fontconfig-sys),
19
20
# libva enables the hardware video codecs of webrtc-sys.
20
21
sudo apt-get update
21
22
sudo apt-get install --no-install-recommends -y \
22
23
clang mold pkg-config libclang-dev \
23
libglib2.0-dev libfontconfig-dev libasound2-dev libva-dev \
24
libglib2.0-dev libfontconfig-dev libasound2-dev libpulse-dev libva-dev \
24
25
libxkbcommon-dev libxkbcommon-x11-dev \
25
26
libx11-dev libxcb1-dev libxext-dev libxfixes-dev libxdamage-dev \
26
27
libxrandr-dev libxcomposite-dev libwayland-dev libpipewire-0.3-dev
@@ -14,13 +14,14 @@ runs:14
run: |14
run: |15
# README: "Linux build needs clang + mold (set in .cargo/config.toml)".15
# README: "Linux build needs clang + mold (set in .cargo/config.toml)".16
# The rest are headers the calling stack probes at build time: glib for webrtc-sys,16
# The rest are headers the calling stack probes at build time: glib for webrtc-sys,17
# alsa for cpal, v4l2 for nokhwa (bindgen wants libclang), xkbcommon and fontconfig17
# alsa for cpal, Pulse for call tones (libpulse-simple), v4l2 for nokhwa18
# for GPUI (font lookup via yeslogic-fontconfig-sys),18
# (bindgen wants libclang), xkbcommon and fontconfig for GPUI19
# (font lookup via yeslogic-fontconfig-sys),19
# libva enables the hardware video codecs of webrtc-sys.20
# libva enables the hardware video codecs of webrtc-sys.20
sudo apt-get update21
sudo apt-get update21
sudo apt-get install --no-install-recommends -y \22
sudo apt-get install --no-install-recommends -y \22
clang mold pkg-config libclang-dev \23
clang mold pkg-config libclang-dev \23
libglib2.0-dev libfontconfig-dev libasound2-dev libva-dev \24
libglib2.0-dev libfontconfig-dev libasound2-dev libpulse-dev libva-dev \24
libxkbcommon-dev libxkbcommon-x11-dev \25
libxkbcommon-dev libxkbcommon-x11-dev \25
libx11-dev libxcb1-dev libxext-dev libxfixes-dev libxdamage-dev \26
libx11-dev libxcb1-dev libxext-dev libxfixes-dev libxdamage-dev \26
libxrandr-dev libxcomposite-dev libwayland-dev libpipewire-0.3-dev27
libxrandr-dev libxcomposite-dev libwayland-dev libpipewire-0.3-dev@@ -322,6 +322,8 @@ dependencies = [
322
322
"image",
323
323
"ksni",
324
324
"libc",
325
"libpulse-binding",
326
"libpulse-simple-binding",
325
327
"log",
326
328
"mcp",
327
329
"raw-window-handle",
@@ -5269,6 +5271,54 @@ version = "0.2.16"
5269
5271
source = "registry+https://github.com/rust-lang/crates.io-index"
5270
5272
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
5271
5273
5274
[[package]]
5275
name = "libpulse-binding"
5276
version = "2.30.1"
5277
source = "registry+https://github.com/rust-lang/crates.io-index"
5278
checksum = "909eb3049e16e373680fe65afe6e2a722ace06b671250cc4849557bc57d6a397"
5279
dependencies = [
5280
"bitflags 2.13.2",
5281
"libc",
5282
"libpulse-sys",
5283
"num-derive",
5284
"num-traits",
5285
"winapi",
5286
]
5287
5288
[[package]]
5289
name = "libpulse-simple-binding"
5290
version = "2.29.0"
5291
source = "registry+https://github.com/rust-lang/crates.io-index"
5292
checksum = "b7bebef0381c8e3e4b23cc24aaf36fab37472bece128de96f6a111efa464cfef"
5293
dependencies = [
5294
"libpulse-binding",
5295
"libpulse-simple-sys",
5296
"libpulse-sys",
5297
]
5298
5299
[[package]]
5300
name = "libpulse-simple-sys"
5301
version = "1.22.0"
5302
source = "registry+https://github.com/rust-lang/crates.io-index"
5303
checksum = "3bd96888fe37ad270d16abf5e82cccca1424871cf6afa2861824d2a52758eebc"
5304
dependencies = [
5305
"libpulse-sys",
5306
"pkg-config",
5307
]
5308
5309
[[package]]
5310
name = "libpulse-sys"
5311
version = "1.23.0"
5312
source = "registry+https://github.com/rust-lang/crates.io-index"
5313
checksum = "d74371848b22e989f829cc1621d2ebd74960711557d8b45cfe740f60d0a05e61"
5314
dependencies = [
5315
"libc",
5316
"num-derive",
5317
"num-traits",
5318
"pkg-config",
5319
"winapi",
5320
]
5321
5272
5322
[[package]]
5273
5323
name = "libredox"
5274
5324
version = "0.1.25"
@@ -6201,7 +6251,7 @@ version = "0.7.6"
6201
6251
source = "registry+https://github.com/rust-lang/crates.io-index"
6202
6252
checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"
6203
6253
dependencies = [
6204
"proc-macro-crate 1.3.1",
6254
"proc-macro-crate 3.5.0",
6205
6255
"proc-macro2",
6206
6256
"quote",
6207
6257
"syn 2.0.119",
@@ -9409,7 +9459,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
9409
9459
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
9410
9460
dependencies = [
9411
9461
"fastrand",
9412
"getrandom 0.3.4",
9462
"getrandom 0.4.3",
9413
9463
"once_cell",
9414
9464
"rustix 1.1.5",
9415
9465
"windows-sys 0.61.2",
@@ -11048,7 +11098,7 @@ version = "0.1.11"
11048
11098
source = "registry+https://github.com/rust-lang/crates.io-index"
11049
11099
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
11050
11100
dependencies = [
11051
"windows-sys 0.48.0",
11101
"windows-sys 0.61.2",
11052
11102
]
11053
11103
11054
11104
[[package]]
@@ -322,6 +322,8 @@ dependencies = [322
"image",322
"image",323
"ksni",323
"ksni",324
"libc",324
"libc",325
"libpulse-binding",326
"libpulse-simple-binding",325
"log",327
"log",326
"mcp",328
"mcp",327
"raw-window-handle",329
"raw-window-handle",@@ -5269,6 +5271,54 @@ version = "0.2.16"5269
source = "registry+https://github.com/rust-lang/crates.io-index"5271
source = "registry+https://github.com/rust-lang/crates.io-index"5270
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"5272
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"5271
5273
5274
[[package]]5275
name = "libpulse-binding"5276
version = "2.30.1"5277
source = "registry+https://github.com/rust-lang/crates.io-index"5278
checksum = "909eb3049e16e373680fe65afe6e2a722ace06b671250cc4849557bc57d6a397"5279
dependencies = [5280
"bitflags 2.13.2",5281
"libc",5282
"libpulse-sys",5283
"num-derive",5284
"num-traits",5285
"winapi",5286
]5287
5288
[[package]]5289
name = "libpulse-simple-binding"5290
version = "2.29.0"5291
source = "registry+https://github.com/rust-lang/crates.io-index"5292
checksum = "b7bebef0381c8e3e4b23cc24aaf36fab37472bece128de96f6a111efa464cfef"5293
dependencies = [5294
"libpulse-binding",5295
"libpulse-simple-sys",5296
"libpulse-sys",5297
]5298
5299
[[package]]5300
name = "libpulse-simple-sys"5301
version = "1.22.0"5302
source = "registry+https://github.com/rust-lang/crates.io-index"5303
checksum = "3bd96888fe37ad270d16abf5e82cccca1424871cf6afa2861824d2a52758eebc"5304
dependencies = [5305
"libpulse-sys",5306
"pkg-config",5307
]5308
5309
[[package]]5310
name = "libpulse-sys"5311
version = "1.23.0"5312
source = "registry+https://github.com/rust-lang/crates.io-index"5313
checksum = "d74371848b22e989f829cc1621d2ebd74960711557d8b45cfe740f60d0a05e61"5314
dependencies = [5315
"libc",5316
"num-derive",5317
"num-traits",5318
"pkg-config",5319
"winapi",5320
]5321
5272
[[package]]5322
[[package]]5273
name = "libredox"5323
name = "libredox"5274
version = "0.1.25"5324
version = "0.1.25"@@ -6201,7 +6251,7 @@ version = "0.7.6"6201
source = "registry+https://github.com/rust-lang/crates.io-index"6251
source = "registry+https://github.com/rust-lang/crates.io-index"6202
checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"6252
checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"6203
dependencies = [6253
dependencies = [6204
"proc-macro-crate 1.3.1",6254
"proc-macro-crate 3.5.0",6205
"proc-macro2",6255
"proc-macro2",6206
"quote",6256
"quote",6207
"syn 2.0.119",6257
"syn 2.0.119",@@ -9409,7 +9459,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"9409
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"9459
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"9410
dependencies = [9460
dependencies = [9411
"fastrand",9461
"fastrand",9412
"getrandom 0.3.4",9462
"getrandom 0.4.3",9413
"once_cell",9463
"once_cell",9414
"rustix 1.1.5",9464
"rustix 1.1.5",9415
"windows-sys 0.61.2",9465
"windows-sys 0.61.2",@@ -11048,7 +11098,7 @@ version = "0.1.11"11048
source = "registry+https://github.com/rust-lang/crates.io-index"11098
source = "registry+https://github.com/rust-lang/crates.io-index"11049
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"11099
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"11050
dependencies = [11100
dependencies = [11051
"windows-sys 0.48.0",11101
"windows-sys 0.61.2",11052
]11102
]11053
11103
11054
[[package]]11104
[[package]]@@ -46,6 +46,8 @@ wayland-protocols = { version = "0.32", features = ["client", "staging"] }
46
46
x11rb = { version = "0.13", features = ["shape"] }
47
47
ksni = { version = "0.3", features = ["blocking"] }
48
48
zbus = { version = "5", default-features = false, features = ["tokio"] }
49
libpulse-binding = "2.30.1"
50
libpulse-simple-binding = "2.29.0"
49
51
50
52
[target.'cfg(any(windows, target_os = "macos"))'.dependencies]
51
53
tray-icon = { version = "0.21", default-features = false }
@@ -46,6 +46,8 @@ wayland-protocols = { version = "0.32", features = ["client", "staging"] }46
x11rb = { version = "0.13", features = ["shape"] }46
x11rb = { version = "0.13", features = ["shape"] }47
ksni = { version = "0.3", features = ["blocking"] }47
ksni = { version = "0.3", features = ["blocking"] }48
zbus = { version = "5", default-features = false, features = ["tokio"] }48
zbus = { version = "5", default-features = false, features = ["tokio"] }49
libpulse-binding = "2.30.1"50
libpulse-simple-binding = "2.29.0"49
51
50
[target.'cfg(any(windows, target_os = "macos"))'.dependencies]52
[target.'cfg(any(windows, target_os = "macos"))'.dependencies]51
tray-icon = { version = "0.21", default-features = false }53
tray-icon = { version = "0.21", default-features = false }@@ -1,20 +1,77 @@
1
//! Linux and macOS notification and ringtone playback through the system audio output.
1
//! Linux and macOS notification and ringtone playback.
2
//!
3
//! On Linux the saved call output is a Pulse sink description or name. Tones go to that
4
//! sink. When the Pulse daemon is not running, Linux uses the same cpal lookup as macOS.
5
//! A sink that disappears while a tone is playing falls back to the system default.
6
7
use std::collections::HashSet;
2
8
use std::io::Cursor;
3
9
use std::sync::atomic::{AtomicBool, Ordering};
4
use std::sync::{Arc, Mutex};
10
use std::sync::{Arc, LazyLock, Mutex};
5
11
use std::time::Duration;
6
12
13
use rodio::Source;
7
14
use rodio::cpal::traits::{DeviceTrait, HostTrait};
8
15
9
16
const SOUND_BYTES: &[u8] = include_bytes!("../../../../app/assets/sounds/notification.mp3");
10
17
const POLL: Duration = Duration::from_millis(20);
11
18
static SOUND_OUTPUT: Mutex<Option<String>> = Mutex::new(None);
19
static LOGGED_MISSES: LazyLock<Mutex<HashSet<String>>> =
20
LazyLock::new(|| Mutex::new(HashSet::new()));
12
21
13
22
pub fn set_sound_output(device_key: Option<String>) {
14
23
*SOUND_OUTPUT.lock().unwrap_or_else(|p| p.into_inner()) = device_key;
15
24
}
16
25
17
/// True when a call-output key names this cpal device (id, friendly name, or Pulse-style id).
26
/// One Pulse sink, as listed by the daemon.
27
#[derive(Clone)]
28
pub(crate) struct PulseSink {
29
pub name: String,
30
pub description: String,
31
}
32
33
/// Trim, drop one leading `default:` prefix, then ASCII-lowercase.
34
pub(crate) fn normalized_audio_key(value: &str) -> String {
35
let trimmed = value.trim();
36
let rest = strip_default_prefix(trimmed).trim();
37
rest.to_ascii_lowercase()
38
}
39
40
fn strip_default_prefix(value: &str) -> &str {
41
const PREFIX: &str = "default:";
42
if value.len() >= PREFIX.len() && value[..PREFIX.len()].eq_ignore_ascii_case(PREFIX) {
43
&value[PREFIX.len()..]
44
} else {
45
value
46
}
47
}
48
49
/// Exact name or description match. A Game sink does not satisfy a Chat key.
50
pub(crate) fn matching_sink<'a>(sinks: &'a [PulseSink], key: &str) -> Option<&'a PulseSink> {
51
let key = normalized_audio_key(key);
52
if key.is_empty() {
53
return None;
54
}
55
sinks.iter().find(|sink| {
56
normalized_audio_key(&sink.name) == key || normalized_audio_key(&sink.description) == key
57
})
58
}
59
60
/// True the first time this key is reported missing.
61
fn claim_miss(key: &str) -> bool {
62
LOGGED_MISSES
63
.lock()
64
.unwrap_or_else(|p| p.into_inner())
65
.insert(key.to_owned())
66
}
67
68
fn note_missing_once(key: &str, message: String) {
69
if claim_miss(key) {
70
crate::diagnostics::record(message);
71
}
72
}
73
74
/// True when a call-output key names this cpal device (id or friendly name).
18
75
pub(crate) fn device_matches_key(device_id: &str, device_name: &str, key: &str) -> bool {
19
76
let key = key.trim();
20
77
if key.is_empty() {
@@ -32,10 +89,61 @@ pub(crate) fn device_matches_key(device_id: &str, device_name: &str, key: &str)
32
89
|| (key_lower.len() >= 4 && name_lower.contains(&key_lower))
33
90
}
34
91
92
struct Decoded {
93
rate: u32,
94
channels: u16,
95
samples: Vec<f32>,
96
}
97
98
fn decode(bytes: &[u8]) -> Result<Decoded, String> {
99
let decoder = rodio::Decoder::try_from(Cursor::new(bytes.to_vec()))
100
.map_err(|error| format!("cannot decode notification sound: {error}"))?;
101
let rate = decoder.sample_rate().get();
102
let channels = decoder.channels().get();
103
let samples = decoder.collect();
104
Ok(Decoded {
105
rate,
106
channels,
107
samples,
108
})
109
}
110
111
fn play_on_rodio(
112
sink: &mut rodio::MixerDeviceSink,
113
bytes: Vec<u8>,
114
looped: bool,
115
stop: &AtomicBool,
116
) -> Result<(), String> {
117
sink.log_on_drop(false);
118
loop {
119
if stop.load(Ordering::SeqCst) {
120
return Ok(());
121
}
122
let player = rodio::play(sink.mixer(), Cursor::new(bytes.clone()))
123
.map_err(|error| format!("cannot decode notification sound: {error}"))?;
124
while !player.empty() {
125
if stop.load(Ordering::SeqCst) {
126
player.stop();
127
return Ok(());
128
}
129
std::thread::sleep(POLL);
130
}
131
if !looped {
132
return Ok(());
133
}
134
}
135
}
136
137
fn open_default_and_play(bytes: Vec<u8>, looped: bool, stop: &AtomicBool) -> Result<(), String> {
138
let mut sink = rodio::DeviceSinkBuilder::open_default_sink()
139
.map_err(|error| format!("cannot open audio output: {error}"))?;
140
play_on_rodio(&mut sink, bytes, looped, stop)
141
}
142
35
143
fn open_sink() -> Result<rodio::MixerDeviceSink, String> {
36
144
let chosen = SOUND_OUTPUT
37
145
.lock()
38
.unwrap_or_else(|p| p.into_inner())
146
.unwrap_or_else(|poisoned| poisoned.into_inner())
39
147
.clone();
40
148
if let Some(key) = chosen.as_ref() {
41
149
if let Some(device) = rodio::cpal::default_host()
@@ -68,34 +176,184 @@ fn open_sink() -> Result<rodio::MixerDeviceSink, String> {
68
176
}
69
177
}
70
178
rodio::DeviceSinkBuilder::open_default_sink()
71
.map_err(|e| format!("cannot open audio output: {e}"))
179
.map_err(|error| format!("cannot open audio output: {error}"))
72
180
}
73
181
74
fn play(bytes: Vec<u8>, looped: bool, stop: Arc<AtomicBool>) -> Result<(), String> {
75
if stop.load(Ordering::SeqCst) {
76
return Ok(());
77
}
78
let mut sink = open_sink()?;
79
sink.log_on_drop(false);
182
#[cfg(target_os = "linux")]
183
fn pulse_sinks() -> Option<Vec<PulseSink>> {
184
use libpulse_binding::callbacks::ListResult;
185
use libpulse_binding::context::{Context, FlagSet, State};
186
use libpulse_binding::mainloop::standard::Mainloop;
187
188
let mut mainloop = Mainloop::new()?;
189
let mut context = Context::new(&mainloop, "rusty-teams")?;
190
context.connect(None, FlagSet::NOAUTOSPAWN, None).ok()?;
191
let deadline = std::time::Instant::now() + Duration::from_millis(400);
80
192
loop {
81
if stop.load(Ordering::SeqCst) {
82
return Ok(());
193
if std::time::Instant::now() > deadline {
194
return None;
83
195
}
84
let player = rodio::play(sink.mixer(), Cursor::new(bytes.clone()))
85
.map_err(|e| format!("cannot decode notification sound: {e}"))?;
86
while !player.empty() {
196
let _ = mainloop.iterate(false);
197
match context.get_state() {
198
State::Ready => break,
199
State::Failed | State::Terminated => return None,
200
_ => std::thread::sleep(Duration::from_millis(5)),
201
}
202
}
203
let found = Arc::new(Mutex::new(Vec::new()));
204
let done = Arc::new(AtomicBool::new(false));
205
let found_cb = Arc::clone(&found);
206
let done_cb = Arc::clone(&done);
207
let operation = context
208
.introspect()
209
.get_sink_info_list(move |item| match item {
210
ListResult::Item(info) => found_cb
211
.lock()
212
.unwrap_or_else(|poisoned| poisoned.into_inner())
213
.push(PulseSink {
214
name: info.name.as_deref().unwrap_or("").to_owned(),
215
description: info.description.as_deref().unwrap_or("").to_owned(),
216
}),
217
ListResult::End | ListResult::Error => done_cb.store(true, Ordering::SeqCst),
218
});
219
while !done.load(Ordering::SeqCst) {
220
if std::time::Instant::now() > deadline {
221
return None;
222
}
223
let _ = mainloop.iterate(false);
224
std::thread::sleep(Duration::from_millis(5));
225
}
226
drop(operation);
227
Some(
228
found
229
.lock()
230
.unwrap_or_else(|poisoned| poisoned.into_inner())
231
.clone(),
232
)
233
}
234
235
#[cfg(target_os = "linux")]
236
fn play_on_pulse(
237
sink_name: &str,
238
decoded: &Decoded,
239
looped: bool,
240
stop: &AtomicBool,
241
) -> Result<(), String> {
242
use libpulse_binding::sample::{Format, Spec};
243
use libpulse_binding::stream::Direction;
244
use libpulse_simple_binding::Simple;
245
246
let channels =
247
u8::try_from(decoded.channels).map_err(|_| "too many audio channels".to_owned())?;
248
let spec = Spec {
249
format: Format::FLOAT32NE,
250
channels,
251
rate: decoded.rate,
252
};
253
if !spec.is_valid() {
254
return Err(format!(
255
"pulse cannot play {} Hz {} ch",
256
decoded.rate, decoded.channels
257
));
258
}
259
let simple = Simple::new(
260
None,
261
"rusty-teams",
262
Direction::Playback,
263
Some(sink_name),
264
"call tone",
265
&spec,
266
None,
267
None,
268
)
269
.map_err(|error| format!("pulse open {sink_name}: {error}"))?;
270
let frame = decoded.channels as usize;
271
let chunk = (decoded.rate as usize / 10).max(1) * frame.max(1);
272
loop {
273
for piece in decoded.samples.chunks(chunk.max(1)) {
87
274
if stop.load(Ordering::SeqCst) {
88
player.stop();
89
275
return Ok(());
90
276
}
91
std::thread::sleep(POLL);
277
let mut bytes = Vec::with_capacity(piece.len() * 4);
278
for sample in piece {
279
bytes.extend_from_slice(&sample.to_ne_bytes());
280
}
281
simple
282
.write(&bytes)
283
.map_err(|error| format!("pulse write: {error}"))?;
92
284
}
93
285
if !looped {
286
simple
287
.drain()
288
.map_err(|error| format!("pulse drain: {error}"))?;
94
289
return Ok(());
95
290
}
96
291
}
97
292
}
98
293
294
#[cfg(target_os = "linux")]
295
fn play_linux(bytes: Vec<u8>, looped: bool, stop: &AtomicBool) -> Result<(), String> {
296
let key = SOUND_OUTPUT
297
.lock()
298
.unwrap_or_else(|poisoned| poisoned.into_inner())
299
.clone();
300
if let Some(key) = key.filter(|key| !normalized_audio_key(key).is_empty()) {
301
match pulse_sinks() {
302
Some(sinks) => {
303
if let Some(sink) = matching_sink(&sinks, &key) {
304
let decoded = decode(&bytes)?;
305
match play_on_pulse(&sink.name, &decoded, looped, stop) {
306
Ok(()) => return Ok(()),
307
Err(error)
308
if error.starts_with("pulse open ")
309
|| error.starts_with("pulse cannot play")
310
|| error.starts_with("pulse write")
311
|| error.starts_with("pulse drain") =>
312
{
313
note_missing_once(
314
&key,
315
format!(
316
"sound: selected output {key:?} failed ({error}), using system default"
317
),
318
);
319
}
320
Err(error) => return Err(error),
321
}
322
} else {
323
note_missing_once(
324
&key,
325
format!("sound: selected output {key:?} not found, using system default"),
326
);
327
}
328
}
329
None => {
330
note_missing_once(
331
&format!("pulse:{key}"),
332
format!("sound: pulse unavailable for {key:?}, trying the device list"),
333
);
334
let mut sink = open_sink()?;
335
return play_on_rodio(&mut sink, bytes, looped, stop);
336
}
337
}
338
}
339
open_default_and_play(bytes, looped, stop)
340
}
341
342
fn play(bytes: Vec<u8>, looped: bool, stop: Arc<AtomicBool>) -> Result<(), String> {
343
if stop.load(Ordering::SeqCst) {
344
return Ok(());
345
}
346
#[cfg(target_os = "linux")]
347
{
348
return play_linux(bytes, looped, &stop);
349
}
350
#[cfg(not(target_os = "linux"))]
351
{
352
let mut sink = open_sink()?;
353
play_on_rodio(&mut sink, bytes, looped, &stop)
354
}
355
}
356
99
357
pub fn play_mp3_until(bytes: Vec<u8>, looped: bool, stop: Arc<AtomicBool>) {
100
358
std::thread::spawn(move || {
101
359
if let Err(error) = play(bytes, looped, stop) {
@@ -116,6 +374,20 @@ pub fn play_sound() {
116
374
mod tests {
117
375
use super::*;
118
376
377
fn sink(name: &str, description: &str) -> PulseSink {
378
PulseSink {
379
name: name.to_owned(),
380
description: description.to_owned(),
381
}
382
}
383
384
fn headset_sinks() -> Vec<PulseSink> {
385
vec![
386
sink("alsa_output.headset.mono-chat", "Headset Chat"),
387
sink("alsa_output.headset.stereo-game", "Headset Game"),
388
]
389
}
390
119
391
#[test]
120
392
fn bundled_notification_decodes_to_audible_samples() {
121
393
let decoded = rodio::Decoder::try_from(Cursor::new(SOUND_BYTES)).unwrap();
@@ -153,6 +425,28 @@ mod tests {
153
425
assert!(!device_matches_key("id", "Speaker", ""));
154
426
}
155
427
428
#[test]
429
fn a_pulse_description_selects_that_sink_and_not_the_other_output() {
430
let sinks = headset_sinks();
431
let game = matching_sink(&sinks, "Headset Game").unwrap();
432
assert_eq!(game.name, "alsa_output.headset.stereo-game");
433
let prefixed = matching_sink(&sinks, "default: Headset Game").unwrap();
434
assert_eq!(prefixed.name, "alsa_output.headset.stereo-game");
435
let chat = matching_sink(&sinks, "Headset Chat").unwrap();
436
assert_eq!(chat.name, "alsa_output.headset.mono-chat");
437
assert!(matching_sink(&sinks, "Headset Game").unwrap().name != chat.name);
438
assert!(matching_sink(&sinks, "missing output").is_none());
439
assert!(matching_sink(&sinks, "Game").is_none());
440
}
441
442
#[test]
443
fn a_missing_key_is_noted_once() {
444
let key = format!("missing-output-{}", std::process::id());
445
assert!(claim_miss(&key));
446
assert!(!claim_miss(&key));
447
assert!(claim_miss(&format!("{key}-other")));
448
}
449
156
450
#[test]
157
451
#[ignore = "plays a short notification on the real default audio output"]
158
452
fn notification_plays_on_default_output() {
@@ -163,4 +457,30 @@ mod tests {
163
457
)
164
458
.unwrap();
165
459
}
460
461
#[cfg(target_os = "linux")]
462
#[test]
463
#[ignore = "plays a short tone on the Pulse sink named by CALL_OUTPUT_KEY"]
464
fn selected_pulse_sink_plays_the_tone() {
465
let key = std::env::var("CALL_OUTPUT_KEY").expect("CALL_OUTPUT_KEY");
466
let sinks = pulse_sinks().expect("pulse");
467
let sink = matching_sink(&sinks, &key).unwrap_or_else(|| {
468
panic!(
469
"no sink for {key:?}; have {}",
470
sinks
471
.iter()
472
.map(|sink| format!("{} ({})", sink.description, sink.name))
473
.collect::<Vec<_>>()
474
.join(", ")
475
)
476
});
477
eprintln!("pulse sink {} ({})", sink.name, sink.description);
478
set_sound_output(Some(key));
479
play(
480
SOUND_BYTES.to_vec(),
481
false,
482
Arc::new(AtomicBool::new(false)),
483
)
484
.unwrap();
485
}
166
486
}
@@ -1,20 +1,77 @@1
//! Linux and macOS notification and ringtone playback through the system audio output.1
//! Linux and macOS notification and ringtone playback.2
//!3
//! On Linux the saved call output is a Pulse sink description or name. Tones go to that4
//! sink. When the Pulse daemon is not running, Linux uses the same cpal lookup as macOS.5
//! A sink that disappears while a tone is playing falls back to the system default.6
7
use std::collections::HashSet;2
use std::io::Cursor;8
use std::io::Cursor;3
use std::sync::atomic::{AtomicBool, Ordering};9
use std::sync::atomic::{AtomicBool, Ordering};4
use std::sync::{Arc, Mutex};10
use std::sync::{Arc, LazyLock, Mutex};5
use std::time::Duration;11
use std::time::Duration;6
12
13
use rodio::Source;7
use rodio::cpal::traits::{DeviceTrait, HostTrait};14
use rodio::cpal::traits::{DeviceTrait, HostTrait};8
15
9
const SOUND_BYTES: &[u8] = include_bytes!("../../../../app/assets/sounds/notification.mp3");16
const SOUND_BYTES: &[u8] = include_bytes!("../../../../app/assets/sounds/notification.mp3");10
const POLL: Duration = Duration::from_millis(20);17
const POLL: Duration = Duration::from_millis(20);11
static SOUND_OUTPUT: Mutex<Option<String>> = Mutex::new(None);18
static SOUND_OUTPUT: Mutex<Option<String>> = Mutex::new(None);19
static LOGGED_MISSES: LazyLock<Mutex<HashSet<String>>> =20
LazyLock::new(|| Mutex::new(HashSet::new()));12
21
13
pub fn set_sound_output(device_key: Option<String>) {22
pub fn set_sound_output(device_key: Option<String>) {14
*SOUND_OUTPUT.lock().unwrap_or_else(|p| p.into_inner()) = device_key;23
*SOUND_OUTPUT.lock().unwrap_or_else(|p| p.into_inner()) = device_key;15
}24
}16
25
17
/// True when a call-output key names this cpal device (id, friendly name, or Pulse-style id).26
/// One Pulse sink, as listed by the daemon.27
#[derive(Clone)]28
pub(crate) struct PulseSink {29
pub name: String,30
pub description: String,31
}32
33
/// Trim, drop one leading `default:` prefix, then ASCII-lowercase.34
pub(crate) fn normalized_audio_key(value: &str) -> String {35
let trimmed = value.trim();36
let rest = strip_default_prefix(trimmed).trim();37
rest.to_ascii_lowercase()38
}39
40
fn strip_default_prefix(value: &str) -> &str {41
const PREFIX: &str = "default:";42
if value.len() >= PREFIX.len() && value[..PREFIX.len()].eq_ignore_ascii_case(PREFIX) {43
&value[PREFIX.len()..]44
} else {45
value46
}47
}48
49
/// Exact name or description match. A Game sink does not satisfy a Chat key.50
pub(crate) fn matching_sink<'a>(sinks: &'a [PulseSink], key: &str) -> Option<&'a PulseSink> {51
let key = normalized_audio_key(key);52
if key.is_empty() {53
return None;54
}55
sinks.iter().find(|sink| {56
normalized_audio_key(&sink.name) == key || normalized_audio_key(&sink.description) == key57
})58
}59
60
/// True the first time this key is reported missing.61
fn claim_miss(key: &str) -> bool {62
LOGGED_MISSES63
.lock()64
.unwrap_or_else(|p| p.into_inner())65
.insert(key.to_owned())66
}67
68
fn note_missing_once(key: &str, message: String) {69
if claim_miss(key) {70
crate::diagnostics::record(message);71
}72
}73
74
/// True when a call-output key names this cpal device (id or friendly name).18
pub(crate) fn device_matches_key(device_id: &str, device_name: &str, key: &str) -> bool {75
pub(crate) fn device_matches_key(device_id: &str, device_name: &str, key: &str) -> bool {19
let key = key.trim();76
let key = key.trim();20
if key.is_empty() {77
if key.is_empty() {@@ -32,10 +89,61 @@ pub(crate) fn device_matches_key(device_id: &str, device_name: &str, key: &str)32
|| (key_lower.len() >= 4 && name_lower.contains(&key_lower))89
|| (key_lower.len() >= 4 && name_lower.contains(&key_lower))33
}90
}34
91
92
struct Decoded {93
rate: u32,94
channels: u16,95
samples: Vec<f32>,96
}97
98
fn decode(bytes: &[u8]) -> Result<Decoded, String> {99
let decoder = rodio::Decoder::try_from(Cursor::new(bytes.to_vec()))100
.map_err(|error| format!("cannot decode notification sound: {error}"))?;101
let rate = decoder.sample_rate().get();102
let channels = decoder.channels().get();103
let samples = decoder.collect();104
Ok(Decoded {105
rate,106
channels,107
samples,108
})109
}110
111
fn play_on_rodio(112
sink: &mut rodio::MixerDeviceSink,113
bytes: Vec<u8>,114
looped: bool,115
stop: &AtomicBool,116
) -> Result<(), String> {117
sink.log_on_drop(false);118
loop {119
if stop.load(Ordering::SeqCst) {120
return Ok(());121
}122
let player = rodio::play(sink.mixer(), Cursor::new(bytes.clone()))123
.map_err(|error| format!("cannot decode notification sound: {error}"))?;124
while !player.empty() {125
if stop.load(Ordering::SeqCst) {126
player.stop();127
return Ok(());128
}129
std::thread::sleep(POLL);130
}131
if !looped {132
return Ok(());133
}134
}135
}136
137
fn open_default_and_play(bytes: Vec<u8>, looped: bool, stop: &AtomicBool) -> Result<(), String> {138
let mut sink = rodio::DeviceSinkBuilder::open_default_sink()139
.map_err(|error| format!("cannot open audio output: {error}"))?;140
play_on_rodio(&mut sink, bytes, looped, stop)141
}142
35
fn open_sink() -> Result<rodio::MixerDeviceSink, String> {143
fn open_sink() -> Result<rodio::MixerDeviceSink, String> {36
let chosen = SOUND_OUTPUT144
let chosen = SOUND_OUTPUT37
.lock()145
.lock()38
.unwrap_or_else(|p| p.into_inner())146
.unwrap_or_else(|poisoned| poisoned.into_inner())39
.clone();147
.clone();40
if let Some(key) = chosen.as_ref() {148
if let Some(key) = chosen.as_ref() {41
if let Some(device) = rodio::cpal::default_host()149
if let Some(device) = rodio::cpal::default_host()@@ -68,34 +176,184 @@ fn open_sink() -> Result<rodio::MixerDeviceSink, String> {68
}176
}69
}177
}70
rodio::DeviceSinkBuilder::open_default_sink()178
rodio::DeviceSinkBuilder::open_default_sink()71
.map_err(|e| format!("cannot open audio output: {e}"))179
.map_err(|error| format!("cannot open audio output: {error}"))72
}180
}73
181
74
fn play(bytes: Vec<u8>, looped: bool, stop: Arc<AtomicBool>) -> Result<(), String> {182
#[cfg(target_os = "linux")]75
if stop.load(Ordering::SeqCst) {183
fn pulse_sinks() -> Option<Vec<PulseSink>> {76
return Ok(());184
use libpulse_binding::callbacks::ListResult;77
}185
use libpulse_binding::context::{Context, FlagSet, State};78
let mut sink = open_sink()?;186
use libpulse_binding::mainloop::standard::Mainloop;79
sink.log_on_drop(false);187
188
let mut mainloop = Mainloop::new()?;189
let mut context = Context::new(&mainloop, "rusty-teams")?;190
context.connect(None, FlagSet::NOAUTOSPAWN, None).ok()?;191
let deadline = std::time::Instant::now() + Duration::from_millis(400);80
loop {192
loop {81
if stop.load(Ordering::SeqCst) {193
if std::time::Instant::now() > deadline {82
return Ok(());194
return None;83
}195
}84
let player = rodio::play(sink.mixer(), Cursor::new(bytes.clone()))196
let _ = mainloop.iterate(false);85
.map_err(|e| format!("cannot decode notification sound: {e}"))?;197
match context.get_state() {86
while !player.empty() {198
State::Ready => break,199
State::Failed | State::Terminated => return None,200
_ => std::thread::sleep(Duration::from_millis(5)),201
}202
}203
let found = Arc::new(Mutex::new(Vec::new()));204
let done = Arc::new(AtomicBool::new(false));205
let found_cb = Arc::clone(&found);206
let done_cb = Arc::clone(&done);207
let operation = context208
.introspect()209
.get_sink_info_list(move |item| match item {210
ListResult::Item(info) => found_cb211
.lock()212
.unwrap_or_else(|poisoned| poisoned.into_inner())213
.push(PulseSink {214
name: info.name.as_deref().unwrap_or("").to_owned(),215
description: info.description.as_deref().unwrap_or("").to_owned(),216
}),217
ListResult::End | ListResult::Error => done_cb.store(true, Ordering::SeqCst),218
});219
while !done.load(Ordering::SeqCst) {220
if std::time::Instant::now() > deadline {221
return None;222
}223
let _ = mainloop.iterate(false);224
std::thread::sleep(Duration::from_millis(5));225
}226
drop(operation);227
Some(228
found229
.lock()230
.unwrap_or_else(|poisoned| poisoned.into_inner())231
.clone(),232
)233
}234
235
#[cfg(target_os = "linux")]236
fn play_on_pulse(237
sink_name: &str,238
decoded: &Decoded,239
looped: bool,240
stop: &AtomicBool,241
) -> Result<(), String> {242
use libpulse_binding::sample::{Format, Spec};243
use libpulse_binding::stream::Direction;244
use libpulse_simple_binding::Simple;245
246
let channels =247
u8::try_from(decoded.channels).map_err(|_| "too many audio channels".to_owned())?;248
let spec = Spec {249
format: Format::FLOAT32NE,250
channels,251
rate: decoded.rate,252
};253
if !spec.is_valid() {254
return Err(format!(255
"pulse cannot play {} Hz {} ch",256
decoded.rate, decoded.channels257
));258
}259
let simple = Simple::new(260
None,261
"rusty-teams",262
Direction::Playback,263
Some(sink_name),264
"call tone",265
&spec,266
None,267
None,268
)269
.map_err(|error| format!("pulse open {sink_name}: {error}"))?;270
let frame = decoded.channels as usize;271
let chunk = (decoded.rate as usize / 10).max(1) * frame.max(1);272
loop {273
for piece in decoded.samples.chunks(chunk.max(1)) {87
if stop.load(Ordering::SeqCst) {274
if stop.load(Ordering::SeqCst) {88
player.stop();89
return Ok(());275
return Ok(());90
}276
}91
std::thread::sleep(POLL);277
let mut bytes = Vec::with_capacity(piece.len() * 4);278
for sample in piece {279
bytes.extend_from_slice(&sample.to_ne_bytes());280
}281
simple282
.write(&bytes)283
.map_err(|error| format!("pulse write: {error}"))?;92
}284
}93
if !looped {285
if !looped {286
simple287
.drain()288
.map_err(|error| format!("pulse drain: {error}"))?;94
return Ok(());289
return Ok(());95
}290
}96
}291
}97
}292
}98
293
294
#[cfg(target_os = "linux")]295
fn play_linux(bytes: Vec<u8>, looped: bool, stop: &AtomicBool) -> Result<(), String> {296
let key = SOUND_OUTPUT297
.lock()298
.unwrap_or_else(|poisoned| poisoned.into_inner())299
.clone();300
if let Some(key) = key.filter(|key| !normalized_audio_key(key).is_empty()) {301
match pulse_sinks() {302
Some(sinks) => {303
if let Some(sink) = matching_sink(&sinks, &key) {304
let decoded = decode(&bytes)?;305
match play_on_pulse(&sink.name, &decoded, looped, stop) {306
Ok(()) => return Ok(()),307
Err(error)308
if error.starts_with("pulse open ")309
|| error.starts_with("pulse cannot play")310
|| error.starts_with("pulse write")311
|| error.starts_with("pulse drain") =>312
{313
note_missing_once(314
&key,315
format!(316
"sound: selected output {key:?} failed ({error}), using system default"317
),318
);319
}320
Err(error) => return Err(error),321
}322
} else {323
note_missing_once(324
&key,325
format!("sound: selected output {key:?} not found, using system default"),326
);327
}328
}329
None => {330
note_missing_once(331
&format!("pulse:{key}"),332
format!("sound: pulse unavailable for {key:?}, trying the device list"),333
);334
let mut sink = open_sink()?;335
return play_on_rodio(&mut sink, bytes, looped, stop);336
}337
}338
}339
open_default_and_play(bytes, looped, stop)340
}341
342
fn play(bytes: Vec<u8>, looped: bool, stop: Arc<AtomicBool>) -> Result<(), String> {343
if stop.load(Ordering::SeqCst) {344
return Ok(());345
}346
#[cfg(target_os = "linux")]347
{348
return play_linux(bytes, looped, &stop);349
}350
#[cfg(not(target_os = "linux"))]351
{352
let mut sink = open_sink()?;353
play_on_rodio(&mut sink, bytes, looped, &stop)354
}355
}356
99
pub fn play_mp3_until(bytes: Vec<u8>, looped: bool, stop: Arc<AtomicBool>) {357
pub fn play_mp3_until(bytes: Vec<u8>, looped: bool, stop: Arc<AtomicBool>) {100
std::thread::spawn(move || {358
std::thread::spawn(move || {101
if let Err(error) = play(bytes, looped, stop) {359
if let Err(error) = play(bytes, looped, stop) {@@ -116,6 +374,20 @@ pub fn play_sound() {116
mod tests {374
mod tests {117
use super::*;375
use super::*;118
376
377
fn sink(name: &str, description: &str) -> PulseSink {378
PulseSink {379
name: name.to_owned(),380
description: description.to_owned(),381
}382
}383
384
fn headset_sinks() -> Vec<PulseSink> {385
vec![386
sink("alsa_output.headset.mono-chat", "Headset Chat"),387
sink("alsa_output.headset.stereo-game", "Headset Game"),388
]389
}390
119
#[test]391
#[test]120
fn bundled_notification_decodes_to_audible_samples() {392
fn bundled_notification_decodes_to_audible_samples() {121
let decoded = rodio::Decoder::try_from(Cursor::new(SOUND_BYTES)).unwrap();393
let decoded = rodio::Decoder::try_from(Cursor::new(SOUND_BYTES)).unwrap();@@ -153,6 +425,28 @@ mod tests {153
assert!(!device_matches_key("id", "Speaker", ""));425
assert!(!device_matches_key("id", "Speaker", ""));154
}426
}155
427
428
#[test]429
fn a_pulse_description_selects_that_sink_and_not_the_other_output() {430
let sinks = headset_sinks();431
let game = matching_sink(&sinks, "Headset Game").unwrap();432
assert_eq!(game.name, "alsa_output.headset.stereo-game");433
let prefixed = matching_sink(&sinks, "default: Headset Game").unwrap();434
assert_eq!(prefixed.name, "alsa_output.headset.stereo-game");435
let chat = matching_sink(&sinks, "Headset Chat").unwrap();436
assert_eq!(chat.name, "alsa_output.headset.mono-chat");437
assert!(matching_sink(&sinks, "Headset Game").unwrap().name != chat.name);438
assert!(matching_sink(&sinks, "missing output").is_none());439
assert!(matching_sink(&sinks, "Game").is_none());440
}441
442
#[test]443
fn a_missing_key_is_noted_once() {444
let key = format!("missing-output-{}", std::process::id());445
assert!(claim_miss(&key));446
assert!(!claim_miss(&key));447
assert!(claim_miss(&format!("{key}-other")));448
}449
156
#[test]450
#[test]157
#[ignore = "plays a short notification on the real default audio output"]451
#[ignore = "plays a short notification on the real default audio output"]158
fn notification_plays_on_default_output() {452
fn notification_plays_on_default_output() {@@ -163,4 +457,30 @@ mod tests {163
)457
)164
.unwrap();458
.unwrap();165
}459
}460
461
#[cfg(target_os = "linux")]462
#[test]463
#[ignore = "plays a short tone on the Pulse sink named by CALL_OUTPUT_KEY"]464
fn selected_pulse_sink_plays_the_tone() {465
let key = std::env::var("CALL_OUTPUT_KEY").expect("CALL_OUTPUT_KEY");466
let sinks = pulse_sinks().expect("pulse");467
let sink = matching_sink(&sinks, &key).unwrap_or_else(|| {468
panic!(469
"no sink for {key:?}; have {}",470
sinks471
.iter()472
.map(|sink| format!("{} ({})", sink.description, sink.name))473
.collect::<Vec<_>>()474
.join(", ")475
)476
});477
eprintln!("pulse sink {} ({})", sink.name, sink.description);478
set_sound_output(Some(key));479
play(480
SOUND_BYTES.to_vec(),481
false,482
Arc::new(AtomicBool::new(false)),483
)484
.unwrap();485
}166
}486
}@@ -27,12 +27,13 @@ conflicts:
27
27
- teams
28
28
29
29
# Linked directly (ELF NEEDED): glibc, libstdc++, libgcc_s, glib/gio/gobject, ALSA, fontconfig,
30
# freetype, xcb, xkbcommon and xkbcommon-x11. Loaded at runtime with dlopen, so the package
31
# tools can't see them: Wayland (libwayland-client) and X11 (libX11) for the window, Vulkan or
32
# EGL for wgpu. libwebrtc dlopens the rest only for calls (PulseAudio, PipeWire for Wayland
33
# screen sharing, VA-API/GBM/DRM for hardware video, the X11 extensions for X11 screen
34
# capture), so those are recommended rather than required. The Teams session runs in the
35
# user's own browser, suggested below.
30
# freetype, xcb, xkbcommon, xkbcommon-x11, libpulse and libpulse-simple. Call tones link Pulse
31
# at build time, so a host without those sonames cannot start the binary. Loaded at runtime
32
# with dlopen, so the package tools can't see them: Wayland (libwayland-client) and X11
33
# (libX11) for the window, Vulkan or EGL for wgpu. libwebrtc dlopens the rest only for calls
34
# (PipeWire for Wayland screen sharing, VA-API/GBM/DRM for hardware video, the X11 extensions
35
# for X11 screen capture), so those stay recommended. The Teams session runs in the user's
36
# own browser, suggested below.
36
37
overrides:
37
38
deb:
38
39
depends:
@@ -49,11 +50,11 @@ overrides:
49
50
- libwayland-client0
50
51
- libx11-6
51
52
- libvulkan1 | libegl1
53
- libpulse0
52
54
recommends:
53
55
- mesa-vulkan-drivers
54
56
- libegl1
55
57
- libwayland-egl1
56
- libpulse0
57
58
- libpipewire-0.3-0
58
59
- libva2
59
60
- libva-drm2
@@ -85,9 +86,10 @@ overrides:
85
86
- libwayland-client.so.0()(64bit)
86
87
- libX11.so.6()(64bit)
87
88
- (libvulkan.so.1()(64bit) or libEGL.so.1()(64bit))
89
- libpulse.so.0()(64bit)
90
- libpulse-simple.so.0()(64bit)
88
91
recommends:
89
92
- mesa-vulkan-drivers
90
- libpulse.so.0()(64bit)
91
93
- libpipewire-0.3.so.0()(64bit)
92
94
- libva.so.2()(64bit)
93
95
- libgbm.so.1()(64bit)
@@ -106,9 +108,9 @@ overrides:
106
108
- libx11
107
109
- vulkan-icd-loader
108
110
- libglvnd
111
- libpulse
109
112
recommends:
110
113
- mesa
111
- libpulse
112
114
- pipewire
113
115
- libva
114
116
- xdg-desktop-portal
@@ -27,12 +27,13 @@ conflicts:27
- teams27
- teams28
28
29
# Linked directly (ELF NEEDED): glibc, libstdc++, libgcc_s, glib/gio/gobject, ALSA, fontconfig,29
# Linked directly (ELF NEEDED): glibc, libstdc++, libgcc_s, glib/gio/gobject, ALSA, fontconfig,30
# freetype, xcb, xkbcommon and xkbcommon-x11. Loaded at runtime with dlopen, so the package30
# freetype, xcb, xkbcommon, xkbcommon-x11, libpulse and libpulse-simple. Call tones link Pulse31
# tools can't see them: Wayland (libwayland-client) and X11 (libX11) for the window, Vulkan or31
# at build time, so a host without those sonames cannot start the binary. Loaded at runtime32
# EGL for wgpu. libwebrtc dlopens the rest only for calls (PulseAudio, PipeWire for Wayland32
# with dlopen, so the package tools can't see them: Wayland (libwayland-client) and X1133
# screen sharing, VA-API/GBM/DRM for hardware video, the X11 extensions for X11 screen33
# (libX11) for the window, Vulkan or EGL for wgpu. libwebrtc dlopens the rest only for calls34
# capture), so those are recommended rather than required. The Teams session runs in the34
# (PipeWire for Wayland screen sharing, VA-API/GBM/DRM for hardware video, the X11 extensions35
# user's own browser, suggested below.35
# for X11 screen capture), so those stay recommended. The Teams session runs in the user's36
# own browser, suggested below.36
overrides:37
overrides:37
deb:38
deb:38
depends:39
depends:@@ -49,11 +50,11 @@ overrides:49
- libwayland-client050
- libwayland-client050
- libx11-651
- libx11-651
- libvulkan1 | libegl152
- libvulkan1 | libegl153
- libpulse052
recommends:54
recommends:53
- mesa-vulkan-drivers55
- mesa-vulkan-drivers54
- libegl156
- libegl155
- libwayland-egl157
- libwayland-egl156
- libpulse057
- libpipewire-0.3-058
- libpipewire-0.3-058
- libva259
- libva259
- libva-drm260
- libva-drm2@@ -85,9 +86,10 @@ overrides:85
- libwayland-client.so.0()(64bit)86
- libwayland-client.so.0()(64bit)86
- libX11.so.6()(64bit)87
- libX11.so.6()(64bit)87
- (libvulkan.so.1()(64bit) or libEGL.so.1()(64bit))88
- (libvulkan.so.1()(64bit) or libEGL.so.1()(64bit))89
- libpulse.so.0()(64bit)90
- libpulse-simple.so.0()(64bit)88
recommends:91
recommends:89
- mesa-vulkan-drivers92
- mesa-vulkan-drivers90
- libpulse.so.0()(64bit)91
- libpipewire-0.3.so.0()(64bit)93
- libpipewire-0.3.so.0()(64bit)92
- libva.so.2()(64bit)94
- libva.so.2()(64bit)93
- libgbm.so.1()(64bit)95
- libgbm.so.1()(64bit)@@ -106,9 +108,9 @@ overrides:106
- libx11108
- libx11107
- vulkan-icd-loader109
- vulkan-icd-loader108
- libglvnd110
- libglvnd111
- libpulse109
recommends:112
recommends:110
- mesa113
- mesa111
- libpulse112
- pipewire114
- pipewire113
- libva115
- libva114
- xdg-desktop-portal116
- xdg-desktop-portal