cliamp moves into the plugin, and the platform loses its last music file
The owner read the code and asked why `plugins/music/api/router.ts` was three
lines importing `@@/api/music/router` — platform code that knows the string
'music'. He was right, and tracing it found the justification was hollow.
The chain: server.tsx:20 imported the cliamp relay's two exports, which are
used only on commented-out lines; so the relay's functions were never invoked;
so its call to getMusicServerWsUrl never ran; and the file's other export,
getMusicServerUrl, had no consumers at all. A dead import held a music-named
file in the platform, and I documented that as a "seam" last night after
checking the import existed and stopping there.
Everything cliamp now lives in plugins/music/cliamp/:
sidecar/music/{cliamp-ws,pulse-audio}.ts, asoundrc, the test
api/cliamp/relay.ts
apps/FileBrowser/{CliampPanel,AudioStreamPlayer}.tsx
src/servers/sidecar/music/, src/servers/api/cliamp/ and src/servers/api/music/
are gone. server.tsx has no cliamp import, provider name, handler entry or
route. The platform contains no file named for music or cliamp.
Two of the things that moved were live, not inert.
The file browser's `Play` context-menu item, on any audio file or folder, set
?play= and rendered a cliamp terminal pointed at /api/cliamp/ws — a route that
upgraded into a handlers entry that was commented out, so handlers[provider]!
asserted non-null on undefined. Using that menu item crashed the socket
handler. Removed: the action, the layout, the panel wiring and both menu
entries. Verified the routes now 404 rather than crash.
That closed the totality drift as a side effect. server.tsx's route table and
its handlers map agree again for the first time since 2026-08-13, and
registry.test.ts now asserts it rather than pinning the hole.
The proxy is built in the plugin now, and its prefix is DERIVED. It was the
literal '/api/music', which the proxy uses to strip characters off the path —
correct only because mountPrefix returns /music for a first-party publisher.
The same plugin published by anyone else mounts at /api/p/<publisher>/music and
would have forwarded /alice/music/stream to a sidecar expecting /stream. A
latent bug only third parties would ever hit, and a quiet violation of the rule
that mountPrefix is the one function allowed to know about provenance. Offscale
has the identical hardcode and still needs it.
Still open there: appName is passed as a literal, because a plugin's router
cannot see its own directory name — the platform imports the module and reads
`router`, so there is nowhere to inject it. The fix is a factory the installer
calls with the plugin's identity.
Plugin backend coupling is down to 7 imports, all of them "a plugin talks to
its host": data-path, sidecar/connect, sidecar/protocol, officer-url, the
manifest type, officerdb/db and the users.id FK. Nothing music-shaped left.
bunx tsgo clean. 797 tests, 787 pass, same 7 pre-existing failures. Verified
live: manifest 200, favorites 200, stream 206, /api/cliamp/ws 404.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
// Host audio plumbing for local playback: a PulseAudio daemon and a null sink named `virtual_out`.
|
||||
// cliamp plays *into* that sink (PULSE_SINK) and the capture side reads `virtual_out.monitor`, so the
|
||||
// sink has to exist before either of them starts — which is why this runs at sidecar startup rather
|
||||
// than on first play. Both steps are idempotent and both failures are non-fatal: a host without
|
||||
// pulseaudio simply has no browser playback, and everything else the music sidecar does still works.
|
||||
|
||||
export const VIRTUAL_SINK = 'virtual_out';
|
||||
|
||||
export function ensurePulseAudio(): void {
|
||||
const pulseaudio = Bun.which('pulseaudio');
|
||||
const pactl = Bun.which('pactl');
|
||||
if (!pulseaudio || !pactl) {
|
||||
console.log('[music] pulseaudio not installed, skipping audio setup');
|
||||
return;
|
||||
}
|
||||
|
||||
const check = Bun.spawnSync({ cmd: [pulseaudio, '--check'], stdout: 'ignore', stderr: 'ignore' });
|
||||
if (check.exitCode !== 0) {
|
||||
const start = Bun.spawnSync({ cmd: [pulseaudio, '--start', '-D'], stdout: 'ignore', stderr: 'ignore' });
|
||||
if (start.exitCode !== 0) {
|
||||
console.error('[music] failed to start pulseaudio');
|
||||
return;
|
||||
}
|
||||
console.log('[music] pulseaudio started');
|
||||
} else {
|
||||
console.log('[music] pulseaudio already running');
|
||||
}
|
||||
|
||||
const sinks = Bun.spawnSync({ cmd: [pactl, 'list', 'short', 'sinks'], stdout: 'pipe', stderr: 'ignore' });
|
||||
if (sinks.stdout.toString().includes(VIRTUAL_SINK)) {
|
||||
console.log(`[music] ${VIRTUAL_SINK} sink already exists`);
|
||||
return;
|
||||
}
|
||||
|
||||
const load = Bun.spawnSync({
|
||||
cmd: [
|
||||
pactl,
|
||||
'load-module',
|
||||
'module-null-sink',
|
||||
`sink_name=${VIRTUAL_SINK}`,
|
||||
'sink_properties=device.description=Virtual_Output',
|
||||
],
|
||||
stdout: 'pipe',
|
||||
stderr: 'pipe',
|
||||
});
|
||||
if (load.exitCode !== 0) console.error('[music] failed to load null sink:', load.stderr.toString().trim());
|
||||
else console.log(`[music] ${VIRTUAL_SINK} null sink loaded`);
|
||||
}
|
||||
Reference in New Issue
Block a user