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

This commit is contained in:
Jason Dove
2023-06-14 16:58:37 -05:00
committed by GitHub
parent 99bd827bd9
commit d490cc6f4b
2 changed files with 10 additions and 24 deletions
@@ -567,7 +567,6 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
var result = new List<PlayoutItem>();
TimeSpan remainingToFill = duration;
var discardToFillAttempts = 0;
while (enumerator.Current.IsSome && remainingToFill > TimeSpan.Zero &&
remainingToFill >= enumerator.MinimumDuration)
{
@@ -595,24 +594,15 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
}
else
{
discardToFillAttempts++;
if (discardToFillAttempts >= enumerator.Count)
if (log)
{
// set to zero so it breaks out of the while loop
remainingToFill = TimeSpan.Zero;
_logger.LogDebug(
"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,7 +12,6 @@ public class MultiEpisodeShuffleCollectionEnumerator : IMediaCollectionEnumerato
private readonly CancellationToken _cancellationToken;
private readonly IList<MediaItem> _mediaItems;
private readonly IScriptEngine _scriptEngine;
private readonly string _scriptFile;
private readonly ILogger _logger;
private readonly int _mediaItemCount;
private readonly Dictionary<int, List<MediaItem>> _mediaItemGroups;
@@ -27,16 +26,14 @@ public class MultiEpisodeShuffleCollectionEnumerator : IMediaCollectionEnumerato
IScriptEngine scriptEngine,
string scriptFile,
ILogger logger,
CancellationToken cancellationToken,
bool skipLoad = false)
CancellationToken cancellationToken)
{
_mediaItems = mediaItems;
_scriptEngine = scriptEngine;
_scriptFile = scriptFile;
_logger = logger;
_cancellationToken = cancellationToken;
if (!skipLoad)
if (!string.IsNullOrWhiteSpace(scriptFile))
{
scriptEngine.Load(scriptFile);
}
@@ -99,10 +96,9 @@ public class MultiEpisodeShuffleCollectionEnumerator : IMediaCollectionEnumerato
_mediaItems,
state,
_scriptEngine,
_scriptFile,
null,
_logger,
cancellationToken,
skipLoad: true);
cancellationToken);
}
public CollectionEnumeratorState State { get; }