Fix iOS stereo microphone capture
This commit is contained in:
@@ -55,7 +55,7 @@ internal sealed class IosAudioEngine
|
||||
|
||||
internal void StartMicrophone(uint streamId, int channels)
|
||||
{
|
||||
Volatile.Write(ref microphone, new(streamId, Math.Clamp(channels, 1, 2))); Rebuild();
|
||||
Volatile.Write(ref microphone, CreateMicrophoneRoute(streamId, channels)); Rebuild();
|
||||
}
|
||||
|
||||
internal void StopMicrophone() { Volatile.Write(ref microphone, null); Rebuild(); }
|
||||
@@ -70,10 +70,21 @@ internal sealed class IosAudioEngine
|
||||
// an in-flight callback could interpret its old converter buffer using the new width.
|
||||
DestroyGraph();
|
||||
if (current.Channels != channels) client!.Audio.SetCaptureChannels(current.StreamId, channels);
|
||||
Volatile.Write(ref microphone, new(current.StreamId, channels));
|
||||
Volatile.Write(ref microphone, CreateMicrophoneRoute(current.StreamId, channels));
|
||||
}
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
private static MicrophoneRoute CreateMicrophoneRoute(uint streamId, int channels)
|
||||
{
|
||||
var route = new MicrophoneRoute(streamId, Math.Clamp(channels, 1, 2));
|
||||
// Physical RemoteIO capture is commonly delivered in 100 ms bursts. Starting its 20 ms
|
||||
// pacer with only the VPIO-oriented 60 ms cushion guarantees several underruns after every
|
||||
// mono/stereo rebuild before the adaptive path catches up. Prime one full burst plus one
|
||||
// frame for non-VPIO routes; VPIO remains at the proven low-latency three-frame cushion.
|
||||
route.TargetFrames = IosAudioRouter.Shared.UsesVoiceProcessing ? 3 : 6;
|
||||
return route;
|
||||
}
|
||||
internal bool EnsureRunning()
|
||||
{
|
||||
if (!IsConnected || engine?.Running == true) return true;
|
||||
|
||||
Reference in New Issue
Block a user