Browse Source

fix classic schedule flood bug (#2414)

* clean up some logging

* fix classic schedule flood bug
pull/2415/head
Jason Dove 8 months ago committed by GitHub
parent
commit
64bb1b0d61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 22
      ErsatzTV.Core/Scheduling/PlayoutModeSchedulerBase.cs
  3. 2
      ErsatzTV.Core/Scheduling/PlayoutModeSchedulerFlood.cs
  4. 8
      ErsatzTV.Scanner/Core/Metadata/LocalMetadataProvider.cs

2
CHANGELOG.md

@ -49,6 +49,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -49,6 +49,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix hardware acceleration health check message on mobile
- Fix deco selection logic
- Fix inefficient database migration that would cause database initialization to get stuck
- Classic schedules: fix scheduling behavior when a flood item is before a flexible fixed start item
- Sometimes the flood item wouldn't schedule anything
### Changed
- **BREAKING CHANGE**: change how `Scripted Schedule` system works

22
ErsatzTV.Core/Scheduling/PlayoutModeSchedulerBase.cs

@ -44,14 +44,16 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe @@ -44,14 +44,16 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
public static DateTimeOffset GetStartTimeAfter(
PlayoutBuilderState state,
ProgramScheduleItem scheduleItem,
Option<ILogger> maybeLogger)
Option<ILogger> maybeLogger,
bool isPeek = false)
{
DateTimeOffset startTime = state.CurrentTime.ToLocalTime();
bool isIncomplete = scheduleItem is ProgramScheduleItemMultiple && state.MultipleRemaining.IsSome ||
scheduleItem is ProgramScheduleItemDuration && state.DurationFinish.IsSome ||
scheduleItem is ProgramScheduleItemFlood && state.InFlood ||
scheduleItem is ProgramScheduleItemDuration && state.InDurationFiller;
bool isIncomplete = !isPeek &&
(scheduleItem is ProgramScheduleItemMultiple && state.MultipleRemaining.IsSome ||
scheduleItem is ProgramScheduleItemDuration && state.DurationFinish.IsSome ||
scheduleItem is ProgramScheduleItemFlood && state.InFlood ||
scheduleItem is ProgramScheduleItemDuration && state.InDurationFiller);
if (scheduleItem.StartType == StartType.Fixed && !isIncomplete)
{
@ -84,8 +86,14 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe @@ -84,8 +86,14 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
switch (fixedStartTimeBehavior)
{
case FixedStartTimeBehavior.Flexible:
// only wait for times on the same day
if (result.Day == startTime.Day && result.TimeOfDay > startTime.TimeOfDay)
// if we are peeking from a flood and the flexible time is in the past,
// we should use the next day's time to allow the flood to continue.
if (isPeek && state.InFlood && startTime > result)
{
startTime = result.AddDays(1);
}
// otherwise, only wait for times on the same day
else if (result.Day == startTime.Day && result.TimeOfDay > startTime.TimeOfDay)
{
startTime = result;
}

2
ErsatzTV.Core/Scheduling/PlayoutModeSchedulerFlood.cs

@ -51,7 +51,7 @@ public class PlayoutModeSchedulerFlood : PlayoutModeSchedulerBase<ProgramSchedul @@ -51,7 +51,7 @@ public class PlayoutModeSchedulerFlood : PlayoutModeSchedulerBase<ProgramSchedul
// never block scheduling when there is only one schedule item (with fixed start and flood)
DateTimeOffset peekScheduleItemStart =
scheduleItem.Id != peekScheduleItem.Id && peekScheduleItem.StartType == StartType.Fixed
? GetStartTimeAfter(nextState with { InFlood = false }, peekScheduleItem, Option<ILogger>.None)
? GetStartTimeAfter(nextState with { InFlood = true }, peekScheduleItem, Option<ILogger>.None, true)
: DateTimeOffset.MaxValue;
if (itemDuration == TimeSpan.Zero && mediaItem is RemoteStream)

8
ErsatzTV.Scanner/Core/Metadata/LocalMetadataProvider.cs

@ -1338,14 +1338,7 @@ public class LocalMetadataProvider : ILocalMetadataProvider @@ -1338,14 +1338,7 @@ public class LocalMetadataProvider : ILocalMetadataProvider
{
try
{
_logger.LogDebug("Reading artist metadata from {NfoFileName}", nfoFileName);
_logger.LogDebug("Total memory: {TotalMemory}", GC.GetTotalMemory(false));
Either<BaseError, ArtistNfo> maybeNfo = await _artistNfoReader.ReadFromFile(nfoFileName);
_logger.LogDebug("Finished reading artist metadata from {NfoFileName}", nfoFileName);
_logger.LogDebug("Total memory: {TotalMemory}", GC.GetTotalMemory(false));
foreach (BaseError error in maybeNfo.LeftToSeq())
{
_logger.LogInformation(
@ -1375,7 +1368,6 @@ public class LocalMetadataProvider : ILocalMetadataProvider @@ -1375,7 +1368,6 @@ public class LocalMetadataProvider : ILocalMetadataProvider
catch (Exception ex)
{
_logger.LogInformation(ex, "Failed to read artist nfo metadata from {Path}", nfoFileName);
_logger.LogDebug("Total memory on failure: {TotalMemory}", GC.GetTotalMemory(false));
_client.Notify(ex);
return None;
}

Loading…
Cancel
Save