From 7dcffa6c6f18fab2e89684d08c87f8d73511fe7f Mon Sep 17 00:00:00 2001 From: thebornster <153663006+thebornster@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:58:07 +0200 Subject: [PATCH] Accept CoreAudio slices on devices slower than 48 kHz The maximum frames per slice is reported in device frames, but the render callback checks it against 48 kHz client frames. On a 44.1 kHz output device the converter asks for about 279 client frames per 256-frame slice, so every callback was rejected. The audio ring never drained, the game's audio engine stalled, and the screen stayed black after the intro. Scale the limit by the guest-to-device rate ratio. Signed-off-by: thebornster --- .../src/audio/coreaudio/coreaudio_output.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/glue/rexglue-sdk-main/src/audio/coreaudio/coreaudio_output.cpp b/glue/rexglue-sdk-main/src/audio/coreaudio/coreaudio_output.cpp index e40a5be5b..861370060 100644 --- a/glue/rexglue-sdk-main/src/audio/coreaudio/coreaudio_output.cpp +++ b/glue/rexglue-sdk-main/src/audio/coreaudio/coreaudio_output.cpp @@ -627,6 +627,13 @@ bool CoreAudioOutput::ConfigureDevice() { kAudioUnitScope_Global, 0, &maximum_frames, &maximum_frames_size) == noErr && maximum_frames) { + // The slice limit is in device frames; on a slower device the sample-rate converter pulls + // proportionally more 48 kHz client frames per slice (e.g. 279 for 256 at 44.1 kHz). + if (nominal_rate > 0 && nominal_rate < kGuestAudioSampleRate) { + maximum_frames = static_cast( + std::ceil(maximum_frames * (kGuestAudioSampleRate / nominal_rate))) + + 1; + } maximum_frames_per_slice_.store(maximum_frames, std::memory_order_release); }