Browse Source

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

pull/1308/head
Jason Dove 2 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 @@ -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 @@ -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
ErsatzTV.Infrastructure/Scheduling/MultiEpisodeShuffleCollectionEnumerator.cs

@ -12,7 +12,6 @@ public class MultiEpisodeShuffleCollectionEnumerator : IMediaCollectionEnumerato @@ -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 @@ -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 @@ -99,10 +96,9 @@ public class MultiEpisodeShuffleCollectionEnumerator : IMediaCollectionEnumerato
_mediaItems,
state,
_scriptEngine,
_scriptFile,
null,
_logger,
cancellationToken,
skipLoad: true);
cancellationToken);
}
public CollectionEnumeratorState State { get; }

Loading…
Cancel
Save