fix(audio-openal): advance Attack/Sound/Decay portions on sample completion#134
Merged
Conversation
…letion The OpenAL backend polled sourceIsStopped() in processPlayingList() but discarded PlayingAudio without calling notifyOfAudioCompletion(). Miles Sound System used EOS callbacks for this, so the port lacked the equivalent polling-based trigger. Result: the Attack portion (radio static, gradio1*.wav) played once, then the PlayingAudio was released before the Sound (voice) or Decay portions could start. All aircraft and unit voice lines were silent on Linux/macOS. Fix: call notifyOfAudioCompletion() before releasing a stopped sample. If it starts the next portion the AL source transitions back to playing and the object remains in the list; only release when the source is still stopped after the call (cycle complete or failed to load). Apply the same fix to both m_playingSounds (2D) and m_playing3DSounds (3D positional) loops. Skip the call when m_requestStop is set (user explicitly stopped the event). Also add a multichannel positional-audio fallback in playSample3D() and OpenALAudioCache so that stereo voice assets fall back to 2D playback instead of being dropped or crashing. Fixes #129
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
Fixes #129 — Aircraft (and all unit) voice lines were silent on Linux/macOS. Only the radio static (Attack portion) played; the actual voice (Sound portion) was never started.
Root Cause
The OpenAL backend's
processPlayingList()polledsourceIsStopped()and simply discarded thePlayingAudiowhen a sample finished. The Miles Sound System used EOS (End-of-Sample) callbacks automatically for this; the OpenAL port lacked an equivalent trigger.Without calling
notifyOfAudioCompletion()when a sample ends, the multi-portion playback state machine (PP_Attack → PP_Sound → PP_Decay) never advanced:gradio1*.wav— radio static) playsprocessPlayingList()releases thePlayingAudioobjectnotifyOfAudioCompletion()never called → Sound portion (actual voice) never startsFix
In
processPlayingList(), callnotifyOfAudioCompletion()before releasing a stopped sample. If it successfully starts the next portion, the AL source transitions back to playing and the object remains in the list. Only release when the source is still stopped after the call (full cycle complete, or failed to load next file).Applied to both
m_playingSounds(2D) andm_playing3DSounds(3D positional) loops. The call is skipped whenm_requestStopis set (user explicitly stopped the event).Additional Fixes
playSample3D): Stereo voice assets now fall back to 2D direct playback instead of being silently dropped or crashing.playSample3Dcan handle it.Testing
Manually verified on macOS (Apple Silicon, MoltenVK + DXVK path): selected multiple aircraft units (Comanche, King Raptor, Aurora Bomber, MiG) — radio static followed by voice lines now plays correctly for all factions.