in VirtualStage/Speaker.Recorder/Speaker.Recorder/Kinect/KinectCaptureProvider.cs [176:261]
private void RenderThread(object obj)
{
var processTime = new Stopwatch();
while ((this.device != null || this.playback != null) && !this.disposed)
{
this.captureEvent.Wait();
if (this.disposed)
{
continue;
}
processTime.Restart();
try
{
using var capture = this.device != null ? this.device.GetCapture() : this.playback.GetNextCapture();
if (!this.disposed)
{
if (this.playback != null && capture == null)
{
this.playback.Seek(TimeSpan.Zero);
this.seekCount++;
continue;
}
if (this.playback != null)
{
if (capture.Color != null)
{
capture.Color.DeviceTimestamp += this.playback.RecordingLength * this.seekCount;
}
if (capture.Depth != null)
{
capture.Depth.DeviceTimestamp += this.playback.RecordingLength * this.seekCount;
}
if (capture.IR != null)
{
capture.IR.DeviceTimestamp += this.playback.RecordingLength * this.seekCount;
}
}
this.captureArrived?.Invoke(this, capture);
processTime.Stop();
if (!this.disposed)
{
if (this.playback != null && processTime.Elapsed < this.fpsTime)
{
Thread.Sleep(this.fpsTime - processTime.Elapsed);
}
}
}
}
catch (AzureKinectException)
{
if (this.device != null && !this.disposed)
{
try
{
this.device?.Dispose();
}
catch (Exception e)
{
Debug.WriteLine(e);
}
this.device = null;
this.OpenDevice();
}
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}
try
{
this.device?.Dispose();
this.playback?.Dispose();
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}