Preserve iOS screen audio during stream startup
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user