Sounds and streams output device carries every sound but the voices (#1000) #1006

Closed
charles wants to merge 0 commits from feat-1000-app-sounds-output into textchat
Owner

Closes #1000

What changed. When "Stream output device" names a device other than the output device, every sound the app plays now goes there except people's voices. Before, only the sound of watched streams did. The setting is renamed "Sounds and streams output device", with a help line under the label: "Every sound except voices: streams, call and notification sounds, soundboard, videos." The first option is still "Same as output device". The stored key (stream_output_device) and the action (SetStreamOutputDevice) have not changed, so existing choices are kept. With "Same as output device" (the default) everything plays on the single output as before.

Cause. The second output added in #950 routed by is_stream, so it only ever received SourceId::Stream.

How a sound's device is decided. One pure function, fluxer_audio::output_route(&SourceId) -> OutputRoute::{Voice, Sound}, is an exhaustive match, so any new kind of source has to be assigned a side:

  • Voice (always on the output device): Remote (participants' microphones) and MicTest (your own microphone looped back in the settings test, so you hear yourself as the others do).
  • Sound (on the sounds device when one is set): Stream (watched streams), Clip (soundboard sounds heard in the call and their previews, entrance sounds, local trimmer previews, attachments), Chime (join, leave, move, mute, unmute, deafen, undeafen, disconnect, viewer join and leave, incoming call, stream start and stop, camera on and off, and notification-sound previews; message sounds are not played by the client yet) and Media (the audio of videos and other media in chat: fluxer-media-playback → media_rt → AudioEngine::open_media).

Decision for you to check: the soundboard counts as a sound, not a voice. It plays on the sounds device. If you would rather hear it with the voices, the change is one line in output_route.

Engine (crates/fluxer-audio/src/engine.rs).

  • Each sound is in exactly one mixer at a time. A sounds_on_second flag records which one, and only route_sounds changes it, moving the sounds together with their queued audio. Every push (stream frames, clip and chime frames, media frames) goes to the mixer the sound is in. So when the route changes, or the device is lost, opened or closed, nothing queued is dropped or played twice. The only loss is what the closed device's playout ring held at that moment (about 30 ms).
  • Clips are fed to the mixer they are in, and finished from it. Media are fed and credited (their clock) the same way. output_latency (used for video A/V sync) now follows the device the media play on.
  • Gains for sounds (set_gain, clip and chime gains, MediaAudio::set_gain) are kept in both mixers. Stream volume, soundboard volume, mute, deafen and output volume therefore apply on whichever device plays.
  • A chime or a playing video now opens the second output, just as it opens the main one. A chime with no call in progress opens the second output and closes it after the same 2 s linger, without opening the main output. If the second device is lost or cannot be opened, the sounds fall back to the output device until the devices change, as before. RemoveAllRemote and idle removal in the second mixer now only touch participants' tracks, never clips or media.

Log lines (device name only): "voice: sounds and streams output opened / closed / lost; sounds and streams play on the output device / could not be opened; …".

Tests

  • Unit test engine::tests::every_source_has_its_output: the classification of every SourceId, plus which sources count as participants.
  • Engine tests on the NullHost:
    • every_kind_of_sound_plays_on_the_sounds_output_device_alone: chime, soundboard clip, media and stream each open only the headset and play there. With "Same as output device" each opens only the speakers.
    • the_voices_stay_on_the_output_device_while_the_sounds_play_on_their_own: the voice is alone on the speakers; the clip at gain 0.5 and the video at 0.25 play on the headset at those levels; gain 0 silences them there.
    • a_sound_playing_when_the_device_changes_moves_along_once: a 1 s clip, switched to "Same as output device" and back in the middle. The speakers and headset together play about 970 ms of it, and the clip finishes exactly once.
    • a_lost_sounds_output_device_takes_the_sounds_to_the_output_and_back: unplugging the headset sends the clip to the speakers; replugging brings it back.
    • sounds_play_on_the_output_device_when_theirs_cannot_be_opened
    • a_chime_outside_a_call_opens_the_sounds_output_and_lets_it_close
    • callbacks_do_not_allocate now also plays a clip and a chime on the second output (both outputs covered).
  • The existing #933 tests pass unchanged.
  • UI: settings_voice checks the new label and help line.
  • audio_rt: the log-line test is updated.

Goldens re-rendered on lavapipe (fluxer-native-shots:u2204); only these four changed: settings_voice, settings_camera_test, voice_devices_linux_default, voice_ptt_notice.

Docs: the READMEs of fluxer-audio, fluxer-core, fluxer-ui and apps/fluxer are updated, and the parity entry voice-video-stream-output-device now gives the new label and the wider scope (still native only).

Verified: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci → ==> xtask ci: all steps passed.

To check by ear, with the sounds device set to a second device:

  • mute/unmute, deafen, someone joining or leaving, and disconnect chimes;
  • a notification-sound "Preview sound" with no call in progress (the device should close about 2 s later);
  • a soundboard sound in a call and its preview;
  • a video with sound in chat (also check that its picture stays in sync);
  • a watched stream;
  • the microphone test, which should stay on the output device;
  • unplugging and replugging that device in the middle of a sound.

🤖 Generated with Claude Code

Closes #1000 **What changed.** When "Stream output device" names a device other than the output device, every sound the app plays now goes there except people's voices. Before, only the sound of watched streams did. The setting is renamed **"Sounds and streams output device"**, with a help line under the label: "Every sound except voices: streams, call and notification sounds, soundboard, videos." The first option is still "Same as output device". The stored key (`stream_output_device`) and the action (`SetStreamOutputDevice`) have not changed, so existing choices are kept. With "Same as output device" (the default) everything plays on the single output as before. **Cause.** The second output added in #950 routed by `is_stream`, so it only ever received `SourceId::Stream`. **How a sound's device is decided.** One pure function, `fluxer_audio::output_route(&SourceId) -> OutputRoute::{Voice, Sound}`, is an exhaustive match, so any new kind of source has to be assigned a side: - **Voice** (always on the output device): `Remote` (participants' microphones) and `MicTest` (your own microphone looped back in the settings test, so you hear yourself as the others do). - **Sound** (on the sounds device when one is set): `Stream` (watched streams), `Clip` (soundboard sounds heard in the call and their previews, entrance sounds, local trimmer previews, attachments), `Chime` (join, leave, move, mute, unmute, deafen, undeafen, disconnect, viewer join and leave, incoming call, stream start and stop, camera on and off, and notification-sound previews; message sounds are not played by the client yet) and `Media` (the audio of videos and other media in chat: `fluxer-media-playback` → `media_rt` → `AudioEngine::open_media`). **Decision for you to check: the soundboard counts as a sound, not a voice.** It plays on the sounds device. If you would rather hear it with the voices, the change is one line in `output_route`. **Engine (`crates/fluxer-audio/src/engine.rs`).** - Each sound is in exactly one mixer at a time. A `sounds_on_second` flag records which one, and only `route_sounds` changes it, moving the sounds together with their queued audio. Every push (stream frames, clip and chime frames, media frames) goes to the mixer the sound is in. So when the route changes, or the device is lost, opened or closed, nothing queued is dropped or played twice. The only loss is what the closed device's playout ring held at that moment (about 30 ms). - Clips are fed to the mixer they are in, and finished from it. Media are fed and credited (their clock) the same way. `output_latency` (used for video A/V sync) now follows the device the media play on. - Gains for sounds (`set_gain`, clip and chime gains, `MediaAudio::set_gain`) are kept in both mixers. Stream volume, soundboard volume, mute, deafen and output volume therefore apply on whichever device plays. - A chime or a playing video now opens the second output, just as it opens the main one. A chime with no call in progress opens the second output and closes it after the same 2 s linger, without opening the main output. If the second device is lost or cannot be opened, the sounds fall back to the output device until the devices change, as before. `RemoveAllRemote` and idle removal in the second mixer now only touch participants' tracks, never clips or media. **Log lines** (device name only): "voice: sounds and streams output opened / closed / lost; sounds and streams play on the output device / could not be opened; …". **Tests** - Unit test `engine::tests::every_source_has_its_output`: the classification of every `SourceId`, plus which sources count as participants. - Engine tests on the `NullHost`: - `every_kind_of_sound_plays_on_the_sounds_output_device_alone`: chime, soundboard clip, media and stream each open only the headset and play there. With "Same as output device" each opens only the speakers. - `the_voices_stay_on_the_output_device_while_the_sounds_play_on_their_own`: the voice is alone on the speakers; the clip at gain 0.5 and the video at 0.25 play on the headset at those levels; gain 0 silences them there. - `a_sound_playing_when_the_device_changes_moves_along_once`: a 1 s clip, switched to "Same as output device" and back in the middle. The speakers and headset together play about 970 ms of it, and the clip finishes exactly once. - `a_lost_sounds_output_device_takes_the_sounds_to_the_output_and_back`: unplugging the headset sends the clip to the speakers; replugging brings it back. - `sounds_play_on_the_output_device_when_theirs_cannot_be_opened` - `a_chime_outside_a_call_opens_the_sounds_output_and_lets_it_close` - `callbacks_do_not_allocate` now also plays a clip and a chime on the second output (both outputs covered). - The existing #933 tests pass unchanged. - UI: `settings_voice` checks the new label and help line. - `audio_rt`: the log-line test is updated. **Goldens** re-rendered on lavapipe (`fluxer-native-shots:u2204`); only these four changed: `settings_voice`, `settings_camera_test`, `voice_devices_linux_default`, `voice_ptt_notice`. **Docs:** the READMEs of fluxer-audio, fluxer-core, fluxer-ui and apps/fluxer are updated, and the parity entry `voice-video-stream-output-device` now gives the new label and the wider scope (still native only). **Verified:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` → `==> xtask ci: all steps passed`. **To check by ear,** with the sounds device set to a second device: - mute/unmute, deafen, someone joining or leaving, and disconnect chimes; - a notification-sound "Preview sound" with no call in progress (the device should close about 2 s later); - a soundboard sound in a call and its preview; - a video with sound in chat (also check that its picture stays in sync); - a watched stream; - the microphone test, which should stay on the output device; - unplugging and replugging that device in the middle of a sound. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With "Stream output device" set to another device, only the watched streams'
sound played there. Now every mixer source that is not a voice does: the
streams, chimes (call and notification sounds and their previews), clips
(soundboard heard and previewed, entrance sounds) and media in chat. The
participants' microphones and the microphone test stay on the output device.

One rule decides it: fluxer_audio::output_route, an exhaustive match over
SourceId. The engine keeps the sounds in exactly one mixer (sounds_on_second,
changed only by route_sounds, which moves them with their queues), feeds clips
and media to the mixer they are in, keeps their gains in both mixers, lets a
chime open the second output and closes it after the same 2 s linger, and
falls back to the output device when it is lost or cannot be opened.
output_latency follows the device the media play on.

The setting is now labelled "Sounds and streams output device" with a help
line; its stored key (stream_output_device) and action are unchanged. Log
lines read "voice: sounds and streams output …".

Refs #1000

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Merged by hand into textchat (8f270714) with the other open PRs; the combined tree passed the full gate locally, LiveKit interop included.

Merged by hand into textchat (8f270714) with the other open PRs; the combined tree passed the full gate locally, LiveKit interop included.
charles closed this pull request 2026-11-20 07:25:22 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.