Skip to content

Validate WinMM hardening on integrated FFmpeg audio core - #148

Draft
Blackspirits wants to merge 1 commit into
audit/ffmpeg-audio-core-integration-2c44from
audit/ffmpeg-audio-winmm-integration-fa52
Draft

Blackspirits wants to merge 1 commit into
audit/ffmpeg-audio-core-integration-2c44from
audit/ffmpeg-audio-winmm-integration-fa52

Conversation

@Blackspirits

@Blackspirits Blackspirits commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Purpose

Integration-only validation of the audited FFmpeg Windows/WinMM audio sink hardening on top of the integrated audio-core stack #147.

The base is #147, so it already composes:

This integration commit layers the Windows-specific audited behavior from:

It is audit evidence only and is not a merge candidate.

Current upstream SubtitleEdit/subtitleedit main was rechecked at 2998aeedbc39a3a5a1c19269c2464122df1aa66b; the newer upstream changes remain outside the FFmpeg player/sinks.

Composition invariants

  1. Seek serial remains the ownership fence.
    Fail closed when native FFmpeg audio reset fails #128's Reset(int serial) remains intact: generation advances first, the accepted serial is set to rejected before native reset, and a new serial is published only after successful waveOutReset.

  2. Position-format hardening does not weaken reset semantics.
    Handle alternate WinMM playback position formats #126's position normalization/wrap tracking is reset only after native reset succeeds.

  3. Open is all-or-nothing.
    Fail closed when WinMM output setup is incomplete #129 verifies the event handle and every waveOutPrepareHeader; all headers are initialized before any partial cleanup can inspect them.

  4. Write remains copy+enqueue atomic against Reset.
    The Fence FFmpeg audio writes by seek serial #125 critical section and serial/generation checks remain unchanged while the Handle alternate WinMM playback position formats #126 position logic is layered around them.

  5. Teardown is fail closed.
    Retain WinMM buffers when teardown cannot reclaim them #131 frees no header/data buffer while WinMM still reports reset/unprepare/close failure.

  6. Retryable native cleanup is preserved.
    A later Open/Dispose can retry retained WinMM state instead of using/freing a half-reclaimed device boundary.

  7. Clock position is monotonic across driver format changes.
    Samples/bytes/ms replies are normalized to bytes and format-switch rounding cannot manufacture a 32-bit wrap jump.

Deliberate residual finding

This integration does not yet solve native clock-query health.

Both WinMM and Core Audio currently return their last known playback position when the native clock API itself fails. That is safer than returning garbage, but it means the player cannot distinguish “temporarily unchanged clock” from “clock query is no longer valid”.

A separate follow-up will expose clock validity explicitly so persistent waveOutGetPosition / AudioQueueGetCurrentTime failure can trigger the #144 wall-clock failover without timeout heuristics.

Scope / branch state

Acceptance

  • full restore/build/test suite must pass on this exact integrated tree;
  • no new warning;
  • retry step must remain unused;
  • final adversarial review must confirm the seven invariants above and keep the clock-health gap explicitly open.

AI assistance: ChatGPT was used for cross-branch WinMM reconciliation, serial/reset/open/teardown invariant review, and integration acceptance design.

Final CI

Authoritative run: SubtitleEdit#292 on fd98fcc6bce4c01845ddff9b1ad5d35757478c99

  • SeConv: 488 passed / 2 skipped / 0 failed
  • LibUiLogic: 905 passed / 0 skipped / 0 failed
  • LibSE: 2017 passed / 0 skipped / 0 failed
  • UI: 5288 passed / 9 skipped / 0 failed
  • build: 0 errors / 7 pre-existing warnings
  • retry step skipped
  • failure-artifact upload skipped

The first integrated run SubtitleEdit#290 exposed one integration-only duplicate-using warning in WaveOutAudioSink. That warning was removed, the branch was re-compacted to one commit, and SubtitleEdit#292 is the authoritative clean run.

Final adversarial integration review was performed on this exact HEAD after CI; all seven WinMM composition invariants remain satisfied.

@Blackspirits
Blackspirits force-pushed the audit/ffmpeg-audio-winmm-integration-fa52 branch from efc09be to fd98fcc Compare September 16, 2026 13:39

@Blackspirits Blackspirits left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final adversarial integration review on fd98fcc6bce4c01845ddff9b1ad5d35757478c99 after CI SubtitleEdit#292: no blocker found. Verified serial-fenced Reset(int), position-format/wrap normalization, all-or-nothing WinMM open, atomic copy+enqueue vs Reset, fail-closed teardown, retryable retained native cleanup, and monotonic position across driver format changes. The only new warning seen in superseded CI SubtitleEdit#290 was a duplicate using introduced by integration; it was removed before SubtitleEdit#292. Native clock-query health remains explicitly open for the follow-up. No merge/promotion performed.

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.

1 participant