Browse Source

dont give up on scheduling filler while some should fit (#1306)

pull/1308/head
Jason Dove 3 years ago committed by GitHub
parent
commit
d490cc6f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      ErsatzTV.Core/Scheduling/PlayoutModeSchedulerBase.cs
  2. 12
      ErsatzTV.Infrastructure/Scheduling/MultiEpisodeShuffleCollectionEnumerator.cs

22
ErsatzTV.Core/Scheduling/PlayoutModeSchedulerBase.cs

@ -567,7 +567,6 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
var result = new List<PlayoutItem>(); var result = new List<PlayoutItem>();
TimeSpan remainingToFill = duration; TimeSpan remainingToFill = duration;
var discardToFillAttempts = 0;
while (enumerator.Current.IsSome && remainingToFill > TimeSpan.Zero && while (enumerator.Current.IsSome && remainingToFill > TimeSpan.Zero &&
remainingToFill >= enumerator.MinimumDuration) remainingToFill >= enumerator.MinimumDuration)
{ {
@ -595,24 +594,15 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
} }
else else
{ {
discardToFillAttempts++; if (log)
if (discardToFillAttempts >= enumerator.Count)
{ {
// set to zero so it breaks out of the while loop _logger.LogDebug(
remainingToFill = TimeSpan.Zero; "Filler item is too long {FillerDuration:g} to fill {GapDuration:g}; skipping to next filler item",
itemDuration,
remainingToFill);
} }
else
{
if (log)
{
_logger.LogDebug(
"Filler item is too long {FillerDuration:g} to fill {GapDuration:g}; skipping to next filler item",
itemDuration,
remainingToFill);
}
enumerator.MoveNext(); enumerator.MoveNext();
}
} }
} }
} }

12
ErsatzTV.Infrastructure/Scheduling/MultiEpisodeShuffleCollectionEnumerator.cs

@ -12,7 +12,6 @@ public class MultiEpisodeShuffleCollectionEnumerator : IMediaCollectionEnumerato
private readonly CancellationToken _cancellationToken; private readonly CancellationToken _cancellationToken;
private readonly IList<MediaItem> _mediaItems; private readonly IList<MediaItem> _mediaItems;
private readonly IScriptEngine _scriptEngine; private readonly IScriptEngine _scriptEngine;
private readonly string _scriptFile;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly int _mediaItemCount; private readonly int _mediaItemCount;
private readonly Dictionary<int, List<MediaItem>> _mediaItemGroups; private readonly Dictionary<int, List<MediaItem>> _mediaItemGroups;
@ -27,16 +26,14 @@ public class MultiEpisodeShuffleCollectionEnumerator : IMediaCollectionEnumerato
IScriptEngine scriptEngine, IScriptEngine scriptEngine,
string scriptFile, string scriptFile,
ILogger logger, ILogger logger,
CancellationToken cancellationToken, CancellationToken cancellationToken)
bool skipLoad = false)
{ {
_mediaItems = mediaItems; _mediaItems = mediaItems;
_scriptEngine = scriptEngine; _scriptEngine = scriptEngine;
_scriptFile = scriptFile;
_logger = logger; _logger = logger;
_cancellationToken = cancellationToken; _cancellationToken = cancellationToken;
if (!skipLoad) if (!string.IsNullOrWhiteSpace(scriptFile))
{ {
scriptEngine.Load(scriptFile); scriptEngine.Load(scriptFile);
} }
@ -99,10 +96,9 @@ public class MultiEpisodeShuffleCollectionEnumerator : IMediaCollectionEnumerato
_mediaItems, _mediaItems,
state, state,
_scriptEngine, _scriptEngine,
_scriptFile, null,
_logger, _logger,
cancellationToken, cancellationToken);
skipLoad: true);
} }
public CollectionEnumeratorState State { get; } public CollectionEnumeratorState State { get; }

Loading…
Cancel
Save