Skip to content

App device routing - #123

Merged
G-Stas merged 12 commits into
mainfrom
feature/app-routing
Oct 30, 2026
Merged

G-Stas merged 12 commits into
mainfrom
feature/app-routing

Conversation

@G-Stas

@G-Stas G-Stas commented Oct 29, 2026

Copy link
Copy Markdown
Owner
  • Move an app to another output device from the mixer: open the app, pick a device. Undo for 5 seconds
  • An app pinned to a device shows the device's name
  • App and foreground-app hotkeys reach the app on every device

Closes #14

…tory

IAppAudioRouting with AudioPolicyRouting: the undocumented WinRT factory
Windows.Media.Internal.AudioPolicyConfig (AudioSes.dll), picked by the
interface IDs it lists (Windows 11 ab3d4648, Windows 10 2a59116d) and called
through its vtable with raw HSTRINGs. Every answer of Windows is a result
value; an unknown interface makes the feature unavailable with one warning.
Registered in DI, not used yet.
AppRoutingRules: one app across devices (grouping parameter or file, linked
transitively), the route as seen from one device, whether a row belongs in a
device's list, the app's home row, when a volume copy applies, and the outcome
of a move from Windows' answer for each process.
AppRouting reads every app's route from Windows on one worker and sets
Route, RouteDeviceName and PlaysHere on its models; triggers (a session
starting or stopping, apps or devices coming and going, the default device
changing) only mark the app as waiting. Moves set all processes of the app,
and the app's volume and mute are copied once to the device it moved to when
it first plays there. Sessions know whether they play (registered before the
state is read), device models group sessions by the shared SameApp rule, and
inactive devices are named through the device enumerator.
Created at start; no UI yet.
A move's log and volume copy step is skipped after Dispose and its result is
cancelled; a failed read after a move Windows made still reports the move.
The factory file keeps its byte order mark.
Every app that can be moved opens from its icon (System Sounds only with
several sessions) and shows a device box before its sessions: "Default
device" with the current default, then each active device; a pinned device
that isn't active is the last item, greyed, only its icon when Windows can't
name it. Picking a device moves the app; a notice above the bottom bar says
where it is set to play, with Undo for 5 s, or that the move failed.
A pinned app shows its device's name next to its name, and rows of apps
that play on another device are hidden. Opening the mixer reads every
app's route again. Five strings in all languages.
App and foreground-app hotkeys find apps on every device through
AppRouting: a saved app's hotkeys sit on its home model (where it is set to
play; Windows refuses a combination twice) and move when that changes,
and a press gives every model of the app the same volume or mute. An app
that only plays on another device gets its hotkeys too. The same-app rule
no longer takes an empty grouping parameter or path as shared.
A1 opens the test app's box and checks it lists the default device and every output device without changing anything. A2 moves a test app with its own executable to another device, checks the notice, box and badge, presses Undo, and always puts it back; inconclusive with one output device.
While a pinned device is disabled or unplugged, Windows plays the app on the
default device, and when the device returns it reports the pin again but
leaves the app where it is: the app only hears of its route when it's set.
When a device becomes active, apps pinned to it that don't play there are
set to it again.
Each Set makes the app reopen its stream, and refreshes before it plays on the returned device would set it again; an app is sent back once per return, and again if the device leaves and returns once more.
@G-Stas
G-Stas marked this pull request as ready for review October 30, 2026 00:56
The test audio app gets --routing (Windows' automatic stream routing, so it
moves at once like a real player). The UI tests read, set and reset an
app's route through Windows' audio policy (the app's interop files compiled
into the tests) and can turn a second device off and on; they never touch a
default device or a device another app plays on.
New tests: a move plays there, leaves the default's list and comes back with
Undo; the moved app is listed on its device with the device's name; it keeps
its volume; it goes back to its device when the device is turned on again;
a route set outside Volumey shows; app hotkeys reach the app on its new device.
The scenario IDs of the plan don't belong in the code; the test names say what each checks.
-AppDir points it at another Debug build, e.g. a trimmed self-contained publish, instead of the one in bin.
@G-Stas
G-Stas merged commit 8ca7c21 into main Oct 30, 2026
2 checks passed
@G-Stas
G-Stas deleted the feature/app-routing branch November 3, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Change output device of each application

1 participant