Skip to content

fix(sapi): build the Windows SAPI engine against windows-rs 0.61#5

Merged
willwade merged 1 commit into
AACTools:mainfrom
owenpkent:fix/sapi-windows-rs-msvc
Jun 28, 2026
Merged

fix(sapi): build the Windows SAPI engine against windows-rs 0.61#5
willwade merged 1 commit into
AACTools:mainfrom
owenpkent:fix/sapi-windows-rs-msvc

Conversation

@owenpkent

Copy link
Copy Markdown

Summary

The Windows SAPI backend (src/sapi_engine.rs) does not compile against the current windows crate (0.61). The module is gated to target_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 sapi feature.

What was broken against windows-rs 0.61

Old (does not compile) Fix
SPVOICE_CLSID the generated SpVoice CLSID constant
SpEnumTokens(...) (an sphelper.h inline helper that windows-rs does not generate) enumerate ISpObjectTokenCategory directly via a new enum_voice_tokens() helper keyed on SPCAT_VOICES
IEnumSpObjectTokens::GetCount() used as a return value it takes an out-pointer: GetCount(&mut count)
SPEAK_FLAGS(0x1) newtype ISpVoice::Speak takes a plain u32; use the SPF_ASYNC / SPF_IS_XML / SPF_PURGEBEFORESPEAK constants
PWSTR::to_string_lossy() (does not exist) to_hstring().to_string_lossy()
id == target (PWSTR == HSTRING) compare by string value

Verification

  • cargo fmt --all -- --check is clean.
  • cargo check --no-default-features --features sapi compiles on an x86_64-pc-windows-msvc host (it was 27 errors before this change).
  • Exercised end to end: this exact migration builds and links the SAPI backend green in a downstream consumer's Windows CI (the Dasher-GTK frontend), across both Debug and Release.

Notes

  • Linux and macOS CI are unaffected; the module stays gated to Windows.
  • Branched off main, so it applies cleanly.
  • DCO signed off.

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>
@willwade willwade merged commit 4fb43bd into AACTools:main Jun 28, 2026
2 of 3 checks passed
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.

2 participants