Fix Well clock freshness and reservoir intake
This commit is contained in:
parent
7ab555a355
commit
f5193341e9
8 changed files with 155 additions and 21 deletions
|
|
@ -14,7 +14,7 @@ public sealed record MimirAsioStreamSourceOptions(
|
|||
public sealed class MimirAsioStreamSource : IMimirMultiplexedStreamSource
|
||||
{
|
||||
private const string DefaultClsid = "{AC4D0455-50D7-4498-B3CD-9A41D130B759}";
|
||||
private const int MaxQueuedBlocks = 32768;
|
||||
private const int MaxQueuedBlocks = 256;
|
||||
private readonly ConcurrentQueue<MimirStreamSample> samples = new();
|
||||
private readonly ManualResetEventSlim started = new();
|
||||
private readonly Thread captureThread;
|
||||
|
|
@ -130,13 +130,14 @@ public sealed class MimirAsioStreamSource : IMimirMultiplexedStreamSource
|
|||
|
||||
var sourceId = channel < sourceIds.Length ? sourceIds[channel] : $"asio-ch{channel}";
|
||||
var bytes = new byte[frameCount * sizeof(float)];
|
||||
var arrivalNs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() * 1_000_000L;
|
||||
MemoryMarshal.AsBytes(sampleBuffer.AsSpan(0, frameCount)).CopyTo(bytes);
|
||||
samples.Enqueue(new MimirStreamSample(
|
||||
sourceId,
|
||||
MimirStreamKind.Audio,
|
||||
Descriptor.Origin,
|
||||
timestampNs,
|
||||
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() * 1_000_000L,
|
||||
arrivalNs,
|
||||
arrivalNs,
|
||||
sequence,
|
||||
0,
|
||||
bytes.Length,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public sealed class MimirNativeIngestStreamSource : IMimirStreamSource
|
|||
}
|
||||
|
||||
Push(
|
||||
frame.DeviceTimestampNs,
|
||||
arrivalNs,
|
||||
arrivalNs,
|
||||
frame.NativeHandle,
|
||||
data.Length,
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ public sealed class MimirRuntimeConfiguration
|
|||
stream.MinimumFramesPerSecond,
|
||||
stream.QueueDepth,
|
||||
ParsePixelFormat(stream.PixelFormat))),
|
||||
static () => StopwatchTicksToNs(System.Diagnostics.Stopwatch.GetTimestamp())));
|
||||
UtcNowNs));
|
||||
}
|
||||
|
||||
if (string.Equals(stream.Adapter, "ps3eye", StringComparison.OrdinalIgnoreCase)
|
||||
|
|
@ -192,7 +192,7 @@ public sealed class MimirRuntimeConfiguration
|
|||
stream.Width,
|
||||
stream.Height,
|
||||
stream.FramesPerSecond)),
|
||||
static () => StopwatchTicksToNs(System.Diagnostics.Stopwatch.GetTimestamp())));
|
||||
UtcNowNs));
|
||||
}
|
||||
|
||||
if (string.Equals(stream.Adapter, "mf-gpu", StringComparison.OrdinalIgnoreCase)
|
||||
|
|
@ -214,7 +214,7 @@ public sealed class MimirRuntimeConfiguration
|
|||
stream.InputFormat,
|
||||
stream.OutputFormat,
|
||||
stream.MinimumFramesPerSecond)),
|
||||
static () => StopwatchTicksToNs(System.Diagnostics.Stopwatch.GetTimestamp())));
|
||||
UtcNowNs));
|
||||
}
|
||||
|
||||
if (string.Equals(stream.Adapter, "frame-events", StringComparison.OrdinalIgnoreCase)
|
||||
|
|
@ -305,10 +305,7 @@ public sealed class MimirRuntimeConfiguration
|
|||
return Path.GetFullPath(Path.Combine(configDirectory, command));
|
||||
}
|
||||
|
||||
private static long StopwatchTicksToNs(long ticks)
|
||||
{
|
||||
return checked((long)(ticks * (1_000_000_000.0 / System.Diagnostics.Stopwatch.Frequency)));
|
||||
}
|
||||
private static long UtcNowNs() => DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() * 1_000_000L;
|
||||
|
||||
private static MimirStreamKind ParseKind(string value)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue