Add a singleton ITroubleshootingPlaybackStatusStore (Core, alongside TroubleshootingNotifier) that records the exit code + speed of the most recent troubleshooting playback session. A new MediatR notification handler writes to it on PlaybackTroubleshootingCompletedNotification, and PrepareTroubleshootingPlaybackHandler resets it when a new session starts (both the channel and media-item lock paths). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
37 lines
862 B
C#
37 lines
862 B
C#
using ErsatzTV.Core.Interfaces.Troubleshooting;
|
|
|
|
namespace ErsatzTV.Core.Troubleshooting;
|
|
|
|
public class TroubleshootingPlaybackStatusStore : ITroubleshootingPlaybackStatusStore
|
|
{
|
|
private readonly object _sync = new();
|
|
private Option<TroubleshootingPlaybackResult> _result = Option<TroubleshootingPlaybackResult>.None;
|
|
|
|
public Option<TroubleshootingPlaybackResult> CurrentResult
|
|
{
|
|
get
|
|
{
|
|
lock (_sync)
|
|
{
|
|
return _result;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
lock (_sync)
|
|
{
|
|
_result = Option<TroubleshootingPlaybackResult>.None;
|
|
}
|
|
}
|
|
|
|
public void RecordCompletion(int exitCode, Option<double> speed)
|
|
{
|
|
lock (_sync)
|
|
{
|
|
_result = new TroubleshootingPlaybackResult(exitCode, speed);
|
|
}
|
|
}
|
|
}
|