Implement IDisposable

This commit is contained in:
David 2020-08-01 16:21:48 +02:00
parent b717ecd5e0
commit 3f0c0e2d0d

View File

@ -30,7 +30,7 @@ namespace Jellyfin.Api.Helpers
/// <summary>
/// Transcoding job helpers.
/// </summary>
public class TranscodingJobHelper
public class TranscodingJobHelper : IDisposable
{
/// <summary>
/// The active transcoding jobs.
@ -46,14 +46,12 @@ namespace Jellyfin.Api.Helpers
private readonly EncodingHelper _encodingHelper;
private readonly IFileSystem _fileSystem;
private readonly IIsoManager _isoManager;
private readonly ILogger<TranscodingJobHelper> _logger;
private readonly IMediaEncoder _mediaEncoder;
private readonly IMediaSourceManager _mediaSourceManager;
private readonly IServerConfigurationManager _serverConfigurationManager;
private readonly ISessionManager _sessionManager;
private readonly ILoggerFactory _loggerFactory;
private readonly IFileSystem _fileSystem;
/// <summary>
/// Initializes a new instance of the <see cref="TranscodingJobHelper"/> class.
@ -861,5 +859,28 @@ namespace Jellyfin.Api.Helpers
_fileSystem.DeleteFile(file);
}
}
/// <summary>
/// Dispose transcoding job helper.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Dispose throttler.
/// </summary>
/// <param name="disposing">Disposing.</param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_loggerFactory.Dispose();
_sessionManager!.PlaybackProgress -= OnPlaybackProgress;
_sessionManager!.PlaybackStart -= OnPlaybackProgress;
}
}
}
}