Fix audio clock drift and adaptive jitter buffering
This commit is contained in:
@@ -55,6 +55,16 @@ public sealed partial class VoiceCatClient
|
||||
public VcResult SetOutputVolume(float gain) { if (!float.IsFinite(gain) || gain is < 0 or > 4) return VcResult.InvalidArg; core.Audio.OutputGain = gain; return VcResult.Ok; }
|
||||
public VcResult SetInputGain(float gain) { if (!float.IsFinite(gain) || gain is < 0 or > 4) return VcResult.InvalidArg; core.Audio.InputGain = gain; return VcResult.Ok; }
|
||||
public VcResult SetInputNoiseReduction(bool enabled) { core.Audio.InputNoiseReduction = enabled; return VcResult.Ok; }
|
||||
public VcResult SetAudioBufferMilliseconds(int milliseconds)
|
||||
{
|
||||
try
|
||||
{
|
||||
core.Audio.DeviceBufferMilliseconds = milliseconds;
|
||||
if (Volatile.Read(ref playback) is { } output) output.BufferMilliseconds = milliseconds;
|
||||
return VcResult.Ok;
|
||||
}
|
||||
catch (ArgumentOutOfRangeException) { return VcResult.InvalidArg; }
|
||||
}
|
||||
public VcResult SetRemoteStream(uint userId, uint streamId, float gain, bool muted, bool nr)
|
||||
{ try { core.Audio.SetRemotePlayback(userId, streamId, gain, muted, nr); return VcResult.Ok; } catch { return VcResult.InvalidArg; } }
|
||||
public (VcResult Result, RemoteStreamState? State) GetRemoteStream(uint userId, uint streamId)
|
||||
|
||||
@@ -159,7 +159,11 @@ public sealed partial class VoiceCatClient : IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
if (backend is not null && playback is null) playback = backend.OpenPlayback();
|
||||
if (backend is not null && playback is null)
|
||||
{
|
||||
playback = backend.OpenPlayback();
|
||||
playback.BufferMilliseconds = core.Audio.DeviceBufferMilliseconds;
|
||||
}
|
||||
var result = core.SubscribeVoiceAsync().GetAwaiter().GetResult();
|
||||
if (!result.Ok) { Interlocked.Exchange(ref playback, null)?.Dispose(); }
|
||||
return result.Ok ? VcResult.Ok : VcResult.Audio;
|
||||
|
||||
Reference in New Issue
Block a user