Skip to content

fix(audio-openal): restore briefing video audio#100

Merged
fbraz3 merged 8 commits into
mainfrom
fix/issue-38-briefing-audio-timing
Apr 23, 2026
Merged

fix(audio-openal): restore briefing video audio#100
fbraz3 merged 8 commits into
mainfrom
fix/issue-38-briefing-audio-timing

Conversation

@fbraz3

@fbraz3 fbraz3 commented Apr 23, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the briefing and video-audio regression from issue #38 by stabilizing the shared OpenAL streaming path and backporting the FFmpeg-side hardening needed by the base Generals path.

What changed

  • restart shared OpenAL video streams before unqueueing processed buffers
  • keep video sources non-positional and direct in OpenAL
  • reject invalid decoded audio frames before queueing
  • convert FFmpeg float audio output to PCM16 before passing it to OpenAL
  • force Bink/OpenAL video stream gain to 1.0f before playback start
  • keep the Generals and Zero Hour FFmpeg paths aligned
  • remove temporary audit instrumentation used during triage
  • update the April dev diary

Validation

  • manual test on macOS confirmed briefing/video audio works correctly in both Generals and Zero Hour
  • verified no GX-AUDIT, Temporary audit, or Runtime audit markers remain in the touched files

Fixes #38

fbraz3 added 7 commits April 20, 2026 20:30
Briefing audio played during gameplay instead of loading screen on
Linux/macOS (OpenAL builds). The FFmpegVideoStream destructor freed
FFmpeg resources but left the OpenAL source (m_binkAudio) with queued
audio buffers still active, which drained into early mission frames.

Fix: call audioStream->reset() in ~FFmpegVideoStream under
SAGE_USE_OPENAL with null-guards. Applied to both Core and GeneralsMD.
Confirmed on Generals base and Zero Hour.

Fixes: #38
Two bugs caused campaign briefing videos to play without audio on
Linux/macOS (OpenAL builds):

1. OpenALAudioStream::update() only restarted playback on AL_STOPPED.
   After reset() on a freshly created stream, alSourceStop() is a
   no-op on AL_INITIAL, so the source stays AL_INITIAL. Audio frames
   arriving via onFrame() called update(), but AL_INITIAL != AL_STOPPED
   skipped play() entirely.
   Fix: also restart on AL_INITIAL state.

2. LoadScreen::init() runs a blocking video loop that never reaches
   the main game loop, so TheVideoPlayer->update() (which calls
   FFmpegVideoStream::update() -> play() if not already playing) was
   never invoked. Audio source underruns had no recovery path.
   Fix: call TheVideoPlayer->update() after each frameNext().

Related: #38
… loop

Same blocking loop issue as SinglePlayerLoadScreen: the ChallengeLoadScreen
video loop never returns to the main game loop, so TheVideoPlayer->update()
was never called. Without it the OpenAL source could stay AL_INITIAL or
underrun with no recovery.

Related: #38
OpenAL-Soft on macOS auto-pauses all sources via Core Audio session
suspension when the application loses window focus. A momentary focus
loss during the shell-map to loading-screen transition caused the video
audio source to enter AL_PAUSED and never recover, resulting in silent
video playback for the rest of the session.

update() in OpenALAudioStream now handles AL_PAUSED alongside AL_STOPPED
and AL_INITIAL: whenever the source is not playing and buffers are queued,
alSourcePlay() is called to resume.

Also removes temporary diagnostic fprintfs that were used to trace the
root cause via logs/issue_38.log.

Issue: #38
Keep the shared OpenAL stream from unqueueing processed buffers before restart, which could drop freshly queued briefing audio during video transitions.

Backport the stable FFmpeg-side fixes into the shared Generals path by forcing stream gain to 1.0f, rejecting invalid decoded frame sizes, and converting float FFmpeg audio to PCM16 before queueing into OpenAL.

Also remove the temporary audit instrumentation used to isolate the issue and update the April dev diary.

Fixes #38
@fbraz3 fbraz3 requested a review from Copilot April 23, 2026 14:40
Register references/fbraz3-dxvk as a proper git submodule entry (gitlink mode 160000) using the existing .gitmodules configuration pointing to fbraz3/dxvk on branch generalsx-macos-v2.6.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@fbraz3 fbraz3 merged commit c0ce9f0 into main Apr 23, 2026
14 checks passed
@fbraz3 fbraz3 deleted the fix/issue-38-briefing-audio-timing branch April 23, 2026 15:11
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.

On Linux Briefing audio is played during mission not during loading screen/cutscene playback

2 participants