mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-14 11:40:42 +01:00
Remove custom Threading
This commit is contained in:
@@ -18,7 +18,6 @@ using MediaBrowser.Model.Diagnostics;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Session;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Api
|
||||
@@ -48,7 +47,6 @@ namespace MediaBrowser.Api
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
public readonly ITimerFactory TimerFactory;
|
||||
public readonly IProcessFactory ProcessFactory;
|
||||
|
||||
/// <summary>
|
||||
@@ -75,7 +73,6 @@ namespace MediaBrowser.Api
|
||||
IServerConfigurationManager config,
|
||||
IFileSystem fileSystem,
|
||||
IMediaSourceManager mediaSourceManager,
|
||||
ITimerFactory timerFactory,
|
||||
IProcessFactory processFactory,
|
||||
IHttpResultFactory resultFactory)
|
||||
{
|
||||
@@ -84,7 +81,6 @@ namespace MediaBrowser.Api
|
||||
_config = config;
|
||||
_fileSystem = fileSystem;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
TimerFactory = timerFactory;
|
||||
ProcessFactory = processFactory;
|
||||
ResultFactory = resultFactory;
|
||||
|
||||
@@ -260,7 +256,7 @@ namespace MediaBrowser.Api
|
||||
{
|
||||
lock (_activeTranscodingJobs)
|
||||
{
|
||||
var job = new TranscodingJob(Logger, TimerFactory)
|
||||
var job = new TranscodingJob(Logger)
|
||||
{
|
||||
Type = type,
|
||||
Path = path,
|
||||
@@ -765,9 +761,7 @@ namespace MediaBrowser.Api
|
||||
/// Gets or sets the kill timer.
|
||||
/// </summary>
|
||||
/// <value>The kill timer.</value>
|
||||
private ITimer KillTimer { get; set; }
|
||||
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
private Timer KillTimer { get; set; }
|
||||
|
||||
public string DeviceId { get; set; }
|
||||
|
||||
@@ -797,10 +791,9 @@ namespace MediaBrowser.Api
|
||||
public DateTime LastPingDate { get; set; }
|
||||
public int PingTimeout { get; set; }
|
||||
|
||||
public TranscodingJob(ILogger logger, ITimerFactory timerFactory)
|
||||
public TranscodingJob(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
_timerFactory = timerFactory;
|
||||
}
|
||||
|
||||
public void StopKillTimer()
|
||||
@@ -843,7 +836,7 @@ namespace MediaBrowser.Api
|
||||
if (KillTimer == null)
|
||||
{
|
||||
//Logger.LogDebug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId);
|
||||
KillTimer = _timerFactory.Create(callback, this, intervalMs, Timeout.Infinite);
|
||||
KillTimer = new Timer(new TimerCallback(callback), this, intervalMs, Timeout.Infinite);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -336,7 +336,7 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
if (EnableThrottling(state))
|
||||
{
|
||||
transcodingJob.TranscodingThrottler = state.TranscodingThrottler = new TranscodingThrottler(transcodingJob, Logger, ServerConfigurationManager, ApiEntryPoint.Instance.TimerFactory, FileSystem);
|
||||
transcodingJob.TranscodingThrottler = state.TranscodingThrottler = new TranscodingThrottler(transcodingJob, Logger, ServerConfigurationManager, FileSystem);
|
||||
state.TranscodingThrottler.Start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Api.Playback
|
||||
@@ -12,18 +12,16 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
private readonly TranscodingJob _job;
|
||||
private readonly ILogger _logger;
|
||||
private ITimer _timer;
|
||||
private Timer _timer;
|
||||
private bool _isPaused;
|
||||
private readonly IConfigurationManager _config;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public TranscodingThrottler(TranscodingJob job, ILogger logger, IConfigurationManager config, ITimerFactory timerFactory, IFileSystem fileSystem)
|
||||
public TranscodingThrottler(TranscodingJob job, ILogger logger, IConfigurationManager config, IFileSystem fileSystem)
|
||||
{
|
||||
_job = job;
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_timerFactory = timerFactory;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
@@ -34,7 +32,7 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_timer = _timerFactory.Create(TimerCallback, null, 5000, 5000);
|
||||
_timer = new Timer(TimerCallback, null, 5000, 5000);
|
||||
}
|
||||
|
||||
private async void TimerCallback(object state)
|
||||
|
||||
Reference in New Issue
Block a user