Preserve iOS screen audio during stream startup
Build and test / test (macos-latest) (push) Canceled after 0s
Build and test / test (ubuntu-24.04) (push) Canceled after 0s
Build and test / test (windows-latest) (push) Canceled after 0s
Build and test / apple-client (push) Canceled after 0s

This commit is contained in:
2026-09-27 17:56:18 +02:00
parent 3dbe763598
commit 4bad264605
6 changed files with 65 additions and 15 deletions
@@ -26,6 +26,7 @@ internal sealed class BroadcastAudioPump : IAsyncDisposable
internal bool IsActive => active;
#if DEBUG
internal bool IsMappingOpen => view is not null;
internal long EncodedPackets => streamId == 0 ? 0 : client?.Audio.GetLocalDiagnostics(streamId).EncodedPackets ?? 0;
#endif
internal void Start(VoiceCatClient owner)
@@ -82,7 +83,13 @@ internal sealed class BroadcastAudioPump : IAsyncDisposable
try { owner.StopStream(stream.StreamId); } catch (Exception exception) when (exception is IOException or InvalidOperationException) { }
return;
}
streamId = stream.StreamId; pages.Write(32, pages.ReadUInt64(24)); SetActive(true);
// Keep the newest 120 ms captured during stream negotiation. This covers the
// largest codec frame plus the input buffer target; dropping through the latest
// write loses short sounds before the first drain can feed them.
ulong latestWrite = pages.ReadUInt64(24);
ulong earliest = latestWrite > (ulong)(Frame * 12) ? latestWrite - (ulong)(Frame * 12) : 0;
pages.Write(32, Math.Max(pages.ReadUInt64(32), earliest));
streamId = stream.StreamId; SetActive(true);
}
ulong write = pages.ReadUInt64(24), read = pages.ReadUInt64(32);
if (write - read > Capacity) read = write - Capacity;