mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 09:59:06 -07:00
Remove custom Threading
This commit is contained in:
parent
52294881b1
commit
0ef2b46106
@ -20,7 +20,6 @@ using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.System;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using MediaBrowser.Model.Xml;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Rssdp;
|
||||
@ -50,7 +49,6 @@ namespace Emby.Dlna.Main
|
||||
|
||||
private SsdpDevicePublisher _Publisher;
|
||||
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
private readonly ISocketFactory _socketFactory;
|
||||
private readonly IEnvironmentInfo _environmentInfo;
|
||||
private readonly INetworkManager _networkManager;
|
||||
@ -78,7 +76,6 @@ namespace Emby.Dlna.Main
|
||||
IDeviceDiscovery deviceDiscovery,
|
||||
IMediaEncoder mediaEncoder,
|
||||
ISocketFactory socketFactory,
|
||||
ITimerFactory timerFactory,
|
||||
IEnvironmentInfo environmentInfo,
|
||||
INetworkManager networkManager,
|
||||
IUserViewManager userViewManager,
|
||||
@ -99,7 +96,6 @@ namespace Emby.Dlna.Main
|
||||
_deviceDiscovery = deviceDiscovery;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
_socketFactory = socketFactory;
|
||||
_timerFactory = timerFactory;
|
||||
_environmentInfo = environmentInfo;
|
||||
_networkManager = networkManager;
|
||||
_logger = loggerFactory.CreateLogger("Dlna");
|
||||
@ -233,7 +229,7 @@ namespace Emby.Dlna.Main
|
||||
|
||||
try
|
||||
{
|
||||
_Publisher = new SsdpDevicePublisher(_communicationsServer, _timerFactory, _environmentInfo.OperatingSystemName, _environmentInfo.OperatingSystemVersion);
|
||||
_Publisher = new SsdpDevicePublisher(_communicationsServer, _environmentInfo.OperatingSystemName, _environmentInfo.OperatingSystemVersion);
|
||||
_Publisher.LogFunction = LogMessage;
|
||||
_Publisher.SupportPnpRootDevice = false;
|
||||
|
||||
@ -353,8 +349,7 @@ namespace Emby.Dlna.Main
|
||||
_userDataManager,
|
||||
_localization,
|
||||
_mediaSourceManager,
|
||||
_mediaEncoder,
|
||||
_timerFactory);
|
||||
_mediaEncoder);
|
||||
|
||||
_manager.Start();
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ using Emby.Dlna.Server;
|
||||
using Emby.Dlna.Ssdp;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Dlna.PlayTo
|
||||
@ -19,7 +18,7 @@ namespace Emby.Dlna.PlayTo
|
||||
{
|
||||
#region Fields & Properties
|
||||
|
||||
private ITimer _timer;
|
||||
private Timer _timer;
|
||||
|
||||
public DeviceInfo Properties { get; set; }
|
||||
|
||||
@ -64,21 +63,18 @@ namespace Emby.Dlna.PlayTo
|
||||
public DateTime DateLastActivity { get; private set; }
|
||||
public Action OnDeviceUnavailable { get; set; }
|
||||
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
|
||||
public Device(DeviceInfo deviceProperties, IHttpClient httpClient, ILogger logger, IServerConfigurationManager config, ITimerFactory timerFactory)
|
||||
public Device(DeviceInfo deviceProperties, IHttpClient httpClient, ILogger logger, IServerConfigurationManager config)
|
||||
{
|
||||
Properties = deviceProperties;
|
||||
_httpClient = httpClient;
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_timerFactory = timerFactory;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_logger.LogDebug("Dlna Device.Start");
|
||||
_timer = _timerFactory.Create(TimerCallback, null, 1000, Timeout.Infinite);
|
||||
_timer = new Timer(TimerCallback, null, 1000, Timeout.Infinite);
|
||||
}
|
||||
|
||||
private DateTime _lastVolumeRefresh;
|
||||
@ -890,7 +886,7 @@ namespace Emby.Dlna.PlayTo
|
||||
set;
|
||||
}
|
||||
|
||||
public static async Task<Device> CreateuPnpDeviceAsync(Uri url, IHttpClient httpClient, IServerConfigurationManager config, ILogger logger, ITimerFactory timerFactory, CancellationToken cancellationToken)
|
||||
public static async Task<Device> CreateuPnpDeviceAsync(Uri url, IHttpClient httpClient, IServerConfigurationManager config, ILogger logger, CancellationToken cancellationToken)
|
||||
{
|
||||
var ssdpHttpClient = new SsdpHttpClient(httpClient, config);
|
||||
|
||||
@ -1001,7 +997,7 @@ namespace Emby.Dlna.PlayTo
|
||||
}
|
||||
}
|
||||
|
||||
var device = new Device(deviceProperties, httpClient, logger, config, timerFactory);
|
||||
var device = new Device(deviceProperties, httpClient, logger, config);
|
||||
|
||||
return device;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Session;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Dlna.PlayTo
|
||||
@ -39,13 +38,12 @@ namespace Emby.Dlna.PlayTo
|
||||
private readonly IDeviceDiscovery _deviceDiscovery;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
private readonly IMediaEncoder _mediaEncoder;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
|
||||
private bool _disposed;
|
||||
private SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1);
|
||||
private CancellationTokenSource _disposeCancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
public PlayToManager(ILogger logger, ISessionManager sessionManager, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IServerApplicationHost appHost, IImageProcessor imageProcessor, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient, IServerConfigurationManager config, IUserDataManager userDataManager, ILocalizationManager localization, IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder, ITimerFactory timerFactory)
|
||||
public PlayToManager(ILogger logger, ISessionManager sessionManager, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IServerApplicationHost appHost, IImageProcessor imageProcessor, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient, IServerConfigurationManager config, IUserDataManager userDataManager, ILocalizationManager localization, IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder)
|
||||
{
|
||||
_logger = logger;
|
||||
_sessionManager = sessionManager;
|
||||
@ -61,7 +59,6 @@ namespace Emby.Dlna.PlayTo
|
||||
_localization = localization;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
_timerFactory = timerFactory;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
@ -168,7 +165,7 @@ namespace Emby.Dlna.PlayTo
|
||||
|
||||
if (controller == null)
|
||||
{
|
||||
var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger, _timerFactory, cancellationToken).ConfigureAwait(false);
|
||||
var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
string deviceName = device.Properties.Name;
|
||||
|
||||
|
@ -5,7 +5,6 @@ using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Rssdp;
|
||||
using Rssdp.Infrastructure;
|
||||
@ -48,20 +47,17 @@ namespace Emby.Dlna.Ssdp
|
||||
|
||||
private SsdpDeviceLocator _deviceLocator;
|
||||
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
private readonly ISocketFactory _socketFactory;
|
||||
private ISsdpCommunicationsServer _commsServer;
|
||||
|
||||
public DeviceDiscovery(
|
||||
ILoggerFactory loggerFactory,
|
||||
IServerConfigurationManager config,
|
||||
ISocketFactory socketFactory,
|
||||
ITimerFactory timerFactory)
|
||||
ISocketFactory socketFactory)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger(nameof(DeviceDiscovery));
|
||||
_config = config;
|
||||
_socketFactory = socketFactory;
|
||||
_timerFactory = timerFactory;
|
||||
}
|
||||
|
||||
// Call this method from somewhere in your code to start the search.
|
||||
@ -78,7 +74,7 @@ namespace Emby.Dlna.Ssdp
|
||||
{
|
||||
if (_listenerCount > 0 && _deviceLocator == null)
|
||||
{
|
||||
_deviceLocator = new SsdpDeviceLocator(_commsServer, _timerFactory);
|
||||
_deviceLocator = new SsdpDeviceLocator(_commsServer);
|
||||
|
||||
// (Optional) Set the filter so we only see notifications for devices we care about
|
||||
// (can be any search target value i.e device type, uuid value etc - any value that appears in the
|
||||
|
@ -20,7 +20,6 @@ using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Notifications
|
||||
@ -40,9 +39,8 @@ namespace Emby.Notifications
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
|
||||
private ITimer LibraryUpdateTimer { get; set; }
|
||||
private Timer LibraryUpdateTimer { get; set; }
|
||||
private readonly object _libraryChangedSyncLock = new object();
|
||||
|
||||
private readonly IConfigurationManager _config;
|
||||
@ -52,7 +50,7 @@ namespace Emby.Notifications
|
||||
|
||||
private string[] _coreNotificationTypes;
|
||||
|
||||
public Notifications(IInstallationManager installationManager, IActivityManager activityManager, ILocalizationManager localization, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost, IConfigurationManager config, IDeviceManager deviceManager, ITimerFactory timerFactory)
|
||||
public Notifications(IInstallationManager installationManager, IActivityManager activityManager, ILocalizationManager localization, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost, IConfigurationManager config, IDeviceManager deviceManager)
|
||||
{
|
||||
_installationManager = installationManager;
|
||||
_userManager = userManager;
|
||||
@ -64,7 +62,6 @@ namespace Emby.Notifications
|
||||
_appHost = appHost;
|
||||
_config = config;
|
||||
_deviceManager = deviceManager;
|
||||
_timerFactory = timerFactory;
|
||||
_localization = localization;
|
||||
_activityManager = activityManager;
|
||||
|
||||
@ -159,7 +156,7 @@ namespace Emby.Notifications
|
||||
{
|
||||
if (LibraryUpdateTimer == null)
|
||||
{
|
||||
LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, 5000,
|
||||
LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, 5000,
|
||||
Timeout.Infinite);
|
||||
}
|
||||
else
|
||||
|
@ -43,7 +43,6 @@ using Emby.Server.Implementations.ScheduledTasks;
|
||||
using Emby.Server.Implementations.Security;
|
||||
using Emby.Server.Implementations.Serialization;
|
||||
using Emby.Server.Implementations.Session;
|
||||
using Emby.Server.Implementations.Threading;
|
||||
using Emby.Server.Implementations.TV;
|
||||
using Emby.Server.Implementations.Updates;
|
||||
using Emby.Server.Implementations.Xml;
|
||||
@ -99,7 +98,6 @@ using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Services;
|
||||
using MediaBrowser.Model.System;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using MediaBrowser.Model.Updates;
|
||||
using MediaBrowser.Model.Xml;
|
||||
using MediaBrowser.Providers.Chapters;
|
||||
@ -347,7 +345,6 @@ namespace Emby.Server.Implementations
|
||||
internal IImageEncoder ImageEncoder { get; private set; }
|
||||
|
||||
protected IProcessFactory ProcessFactory { get; private set; }
|
||||
protected ITimerFactory TimerFactory { get; private set; }
|
||||
protected ICryptoProvider CryptographyProvider = new CryptographyProvider();
|
||||
protected readonly IXmlSerializer XmlSerializer;
|
||||
|
||||
@ -772,9 +769,6 @@ namespace Emby.Server.Implementations
|
||||
ProcessFactory = new ProcessFactory();
|
||||
RegisterSingleInstance(ProcessFactory);
|
||||
|
||||
TimerFactory = new TimerFactory();
|
||||
RegisterSingleInstance(TimerFactory);
|
||||
|
||||
var streamHelper = CreateStreamHelper();
|
||||
ApplicationHost.StreamHelper = streamHelper;
|
||||
RegisterSingleInstance(streamHelper);
|
||||
@ -837,7 +831,7 @@ namespace Emby.Server.Implementations
|
||||
var musicManager = new MusicManager(LibraryManager);
|
||||
RegisterSingleInstance<IMusicManager>(new MusicManager(LibraryManager));
|
||||
|
||||
LibraryMonitor = new LibraryMonitor(LoggerFactory, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, TimerFactory, EnvironmentInfo);
|
||||
LibraryMonitor = new LibraryMonitor(LoggerFactory, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, EnvironmentInfo);
|
||||
RegisterSingleInstance(LibraryMonitor);
|
||||
|
||||
RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LoggerFactory, LibraryManager, UserManager));
|
||||
@ -869,7 +863,7 @@ namespace Emby.Server.Implementations
|
||||
DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LoggerFactory, NetworkManager);
|
||||
RegisterSingleInstance(DeviceManager);
|
||||
|
||||
MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder);
|
||||
MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, () => MediaEncoder);
|
||||
RegisterSingleInstance(MediaSourceManager);
|
||||
|
||||
SubtitleManager = new SubtitleManager(LoggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, LocalizationManager);
|
||||
@ -884,7 +878,7 @@ namespace Emby.Server.Implementations
|
||||
ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LoggerFactory, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager);
|
||||
RegisterSingleInstance(ChannelManager);
|
||||
|
||||
SessionManager = new SessionManager(UserDataManager, LoggerFactory, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager, TimerFactory);
|
||||
SessionManager = new SessionManager(UserDataManager, LoggerFactory, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager);
|
||||
RegisterSingleInstance(SessionManager);
|
||||
|
||||
var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LoggerFactory, JsonSerializer, this, assemblyInfo);
|
||||
@ -905,7 +899,7 @@ namespace Emby.Server.Implementations
|
||||
NotificationManager = new NotificationManager(LoggerFactory, UserManager, ServerConfigurationManager);
|
||||
RegisterSingleInstance(NotificationManager);
|
||||
|
||||
RegisterSingleInstance<IDeviceDiscovery>(new DeviceDiscovery(LoggerFactory, ServerConfigurationManager, SocketFactory, TimerFactory));
|
||||
RegisterSingleInstance<IDeviceDiscovery>(new DeviceDiscovery(LoggerFactory, ServerConfigurationManager, SocketFactory));
|
||||
|
||||
ChapterManager = new ChapterManager(LibraryManager, LoggerFactory, ServerConfigurationManager, ItemRepository);
|
||||
RegisterSingleInstance(ChapterManager);
|
||||
|
@ -9,7 +9,6 @@ using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.EntryPoints
|
||||
@ -22,11 +21,10 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
|
||||
private ITimer _timer;
|
||||
private Timer _timer;
|
||||
|
||||
public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config, ILiveTvManager liveTvManager, ITimerFactory timerFactory)
|
||||
public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config, ILiveTvManager liveTvManager)
|
||||
{
|
||||
_appHost = appHost;
|
||||
_logger = logger;
|
||||
@ -34,7 +32,6 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
_sessionManager = sessionManager;
|
||||
_config = config;
|
||||
_liveTvManager = liveTvManager;
|
||||
_timerFactory = timerFactory;
|
||||
}
|
||||
|
||||
public Task RunAsync()
|
||||
@ -53,7 +50,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
|
||||
if (_appHost.HasPendingRestart)
|
||||
{
|
||||
_timer = _timerFactory.Create(TimerCallback, null, TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(15));
|
||||
_timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(15));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Mono.Nat;
|
||||
|
||||
@ -24,19 +23,17 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IDeviceDiscovery _deviceDiscovery;
|
||||
|
||||
private ITimer _timer;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
private Timer _timer;
|
||||
|
||||
private NatManager _natManager;
|
||||
|
||||
public ExternalPortForwarding(ILoggerFactory loggerFactory, IServerApplicationHost appHost, IServerConfigurationManager config, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient, ITimerFactory timerFactory)
|
||||
public ExternalPortForwarding(ILoggerFactory loggerFactory, IServerApplicationHost appHost, IServerConfigurationManager config, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger("PortMapper");
|
||||
_appHost = appHost;
|
||||
_config = config;
|
||||
_deviceDiscovery = deviceDiscovery;
|
||||
_httpClient = httpClient;
|
||||
_timerFactory = timerFactory;
|
||||
_config.ConfigurationUpdated += _config_ConfigurationUpdated1;
|
||||
}
|
||||
|
||||
@ -94,7 +91,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
_natManager.StartDiscovery();
|
||||
}
|
||||
|
||||
_timer = _timerFactory.Create(ClearCreatedRules, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));
|
||||
_timer = new Timer(ClearCreatedRules, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));
|
||||
|
||||
_deviceDiscovery.DeviceDiscovered += _deviceDiscovery_DeviceDiscovered;
|
||||
|
||||
|
@ -14,7 +14,6 @@ using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.EntryPoints
|
||||
@ -29,7 +28,6 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
|
||||
/// <summary>
|
||||
/// The _library changed sync lock
|
||||
@ -47,7 +45,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
/// Gets or sets the library update timer.
|
||||
/// </summary>
|
||||
/// <value>The library update timer.</value>
|
||||
private ITimer LibraryUpdateTimer { get; set; }
|
||||
private Timer LibraryUpdateTimer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The library update duration
|
||||
@ -56,13 +54,12 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
|
||||
private readonly IProviderManager _providerManager;
|
||||
|
||||
public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IUserManager userManager, ILogger logger, ITimerFactory timerFactory, IProviderManager providerManager)
|
||||
public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IUserManager userManager, ILogger logger, IProviderManager providerManager)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_sessionManager = sessionManager;
|
||||
_userManager = userManager;
|
||||
_logger = logger;
|
||||
_timerFactory = timerFactory;
|
||||
_providerManager = providerManager;
|
||||
}
|
||||
|
||||
@ -191,7 +188,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
{
|
||||
if (LibraryUpdateTimer == null)
|
||||
{
|
||||
LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
|
||||
LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
|
||||
Timeout.Infinite);
|
||||
}
|
||||
else
|
||||
@ -225,7 +222,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
{
|
||||
if (LibraryUpdateTimer == null)
|
||||
{
|
||||
LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
|
||||
LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
|
||||
Timeout.Infinite);
|
||||
}
|
||||
else
|
||||
@ -253,7 +250,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
{
|
||||
if (LibraryUpdateTimer == null)
|
||||
{
|
||||
LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
|
||||
LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
|
||||
Timeout.Infinite);
|
||||
}
|
||||
else
|
||||
|
@ -10,7 +10,6 @@ using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.Session;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.EntryPoints
|
||||
@ -23,19 +22,17 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
private readonly object _syncLock = new object();
|
||||
private ITimer UpdateTimer { get; set; }
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
private Timer UpdateTimer { get; set; }
|
||||
private const int UpdateDuration = 500;
|
||||
|
||||
private readonly Dictionary<Guid, List<BaseItem>> _changedItems = new Dictionary<Guid, List<BaseItem>>();
|
||||
|
||||
public UserDataChangeNotifier(IUserDataManager userDataManager, ISessionManager sessionManager, ILogger logger, IUserManager userManager, ITimerFactory timerFactory)
|
||||
public UserDataChangeNotifier(IUserDataManager userDataManager, ISessionManager sessionManager, ILogger logger, IUserManager userManager)
|
||||
{
|
||||
_userDataManager = userDataManager;
|
||||
_sessionManager = sessionManager;
|
||||
_logger = logger;
|
||||
_userManager = userManager;
|
||||
_timerFactory = timerFactory;
|
||||
}
|
||||
|
||||
public Task RunAsync()
|
||||
@ -56,7 +53,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
{
|
||||
if (UpdateTimer == null)
|
||||
{
|
||||
UpdateTimer = _timerFactory.Create(UpdateTimerCallback, null, UpdateDuration,
|
||||
UpdateTimer = new Timer(UpdateTimerCallback, null, UpdateDuration,
|
||||
Timeout.Infinite);
|
||||
}
|
||||
else
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@ -9,7 +10,6 @@ using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.System;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.IO
|
||||
@ -22,8 +22,7 @@ namespace Emby.Server.Implementations.IO
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly List<string> _affectedPaths = new List<string>();
|
||||
private ITimer _timer;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
private Timer _timer;
|
||||
private readonly object _timerLock = new object();
|
||||
public string Path { get; private set; }
|
||||
|
||||
@ -31,7 +30,7 @@ namespace Emby.Server.Implementations.IO
|
||||
private readonly IEnvironmentInfo _environmentInfo;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public FileRefresher(string path, IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, ITaskManager taskManager, ILogger logger, ITimerFactory timerFactory, IEnvironmentInfo environmentInfo, ILibraryManager libraryManager1)
|
||||
public FileRefresher(string path, IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, ITaskManager taskManager, ILogger logger, IEnvironmentInfo environmentInfo, ILibraryManager libraryManager1)
|
||||
{
|
||||
logger.LogDebug("New file refresher created for {0}", path);
|
||||
Path = path;
|
||||
@ -41,7 +40,6 @@ namespace Emby.Server.Implementations.IO
|
||||
LibraryManager = libraryManager;
|
||||
TaskManager = taskManager;
|
||||
Logger = logger;
|
||||
_timerFactory = timerFactory;
|
||||
_environmentInfo = environmentInfo;
|
||||
_libraryManager = libraryManager1;
|
||||
AddPath(path);
|
||||
@ -90,7 +88,7 @@ namespace Emby.Server.Implementations.IO
|
||||
|
||||
if (_timer == null)
|
||||
{
|
||||
_timer = _timerFactory.Create(OnTimerCallback, null, TimeSpan.FromSeconds(ConfigurationManager.Configuration.LibraryMonitorDelay), TimeSpan.FromMilliseconds(-1));
|
||||
_timer = new Timer(OnTimerCallback, null, TimeSpan.FromSeconds(ConfigurationManager.Configuration.LibraryMonitorDelay), TimeSpan.FromMilliseconds(-1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -11,7 +11,6 @@ using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.System;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.IO
|
||||
@ -134,7 +133,6 @@ namespace Emby.Server.Implementations.IO
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
private readonly IEnvironmentInfo _environmentInfo;
|
||||
|
||||
/// <summary>
|
||||
@ -146,7 +144,6 @@ namespace Emby.Server.Implementations.IO
|
||||
ILibraryManager libraryManager,
|
||||
IServerConfigurationManager configurationManager,
|
||||
IFileSystem fileSystem,
|
||||
ITimerFactory timerFactory,
|
||||
IEnvironmentInfo environmentInfo)
|
||||
{
|
||||
if (taskManager == null)
|
||||
@ -159,7 +156,6 @@ namespace Emby.Server.Implementations.IO
|
||||
Logger = loggerFactory.CreateLogger(GetType().Name);
|
||||
ConfigurationManager = configurationManager;
|
||||
_fileSystem = fileSystem;
|
||||
_timerFactory = timerFactory;
|
||||
_environmentInfo = environmentInfo;
|
||||
}
|
||||
|
||||
@ -545,7 +541,7 @@ namespace Emby.Server.Implementations.IO
|
||||
}
|
||||
}
|
||||
|
||||
var newRefresher = new FileRefresher(path, _fileSystem, ConfigurationManager, LibraryManager, TaskManager, Logger, _timerFactory, _environmentInfo, LibraryManager);
|
||||
var newRefresher = new FileRefresher(path, _fileSystem, ConfigurationManager, LibraryManager, TaskManager, Logger, _environmentInfo, LibraryManager);
|
||||
newRefresher.Completed += NewRefresher_Completed;
|
||||
_activeRefreshers.Add(newRefresher);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.Library
|
||||
@ -36,7 +35,6 @@ namespace Emby.Server.Implementations.Library
|
||||
private IMediaSourceProvider[] _providers;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
private readonly Func<IMediaEncoder> _mediaEncoder;
|
||||
private ILocalizationManager _localizationManager;
|
||||
private IApplicationPaths _appPaths;
|
||||
@ -51,7 +49,6 @@ namespace Emby.Server.Implementations.Library
|
||||
IJsonSerializer jsonSerializer,
|
||||
IFileSystem fileSystem,
|
||||
IUserDataManager userDataManager,
|
||||
ITimerFactory timerFactory,
|
||||
Func<IMediaEncoder> mediaEncoder)
|
||||
{
|
||||
_itemRepo = itemRepo;
|
||||
@ -61,7 +58,6 @@ namespace Emby.Server.Implementations.Library
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_fileSystem = fileSystem;
|
||||
_userDataManager = userDataManager;
|
||||
_timerFactory = timerFactory;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
_localizationManager = localizationManager;
|
||||
_appPaths = applicationPaths;
|
||||
|
@ -35,7 +35,6 @@ using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Reflection;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
@ -86,7 +85,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
ILibraryMonitor libraryMonitor,
|
||||
IProviderManager providerManager,
|
||||
IMediaEncoder mediaEncoder,
|
||||
ITimerFactory timerFactory,
|
||||
IProcessFactory processFactory)
|
||||
{
|
||||
Current = this;
|
||||
@ -108,7 +106,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
_streamHelper = streamHelper;
|
||||
|
||||
_seriesTimerProvider = new SeriesTimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers"));
|
||||
_timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger, timerFactory);
|
||||
_timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger);
|
||||
_timerProvider.TimerFired += _timerProvider_TimerFired;
|
||||
|
||||
_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;
|
||||
|
@ -2,29 +2,27 @@ using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
{
|
||||
public class TimerManager : ItemDataProvider<TimerInfo>
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, ITimer> _timers = new ConcurrentDictionary<string, ITimer>(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly ConcurrentDictionary<string, Timer> _timers = new ConcurrentDictionary<string, Timer>(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public event EventHandler<GenericEventArgs<TimerInfo>> TimerFired;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
|
||||
public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1, ITimerFactory timerFactory)
|
||||
public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1)
|
||||
: base(fileSystem, jsonSerializer, logger, dataPath, (r1, r2) => string.Equals(r1.Id, r2.Id, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_logger = logger1;
|
||||
_timerFactory = timerFactory;
|
||||
}
|
||||
|
||||
public void RestartTimers()
|
||||
@ -125,7 +123,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
|
||||
private void StartTimer(TimerInfo item, TimeSpan dueTime)
|
||||
{
|
||||
var timer = _timerFactory.Create(TimerCallback, item.Id, dueTime, TimeSpan.Zero);
|
||||
var timer = new Timer(TimerCallback, item.Id, dueTime, TimeSpan.Zero);
|
||||
|
||||
if (_timers.TryAdd(item.Id, timer))
|
||||
{
|
||||
|
@ -27,7 +27,6 @@ using MediaBrowser.Model.Library;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Session;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.Session
|
||||
@ -60,7 +59,6 @@ namespace Emby.Server.Implementations.Session
|
||||
|
||||
private readonly IAuthenticationRepository _authRepo;
|
||||
private readonly IDeviceManager _deviceManager;
|
||||
private readonly ITimerFactory _timerFactory;
|
||||
|
||||
/// <summary>
|
||||
/// The _active connections
|
||||
@ -103,8 +101,7 @@ namespace Emby.Server.Implementations.Session
|
||||
IHttpClient httpClient,
|
||||
IAuthenticationRepository authRepo,
|
||||
IDeviceManager deviceManager,
|
||||
IMediaSourceManager mediaSourceManager,
|
||||
ITimerFactory timerFactory)
|
||||
IMediaSourceManager mediaSourceManager)
|
||||
{
|
||||
_userDataManager = userDataManager;
|
||||
_logger = loggerFactory.CreateLogger(nameof(SessionManager));
|
||||
@ -119,7 +116,6 @@ namespace Emby.Server.Implementations.Session
|
||||
_authRepo = authRepo;
|
||||
_deviceManager = deviceManager;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
_timerFactory = timerFactory;
|
||||
_deviceManager.DeviceOptionsUpdated += _deviceManager_DeviceOptionsUpdated;
|
||||
}
|
||||
|
||||
@ -503,13 +499,13 @@ namespace Emby.Server.Implementations.Session
|
||||
return users;
|
||||
}
|
||||
|
||||
private ITimer _idleTimer;
|
||||
private Timer _idleTimer;
|
||||
|
||||
private void StartIdleCheckTimer()
|
||||
{
|
||||
if (_idleTimer == null)
|
||||
{
|
||||
_idleTimer = _timerFactory.Create(CheckForIdlePlayback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));
|
||||
_idleTimer = new Timer(CheckForIdlePlayback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));
|
||||
}
|
||||
}
|
||||
private void StopIdleCheckTimer()
|
||||
@ -606,7 +602,7 @@ namespace Emby.Server.Implementations.Session
|
||||
ClearTranscodingInfo(session.DeviceId);
|
||||
}
|
||||
|
||||
session.StartAutomaticProgress(_timerFactory, info);
|
||||
session.StartAutomaticProgress(info);
|
||||
|
||||
var users = GetUsers(session);
|
||||
|
||||
@ -717,7 +713,7 @@ namespace Emby.Server.Implementations.Session
|
||||
|
||||
if (!isAutomated)
|
||||
{
|
||||
session.StartAutomaticProgress(_timerFactory, info);
|
||||
session.StartAutomaticProgress(info);
|
||||
}
|
||||
|
||||
StartIdleCheckTimer();
|
||||
|
@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Threading;
|
||||
|
||||
namespace Emby.Server.Implementations.Threading
|
||||
{
|
||||
public class CommonTimer : ITimer
|
||||
{
|
||||
private readonly Timer _timer;
|
||||
|
||||
public CommonTimer(Action<object> callback, object state, TimeSpan dueTime, TimeSpan period)
|
||||
{
|
||||
_timer = new Timer(new TimerCallback(callback), state, dueTime, period);
|
||||
}
|
||||
|
||||
public CommonTimer(Action<object> callback, object state, int dueTimeMs, int periodMs)
|
||||
{
|
||||
_timer = new Timer(new TimerCallback(callback), state, dueTimeMs, periodMs);
|
||||
}
|
||||
|
||||
public void Change(TimeSpan dueTime, TimeSpan period)
|
||||
{
|
||||
_timer.Change(dueTime, period);
|
||||
}
|
||||
|
||||
public void Change(int dueTimeMs, int periodMs)
|
||||
{
|
||||
_timer.Change(dueTimeMs, periodMs);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_timer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using MediaBrowser.Model.Threading;
|
||||
|
||||
namespace Emby.Server.Implementations.Threading
|
||||
{
|
||||
public class TimerFactory : ITimerFactory
|
||||
{
|
||||
public ITimer Create(Action<object> callback, object state, TimeSpan dueTime, TimeSpan period)
|
||||
{
|
||||
return new CommonTimer(callback, state, dueTime, period);
|
||||
}
|
||||
|
||||
public ITimer Create(Action<object> callback, object state, int dueTimeMs, int periodMs)
|
||||
{
|
||||
return new CommonTimer(callback, state, dueTimeMs, periodMs);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -6,7 +6,6 @@ using System.Net.WebSockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Net
|
||||
@ -23,8 +22,8 @@ namespace MediaBrowser.Controller.Net
|
||||
/// <summary>
|
||||
/// The _active connections
|
||||
/// </summary>
|
||||
protected readonly List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>> ActiveConnections =
|
||||
new List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>>();
|
||||
protected readonly List<Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType>> ActiveConnections =
|
||||
new List<Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType>>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
@ -44,8 +43,6 @@ namespace MediaBrowser.Controller.Net
|
||||
/// </summary>
|
||||
protected ILogger Logger;
|
||||
|
||||
protected ITimerFactory TimerFactory { get; private set; }
|
||||
|
||||
protected BasePeriodicWebSocketListener(ILogger logger)
|
||||
{
|
||||
if (logger == null)
|
||||
@ -111,7 +108,7 @@ namespace MediaBrowser.Controller.Net
|
||||
Logger.LogDebug("{1} Begin transmitting over websocket to {0}", message.Connection.RemoteEndPoint, GetType().Name);
|
||||
|
||||
var timer = SendOnTimer ?
|
||||
TimerFactory.Create(TimerCallback, message.Connection, Timeout.Infinite, Timeout.Infinite) :
|
||||
new Timer(TimerCallback, message.Connection, Timeout.Infinite, Timeout.Infinite) :
|
||||
null;
|
||||
|
||||
var state = new TStateType
|
||||
@ -122,7 +119,7 @@ namespace MediaBrowser.Controller.Net
|
||||
|
||||
lock (ActiveConnections)
|
||||
{
|
||||
ActiveConnections.Add(new Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>(message.Connection, cancellationTokenSource, timer, state));
|
||||
ActiveConnections.Add(new Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType>(message.Connection, cancellationTokenSource, timer, state));
|
||||
}
|
||||
|
||||
if (timer != null)
|
||||
@ -139,7 +136,7 @@ namespace MediaBrowser.Controller.Net
|
||||
{
|
||||
var connection = (IWebSocketConnection)state;
|
||||
|
||||
Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType> tuple;
|
||||
Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType> tuple;
|
||||
|
||||
lock (ActiveConnections)
|
||||
{
|
||||
@ -162,7 +159,7 @@ namespace MediaBrowser.Controller.Net
|
||||
|
||||
protected void SendData(bool force)
|
||||
{
|
||||
Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>[] tuples;
|
||||
Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType>[] tuples;
|
||||
|
||||
lock (ActiveConnections)
|
||||
{
|
||||
@ -190,7 +187,7 @@ namespace MediaBrowser.Controller.Net
|
||||
}
|
||||
}
|
||||
|
||||
private async void SendData(Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType> tuple)
|
||||
private async void SendData(Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType> tuple)
|
||||
{
|
||||
var connection = tuple.Item1;
|
||||
|
||||
@ -249,7 +246,7 @@ namespace MediaBrowser.Controller.Net
|
||||
/// Disposes the connection.
|
||||
/// </summary>
|
||||
/// <param name="connection">The connection.</param>
|
||||
private void DisposeConnection(Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType> connection)
|
||||
private void DisposeConnection(Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType> connection)
|
||||
{
|
||||
Logger.LogDebug("{1} stop transmitting over websocket to {0}", connection.Item1.RemoteEndPoint, GetType().Name);
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Session;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Session
|
||||
@ -268,10 +268,10 @@ namespace MediaBrowser.Controller.Session
|
||||
}
|
||||
|
||||
private readonly object _progressLock = new object();
|
||||
private ITimer _progressTimer;
|
||||
private Timer _progressTimer;
|
||||
private PlaybackProgressInfo _lastProgressInfo;
|
||||
|
||||
public void StartAutomaticProgress(ITimerFactory timerFactory, PlaybackProgressInfo progressInfo)
|
||||
public void StartAutomaticProgress(PlaybackProgressInfo progressInfo)
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
@ -284,7 +284,7 @@ namespace MediaBrowser.Controller.Session
|
||||
|
||||
if (_progressTimer == null)
|
||||
{
|
||||
_progressTimer = timerFactory.Create(OnProgressTimerCallback, null, 1000, 1000);
|
||||
_progressTimer = new Timer(OnProgressTimerCallback, null, 1000, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Threading
|
||||
{
|
||||
public interface ITimer : IDisposable
|
||||
{
|
||||
void Change(TimeSpan dueTime, TimeSpan period);
|
||||
void Change(int dueTimeMs, int periodMs);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Threading
|
||||
{
|
||||
public interface ITimerFactory
|
||||
{
|
||||
ITimer Create(Action<object> callback, object state, TimeSpan dueTime, TimeSpan period);
|
||||
ITimer Create(Action<object> callback, object state, int dueTimeMs, int periodMs);
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Threading;
|
||||
|
||||
namespace Rssdp.Infrastructure
|
||||
{
|
||||
@ -23,8 +22,7 @@ namespace Rssdp.Infrastructure
|
||||
private List<DiscoveredSsdpDevice> _Devices;
|
||||
private ISsdpCommunicationsServer _CommunicationsServer;
|
||||
|
||||
private ITimer _BroadcastTimer;
|
||||
private ITimerFactory _timerFactory;
|
||||
private Timer _BroadcastTimer;
|
||||
private object _timerLock = new object();
|
||||
|
||||
private readonly TimeSpan DefaultSearchWaitTime = TimeSpan.FromSeconds(4);
|
||||
@ -37,12 +35,11 @@ namespace Rssdp.Infrastructure
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public SsdpDeviceLocator(ISsdpCommunicationsServer communicationsServer, ITimerFactory timerFactory)
|
||||
public SsdpDeviceLocator(ISsdpCommunicationsServer communicationsServer)
|
||||
{
|
||||
if (communicationsServer == null) throw new ArgumentNullException(nameof(communicationsServer));
|
||||
|
||||
_CommunicationsServer = communicationsServer;
|
||||
_timerFactory = timerFactory;
|
||||
_CommunicationsServer.ResponseReceived += CommsServer_ResponseReceived;
|
||||
|
||||
_Devices = new List<DiscoveredSsdpDevice>();
|
||||
@ -94,7 +91,7 @@ namespace Rssdp.Infrastructure
|
||||
{
|
||||
if (_BroadcastTimer == null)
|
||||
{
|
||||
_BroadcastTimer = _timerFactory.Create(OnBroadcastTimerCallback, null, dueTime, period);
|
||||
_BroadcastTimer = new Timer(OnBroadcastTimerCallback, null, dueTime, period);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7,7 +7,6 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using Rssdp;
|
||||
|
||||
namespace Rssdp.Infrastructure
|
||||
@ -27,8 +26,7 @@ namespace Rssdp.Infrastructure
|
||||
private IList<SsdpRootDevice> _Devices;
|
||||
private IReadOnlyList<SsdpRootDevice> _ReadOnlyDevices;
|
||||
|
||||
private ITimer _RebroadcastAliveNotificationsTimer;
|
||||
private ITimerFactory _timerFactory;
|
||||
private Timer _RebroadcastAliveNotificationsTimer;
|
||||
|
||||
private IDictionary<string, SearchRequest> _RecentSearchRequests;
|
||||
|
||||
@ -39,7 +37,7 @@ namespace Rssdp.Infrastructure
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public SsdpDevicePublisher(ISsdpCommunicationsServer communicationsServer, ITimerFactory timerFactory, string osName, string osVersion)
|
||||
public SsdpDevicePublisher(ISsdpCommunicationsServer communicationsServer, string osName, string osVersion)
|
||||
{
|
||||
if (communicationsServer == null) throw new ArgumentNullException(nameof(communicationsServer));
|
||||
if (osName == null) throw new ArgumentNullException(nameof(osName));
|
||||
@ -48,7 +46,6 @@ namespace Rssdp.Infrastructure
|
||||
if (osVersion.Length == 0) throw new ArgumentException("osVersion cannot be an empty string.", nameof(osName));
|
||||
|
||||
_SupportPnpRootDevice = true;
|
||||
_timerFactory = timerFactory;
|
||||
_Devices = new List<SsdpRootDevice>();
|
||||
_ReadOnlyDevices = new ReadOnlyCollection<SsdpRootDevice>(_Devices);
|
||||
_RecentSearchRequests = new Dictionary<string, SearchRequest>(StringComparer.OrdinalIgnoreCase);
|
||||
@ -64,7 +61,7 @@ namespace Rssdp.Infrastructure
|
||||
|
||||
public void StartBroadcastingAliveMessages(TimeSpan interval)
|
||||
{
|
||||
_RebroadcastAliveNotificationsTimer = _timerFactory.Create(SendAllAliveNotifications, null, TimeSpan.FromSeconds(5), interval);
|
||||
_RebroadcastAliveNotificationsTimer = new Timer(SendAllAliveNotifications, null, TimeSpan.FromSeconds(5), interval);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user