Propagate Fensalir texture leases to video drivers
This commit is contained in:
parent
daf1d4ef8a
commit
7202d30ef1
10 changed files with 85 additions and 3 deletions
|
|
@ -756,6 +756,20 @@ static int RunFensalirTextureLeaseSmoke()
|
|||
_ = runtime.Frame;
|
||||
}
|
||||
|
||||
var receiverDriver = new FakeTextureLeaseVideoDriver();
|
||||
using (var runtime = new MimirRuntime(
|
||||
new AquariumRuntimeOptions(Headless: true, CultCachePath: null),
|
||||
new MimirSynchronizationSettings(),
|
||||
[
|
||||
new MimirVideoCaptureDriverSource(
|
||||
new MimirStreamDescriptor("driver-camera", MimirStreamKind.Video, MimirStreamOrigin.LocalDevice),
|
||||
receiverDriver,
|
||||
static () => 0)
|
||||
]))
|
||||
{
|
||||
runtime.AttachServices(new AquariumRuntimeServices(broker));
|
||||
}
|
||||
|
||||
var buffer = new MimirRollingStreamBuffer(
|
||||
new MimirStreamDescriptor("kiyo-pro-rgb", MimirStreamKind.Video, MimirStreamOrigin.LocalDevice),
|
||||
TimeSpan.FromSeconds(5));
|
||||
|
|
@ -776,9 +790,10 @@ static int RunFensalirTextureLeaseSmoke()
|
|||
var expectedResourceKey = MimirFensalirTextureLeaseClient.ResourceKeyForSource("kiyo-pro-rgb");
|
||||
|
||||
Console.WriteLine(
|
||||
$"fensalir-texture-lease-smoke leased={lease.IsValid} committed={broker.CommittedFenceValue > 0} resources={frame.Resources.Count} claims={frame.Claims.Count} errors={validation.HasErrors}");
|
||||
$"fensalir-texture-lease-smoke leased={lease.IsValid} committed={broker.CommittedFenceValue > 0} driverClient={receiverDriver.HasClient} resources={frame.Resources.Count} claims={frame.Claims.Count} errors={validation.HasErrors}");
|
||||
|
||||
return lease.IsValid &&
|
||||
receiverDriver.HasClient &&
|
||||
broker.CommittedResourceKey == expectedResourceKey &&
|
||||
broker.CommittedVersion == 0 &&
|
||||
broker.CommittedFenceValue == 41 &&
|
||||
|
|
@ -6068,3 +6083,26 @@ sealed class FakeFieldResourceBroker : IAquariumFieldResourceBroker
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
sealed class FakeTextureLeaseVideoDriver : IMimirVideoCaptureDriver, IMimirFensalirTextureLeaseReceiver
|
||||
{
|
||||
public string DriverName => "fake-texture-lease-driver";
|
||||
|
||||
public bool HasClient { get; private set; }
|
||||
|
||||
public void AttachTextureLeaseClient(MimirFensalirTextureLeaseClient? client)
|
||||
{
|
||||
HasClient = client != null;
|
||||
}
|
||||
|
||||
public bool TryCapture(out MimirVideoFrameDescriptor frame, out ReadOnlyMemory<byte> data)
|
||||
{
|
||||
frame = default!;
|
||||
data = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
public void AttachServices(AquariumRuntimeServices services)
|
||||
{
|
||||
runtimeServices = services;
|
||||
synchronization.AttachTextureLeaseClient(new MimirFensalirTextureLeaseClient(services.FieldResources));
|
||||
}
|
||||
|
||||
private AquariumFrame CreateFrame()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public interface IMimirFensalirTextureLeaseReceiver
|
||||
{
|
||||
void AttachTextureLeaseClient(MimirFensalirTextureLeaseClient? client);
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ public sealed class MimirSynchronizationHub : IDisposable
|
|||
private readonly Dictionary<string, MimirAudioSynchronizationReport> audioSynchronizationReports = new(StringComparer.Ordinal);
|
||||
private readonly Dictionary<string, MimirAudioSynchronizationReport> complexContourReports = new(StringComparer.Ordinal);
|
||||
private readonly MimirChirpBinCalibrationModel? chirpBinCalibrationModel;
|
||||
private MimirFensalirTextureLeaseClient? textureLeaseClient;
|
||||
private ulong ingestedSamples;
|
||||
private int nextAudioSynchronizationCandidate;
|
||||
|
||||
|
|
@ -64,6 +65,23 @@ public sealed class MimirSynchronizationHub : IDisposable
|
|||
{
|
||||
Buffers.EnsureBuffer(source.Descriptor);
|
||||
}
|
||||
|
||||
if (source is IMimirFensalirTextureLeaseReceiver receiver)
|
||||
{
|
||||
receiver.AttachTextureLeaseClient(textureLeaseClient);
|
||||
}
|
||||
}
|
||||
|
||||
public void AttachTextureLeaseClient(MimirFensalirTextureLeaseClient? client)
|
||||
{
|
||||
textureLeaseClient = client;
|
||||
foreach (var source in sources)
|
||||
{
|
||||
if (source is IMimirFensalirTextureLeaseReceiver receiver)
|
||||
{
|
||||
receiver.AttachTextureLeaseClient(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int PollSources(int maxSamplesPerSource = 8192)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public sealed class MimirVideoCaptureDriverSource : IMimirStreamSource
|
||||
public sealed class MimirVideoCaptureDriverSource : IMimirStreamSource, IMimirFensalirTextureLeaseReceiver
|
||||
{
|
||||
private readonly IMimirVideoCaptureDriver driver;
|
||||
private readonly MimirNativeIngestStreamSource nativeSource;
|
||||
|
|
@ -25,6 +25,14 @@ public sealed class MimirVideoCaptureDriverSource : IMimirStreamSource
|
|||
|
||||
public Func<long> ReadArrivalNs { get; }
|
||||
|
||||
public void AttachTextureLeaseClient(MimirFensalirTextureLeaseClient? client)
|
||||
{
|
||||
if (driver is IMimirFensalirTextureLeaseReceiver receiver)
|
||||
{
|
||||
receiver.AttachTextureLeaseClient(client);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryRead(out MimirStreamSample sample)
|
||||
{
|
||||
if (nativeSource.TryRead(out sample))
|
||||
|
|
|
|||
Loading…
Reference in a new issue