diff --git a/CHANGELOG.md b/CHANGELOG.md index f35c5570a..0bdf0452e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - The goal is to fill the canvas by over-scaling and cropping, instead of minimally scaling and padding - Include `inputstream.ffmpegdirect` properties in channels.m3u when requested by Kodi +### Fixed +- Fix playout bug that caused some schedule items with fixed start times to be pushed to the next day + ### Changed - Upgrade ffmpeg to 6.1, which is now *required* for all installs - Use new ffmpeg throttling method to minimize cpu/gpu use without impacting audio normalization diff --git a/ErsatzTV.Core/Scheduling/PlayoutModeSchedulerBase.cs b/ErsatzTV.Core/Scheduling/PlayoutModeSchedulerBase.cs index dccd6ef51..da47800c5 100644 --- a/ErsatzTV.Core/Scheduling/PlayoutModeSchedulerBase.cs +++ b/ErsatzTV.Core/Scheduling/PlayoutModeSchedulerBase.cs @@ -41,6 +41,7 @@ public abstract class PlayoutModeSchedulerBase : IPlayoutModeScheduler whe public static DateTimeOffset GetStartTimeAfter(PlayoutBuilderState state, ProgramScheduleItem scheduleItem) { DateTimeOffset startTime = state.CurrentTime.ToLocalTime(); + startTime = startTime.AddTicks(-(startTime.Ticks % TimeSpan.TicksPerSecond)); bool isIncomplete = scheduleItem is ProgramScheduleItemMultiple && state.MultipleRemaining.IsSome || scheduleItem is ProgramScheduleItemDuration && state.DurationFinish.IsSome || @@ -50,6 +51,8 @@ public abstract class PlayoutModeSchedulerBase : IPlayoutModeScheduler whe if (scheduleItem.StartType == StartType.Fixed && !isIncomplete) { TimeSpan itemStartTime = scheduleItem.StartTime.GetValueOrDefault(); + itemStartTime = TimeSpan.FromMilliseconds((int)itemStartTime.TotalMilliseconds); + DateTime date = startTime.Date; DateTimeOffset result = new DateTimeOffset( date.Year, @@ -62,7 +65,11 @@ public abstract class PlayoutModeSchedulerBase : IPlayoutModeScheduler whe new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, DateTimeKind.Local))) .Add(itemStartTime); - // DateTimeOffset result = startTime.Date + itemStartTime; + // Serilog.Log.Logger.Debug( + // "StartTimeOfDay: {StartTimeOfDay} Item Start Time: {ItemStartTime}", + // startTime.TimeOfDay.TotalMilliseconds, + // itemStartTime.TotalMilliseconds); + // need to wrap to the next day if appropriate startTime = startTime.TimeOfDay > itemStartTime ? result.AddDays(1) : result; } diff --git a/ErsatzTV.Infrastructure.Tests/ErsatzTV.Infrastructure.Tests.csproj b/ErsatzTV.Infrastructure.Tests/ErsatzTV.Infrastructure.Tests.csproj index 6d0b2d8bd..5f7459c63 100644 --- a/ErsatzTV.Infrastructure.Tests/ErsatzTV.Infrastructure.Tests.csproj +++ b/ErsatzTV.Infrastructure.Tests/ErsatzTV.Infrastructure.Tests.csproj @@ -14,7 +14,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/ErsatzTV.Scanner.Tests/ErsatzTV.Scanner.Tests.csproj b/ErsatzTV.Scanner.Tests/ErsatzTV.Scanner.Tests.csproj index 5c90d26ce..ad30a4ca5 100644 --- a/ErsatzTV.Scanner.Tests/ErsatzTV.Scanner.Tests.csproj +++ b/ErsatzTV.Scanner.Tests/ErsatzTV.Scanner.Tests.csproj @@ -15,7 +15,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/ErsatzTV/ErsatzTV.csproj b/ErsatzTV/ErsatzTV.csproj index 3f678855c..3eecea1e2 100644 --- a/ErsatzTV/ErsatzTV.csproj +++ b/ErsatzTV/ErsatzTV.csproj @@ -59,7 +59,7 @@ - +