fix(sapi): build the Windows SAPI engine against windows-rs 0.61#5
Merged
Merged
Conversation
The SAPI backend does not compile under the windows crate (0.61). The module is gated to Windows and CI runs on Linux, so the breakage was never exercised. Migrate the dead API usages to the real windows-rs surface: - Use the SpVoice CLSID constant instead of the non-existent SPVOICE_CLSID. - Replace the sphelper.h SpEnumTokens inline helper (not generated by windows-rs) with direct ISpObjectTokenCategory enumeration via a new enum_voice_tokens() helper keyed on SPCAT_VOICES. - IEnumSpObjectTokens::GetCount takes an out-pointer; pass &mut count. - ISpVoice::Speak takes a plain u32 flag, not SPEAK_FLAGS(...); use the SPF_ASYNC / SPF_IS_XML / SPF_PURGEBEFORESPEAK constants. - PWSTR has no to_string_lossy(); convert via to_hstring().to_string_lossy(). - Compare voice ids by string value rather than PWSTR == HSTRING. Verified with cargo fmt --check and cargo check --no-default-features --features sapi on a windows-msvc host. Signed-off-by: Owen Kent <owenpkent@gmail.com>
This was referenced Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Windows SAPI backend (
src/sapi_engine.rs) does not compile against the currentwindowscrate (0.61). The module is gated totarget_os = "windows"and CI runs on Linux, so the breakage is never exercised and slipped through unnoticed.This migrates the dead API usages to the real windows-rs 0.61 surface. There is no behaviour change to the other backends. It is purely a build fix for the
sapifeature.What was broken against windows-rs 0.61
SPVOICE_CLSIDSpVoiceCLSID constantSpEnumTokens(...)(ansphelper.hinline helper that windows-rs does not generate)ISpObjectTokenCategorydirectly via a newenum_voice_tokens()helper keyed onSPCAT_VOICESIEnumSpObjectTokens::GetCount()used as a return valueGetCount(&mut count)SPEAK_FLAGS(0x1)newtypeISpVoice::Speaktakes a plainu32; use theSPF_ASYNC/SPF_IS_XML/SPF_PURGEBEFORESPEAKconstantsPWSTR::to_string_lossy()(does not exist)to_hstring().to_string_lossy()id == target(PWSTR == HSTRING)Verification
cargo fmt --all -- --checkis clean.cargo check --no-default-features --features sapicompiles on anx86_64-pc-windows-msvchost (it was 27 errors before this change).Notes
main, so it applies cleanly.