Repository navigation
SAPI: survive marshaling and output-format gaps in initialize() - #144
Conversation
|
Can we identify what's causing the crashes and determine if they are Wine's problem or ours? If they are ours, I'd like to get an implementation in that eliminates them if possible. |
|
If by crashes you mean the post-initialization crashes, they're almost certainly a separate issue and are very likely mod-specific. I should have been clearer--Prism often works flawlessly, and when it does crash post-initialization it's often after tens of minutes to hours of gameplay, and in mods with various crash fixes in their changelogs. I wouldn't attribute those to this fix--without this the mods don't speak at all, with it they generally work as fine as I'd expect them to under Windows. If you mean the initialization crashes, it looks like Wine is shipping a slightly newer SAPI than Valve packages for Steam OS, and Wine's implementations of the functions SAPI needs are stubs. An actual fix to run Prism unmodified would happen in Wine itself, by Wine implementing more of SAPI. |
Disclosure: generated with Claude and I don't fully understand what's going on from first principles, likely because I'm not familiar with how SAPI works.
I'm working on a project to run unmodified Windows accessibility mods under Proton and stock Steam OS. A decent while back, maybe a couple months ago, I hit an issue where mods refused to speak at all despite everything appearing to be correctly set up. Since Claude is good at rapid-fire brute-force fixes, I turned it loose on the problem. Within a few minutes it had the game in question speaking just fine.
I've been a bit hesitant to finalize this because submitting PRs I don't understand makes me squeamish. Nevertheless, I've had it running across Balatro, The Witcher 3, and Darkest Dungeon, under Proton, for at least a couple months now, using Valve's Piper-based SAPI plugin for Proton. There have been occasional crashes where speech has died, so there may still be lingering issues, but they're infrequent enough and seem to happen with Tolk SAPI integration as well, so they could be issues specific to Valve's SAPI shim.
Below is Claude's description of its work, lightly edited for stupidity. I'm also not clear how much of this is specific to Valve's specific installable Piper-based SAPI which, AFAICT, provides just enough for speech and not a whole lot more.
Wine's SAPI implementation fails initialize() for two reasons that don't actually prevent
speech:
CoMarshalInterThreadInterfaceInStream always fails because no
proxy/stub is registered for ISpVoice. Fall back to handing
initialize() the worker's raw interface, AddRef'd on its behalf. The
worker keeps pumping messages either way, and the implementations
that reach this path use apartment-agnostic SAPI objects, so
cross-thread calls on the raw pointer are safe. The worker drains an
unclaimed fallback pointer on exit so a timed-out initialize() can't
leak it.
ISpVoice::GetOutputStream is a stub (E_NOTIMPL), which failed
initialization over cached output params that only serve the
get_channels/sample_rate/bit_depth queries. Warn and continue
instead; speech does not need to know the output format.
Field-tested under Wine/Proton on the Steam Deck, where both gaps
previously left the SAPI backend unusable.