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> /// <summary>
/// Transcoding job helpers. /// Transcoding job helpers.
/// </summary> /// </summary>
public class TranscodingJobHelper public class TranscodingJobHelper : IDisposable
{ {
/// <summary> /// <summary>
/// The active transcoding jobs. /// The active transcoding jobs.
@ -46,14 +46,12 @@ namespace Jellyfin.Api.Helpers
private readonly EncodingHelper _encodingHelper; private readonly EncodingHelper _encodingHelper;
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly IIsoManager _isoManager; private readonly IIsoManager _isoManager;
private readonly ILogger<TranscodingJobHelper> _logger; private readonly ILogger<TranscodingJobHelper> _logger;
private readonly IMediaEncoder _mediaEncoder; private readonly IMediaEncoder _mediaEncoder;
private readonly IMediaSourceManager _mediaSourceManager; private readonly IMediaSourceManager _mediaSourceManager;
private readonly IServerConfigurationManager _serverConfigurationManager; private readonly IServerConfigurationManager _serverConfigurationManager;
private readonly ISessionManager _sessionManager; private readonly ISessionManager _sessionManager;
private readonly ILoggerFactory _loggerFactory; private readonly ILoggerFactory _loggerFactory;
private readonly IFileSystem _fileSystem;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TranscodingJobHelper"/> class. /// Initializes a new instance of the <see cref="TranscodingJobHelper"/> class.
@ -861,5 +859,28 @@ namespace Jellyfin.Api.Helpers
_fileSystem.DeleteFile(file); _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;
}
}
} }
} }