Fix iOS background audio pacing
Sleep-paced threads stall for hundreds of milliseconds when iOS coalesces a backgrounded app's wakeups, and the deadline resets that discarded the deficit left the capture backlog queued until its ring overflowed: regular dropouts that worsen the longer the app stays backgrounded. Pace both 20 ms hands-offs from the AVAudioSourceNode render callback instead (mix via Audio.RunCycle with deviceClockedAudio, capture handoff from the ring), wake the UDP sender on a queue signal instead of a 1 ms poll, and let stalled consumers drop their backlog to the buffer target instead of ratcheting it.
This commit is contained in:
@@ -132,6 +132,16 @@ public class PublishServerScriptTests
|
||||
Assert.DoesNotContain("Task.Delay(10", screen);
|
||||
Assert.Contains("MaximumCaptureCallbackFrames = 16_384", microphone);
|
||||
Assert.DoesNotContain("Math.Ceiling(4_096 * 48_000", microphone);
|
||||
|
||||
// Both 20 ms hands-offs run from the AVAudioSourceNode render callback: sleep-paced
|
||||
// threads coalesce when the app is backgrounded and glitch the call after several minutes.
|
||||
string model = await File.ReadAllTextAsync(Path.Combine(
|
||||
root, "clients", "apple", "VoiceCat.iOS", "AppModel.cs"));
|
||||
Assert.DoesNotContain("new Thread(", microphone);
|
||||
Assert.DoesNotContain("Thread.Sleep", microphone);
|
||||
Assert.Contains("owner.Audio.RunCycle()", microphone);
|
||||
Assert.Contains("while (microphoneCredit >= 960)", microphone);
|
||||
Assert.Contains("deviceClockedAudio: true", model);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user