|
@@ -16,7 +16,7 @@ internal partial class MediaContext : ICompositorScheduler
|
|
private TimeSpan _inputMarkerAddedAt;
|
|
private TimeSpan _inputMarkerAddedAt;
|
|
private bool _isRendering;
|
|
private bool _isRendering;
|
|
private bool _animationsAreWaitingForComposition;
|
|
private bool _animationsAreWaitingForComposition;
|
|
- private const double MaxSecondsWithoutInput = 1;
|
|
|
|
|
|
+ private readonly double MaxSecondsWithoutInput;
|
|
private readonly Action _render;
|
|
private readonly Action _render;
|
|
private readonly Action _inputMarkerHandler;
|
|
private readonly Action _inputMarkerHandler;
|
|
private readonly HashSet<Compositor> _requestedCommits = new();
|
|
private readonly HashSet<Compositor> _requestedCommits = new();
|
|
@@ -37,12 +37,13 @@ internal partial class MediaContext : ICompositorScheduler
|
|
|
|
|
|
private readonly Dictionary<object, TopLevelInfo> _topLevels = new();
|
|
private readonly Dictionary<object, TopLevelInfo> _topLevels = new();
|
|
|
|
|
|
- private MediaContext(Dispatcher dispatcher)
|
|
|
|
|
|
+ private MediaContext(Dispatcher dispatcher, TimeSpan inputStarvationTimeout)
|
|
{
|
|
{
|
|
_render = Render;
|
|
_render = Render;
|
|
_inputMarkerHandler = InputMarkerHandler;
|
|
_inputMarkerHandler = InputMarkerHandler;
|
|
_clock = new(this);
|
|
_clock = new(this);
|
|
_dispatcher = dispatcher;
|
|
_dispatcher = dispatcher;
|
|
|
|
+ MaxSecondsWithoutInput = inputStarvationTimeout.TotalSeconds;
|
|
_animationsTimer.Tick += (_, _) =>
|
|
_animationsTimer.Tick += (_, _) =>
|
|
{
|
|
{
|
|
_animationsTimer.Stop();
|
|
_animationsTimer.Stop();
|
|
@@ -57,8 +58,14 @@ internal partial class MediaContext : ICompositorScheduler
|
|
// Technically it's supposed to be a thread-static singleton, but we don't have multiple threads
|
|
// Technically it's supposed to be a thread-static singleton, but we don't have multiple threads
|
|
// and need to do a full reset for unit tests
|
|
// and need to do a full reset for unit tests
|
|
var context = AvaloniaLocator.Current.GetService<MediaContext>();
|
|
var context = AvaloniaLocator.Current.GetService<MediaContext>();
|
|
|
|
+
|
|
if (context == null)
|
|
if (context == null)
|
|
- AvaloniaLocator.CurrentMutable.Bind<MediaContext>().ToConstant(context = new(Dispatcher.UIThread));
|
|
|
|
|
|
+ {
|
|
|
|
+ var opts = AvaloniaLocator.Current.GetService<DispatcherOptions>() ?? new();
|
|
|
|
+ context = new MediaContext(Dispatcher.UIThread, opts.InputStarvationTimeout);
|
|
|
|
+ AvaloniaLocator.CurrentMutable.Bind<MediaContext>().ToConstant(context);
|
|
|
|
+ }
|
|
|
|
+
|
|
return context;
|
|
return context;
|
|
}
|
|
}
|
|
}
|
|
}
|