back the audio cap off to opt-in: 7-23 already fixed the complaint, and the cap is a governor

Correcting my own framing in 7e57816. The dropout players actually reported was
fixed on 2026-07-23 by a999e5c, and nobody has complained since. I read the
leftover ACQUIRE FAILED lines in the night-5 logs as the same live bug and
raised the ceiling by default. They are not the same bug.

What is still in the logs is transient exhaustion, not a leak: the census sits
at 45-60 live, spikes during a firefight, and drains straight back (226 -> 42),
which is the priority steal loop working. A voice dropped in that window is
competing with ~256 already sounding, so it is very likely sub-perceptual --
which is consistent with the thing nobody is reporting.

And raising the cap is not free. The 256 ceiling doubles as a governor: the
steal loop only steals when the incoming source outranks a running one, so a
higher cap means many more voices mixing simultaneously, and with EFX reverb and
the lowpass chains live that is real CPU -- spent precisely during heavy combat,
when the frame budget is already tightest. I verified the ceiling moves. I never
measured frame time under a real firefight, and a solo bench cannot produce one.
Shipping that to testers tonight would be gambling their framerate against a
complaint nobody is making.

So the knob stays and the default does not move. BT_AUDIO_SOURCES=<n> raises it
with no rebuild if dropouts are ever reported again -- measure frame time while
you do. Unset reports `granted mono=255 stereo=1`, exactly what testers have
been running.

Keeping the diagnostic read-back either way, since it earned its keep: asking
for 64 grants 240, because OpenAL Soft has a floor of its own, which is also why
the NULL default lands on 256. A request is not a promise.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Joe DiPrima
2026-07-28 16:30:36 -05:00
co-authored by Claude Fable 5
parent 7e57816d39
commit 1af2dfc769
2 changed files with 51 additions and 25 deletions
+33 -11
View File
@@ -395,29 +395,51 @@ void
// DPLIndependantEffect voices, and while the pool is pinned every new
// acquire fails outright and that sound is silently dropped.
//
// Ask for a budget that fits the content. OpenAL Soft mixes in software,
// so this costs mixing headroom, not hardware voices, and it clamps to what
// it can honour -- hence the read-back below rather than an assumption.
// BT_AUDIO_SOURCES overrides for A/B testing.
ALCint monoWanted = 1024;
// ⚠ OFF BY DEFAULT, DELIBERATELY. Raising the cap is NOT a free win, and
// the reported dropout was already fixed on 2026-07-23 by a999e5c (the
// atomic-delete leak) -- no field complaints since. What remains in the
// night-5 logs is transient exhaustion at the peak of a firefight, where
// a dropped voice competes with ~256 already sounding, so it is very
// likely sub-perceptual. Against that: the 256 ceiling also acts as a
// GOVERNOR. The steal loop only steals when the incoming source outranks
// a running one, so a higher cap means many more voices mixing at once --
// with EFX reverb + the lowpass chains live, that is real CPU, spent
// exactly during heavy combat when the frame budget is tightest.
//
// So this stays opt-in: set BT_AUDIO_SOURCES=<n> to raise it (no rebuild
// needed) if dropouts are ever reported again, and measure frame time
// while you do. Unset = the shipped OpenAL Soft default, unchanged.
ALCint monoWanted = 0;
if (const char *sv = getenv("BT_AUDIO_SOURCES"))
{
int n = atoi(sv);
if (n >= 64 && n <= 4096)
monoWanted = n;
}
ALCint attrs[5];
attrs[0] = ALC_MONO_SOURCES; attrs[1] = monoWanted;
attrs[2] = ALC_STEREO_SOURCES; attrs[3] = 16;
attrs[4] = 0;
ALCcontext *context = alcCreateContext(device, attrs);
ALCcontext *context;
if (monoWanted > 0)
{
ALCint attrs[5];
attrs[0] = ALC_MONO_SOURCES; attrs[1] = monoWanted;
attrs[2] = ALC_STEREO_SOURCES; attrs[3] = 16;
attrs[4] = 0;
context = alcCreateContext(device, attrs);
}
else
{
context = alcCreateContext(device, NULL); // default budget (256)
}
alcMakeContextCurrent(context);
// Report what the driver actually GRANTED -- a request is not a promise.
// (Asking for 64 grants 240: OpenAL Soft has a floor of its own, which is
// also why the NULL default lands on 256.)
if (getenv("BT_AUDIO_LOG") || monoWanted > 0)
{
ALCint monoGot = 0, stereoGot = 0;
alcGetIntegerv(device, ALC_MONO_SOURCES, 1, &monoGot);
alcGetIntegerv(device, ALC_STEREO_SOURCES, 1, &stereoGot);
DEBUG_STREAM << "[audio] source budget: requested mono=" << monoWanted
DEBUG_STREAM << "[audio] source budget: requested mono="
<< (monoWanted > 0 ? monoWanted : 0) << " (0 = driver default)"
<< " granted mono=" << monoGot << " stereo=" << stereoGot
<< std::endl << std::flush;
}