System-wide speakup

From JookWiki
Revision as of 07:55, 11 October 2022 by Jookia (talk | contribs) (Initial commit)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

WIP WIP WIP, idea dump for now, rename to Linux systemwide audio

is it possible to play audio as two users on the same computer? today we find out!

first attempt: shared group for audio device

result: fails if root plays audio first

second attempt: shared group for audio device + alsa dmix

result: works, but pulse bypasses this and locks the sound card anyway

system and pulseaudio coordinate will snatch the audio whenever you change to a seat assigned to your user. maybe you could modify these to not cede the audio outside a specific seat (in this case seat = virtual tty you switch in linux with ctrl alt f1 through f7)?

so there's two solutions here:

1. systemwide audio?

2. rewriting the program to run as multiple users?

here's some more nightmare stuff i realized: seats only give permission to device nodes. applications still have to gracefully hand off the hardware during a seat switch. pulse does this just by shutting up

in fact if pulse tries to start and it doesn't immediately get hardware access on login it will freak the FUCK out and give you a dummy output that can't output anything

so the new idea is this:

- have a proxy that sits between speakup and espeak

- send messages to espeakup instances based on current active UID

- during a switch between instances, wait for the current instance to finish talking OR the stop talking control is sent. then start feeding the new instance data

- have a shim that blocks pulseaudio from starting until it has permission, but also don't consume the buffer

i do not like how i'm basically reinventing flow control but poorly

ok so it turns out i was WRONG: you can't share speakup protocol between multiple synths! the protocol is stateful! ie if you tell it to change voice and switch synth the voice change won't be applied. YAY

so this makes the only viable solution to send PCM data from a root espeakup instance.

on top of that this also means i have to modify espeakup to handle some flow control AND output to a buffer instead of the sound card

pulseaudio doesn't gracefully give up audio, only alsa -> pulseaudio