From 219cba75069cd2560e9571eee0c7f4a419256dab Mon Sep 17 00:00:00 2001 From: Sven Van den brande Date: Fri, 29 Jul 2016 21:18:03 +0200 Subject: Removed redundant Collection Initializers Removed Using directives that are not required --- MediaBrowser.ServerApplication/MainStartup.cs | 1 - MediaBrowser.ServerApplication/Native/DbConnector.cs | 4 +--- MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs | 3 --- MediaBrowser.ServerApplication/Native/WindowsApp.cs | 1 - 4 files changed, 1 insertion(+), 8 deletions(-) (limited to 'MediaBrowser.ServerApplication') diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index bdfd7d1bb..a87ad7dbf 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -19,7 +19,6 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using CommonIO.Windows; -using Emby.Drawing.ImageMagick; using ImageMagickSharp; using MediaBrowser.Common.Net; using MediaBrowser.Server.Implementations.Logging; diff --git a/MediaBrowser.ServerApplication/Native/DbConnector.cs b/MediaBrowser.ServerApplication/Native/DbConnector.cs index 9aaa96a80..f403ce2ce 100644 --- a/MediaBrowser.ServerApplication/Native/DbConnector.cs +++ b/MediaBrowser.ServerApplication/Native/DbConnector.cs @@ -1,6 +1,4 @@ -using System; -using System.Data; -using System.Data.SQLite; +using System.Data; using System.Threading.Tasks; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations.Persistence; diff --git a/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs b/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs index 67d2e83f0..dc1e3c79b 100644 --- a/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs +++ b/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Runtime.InteropServices; using System.Security; using System.Text; -using System.Threading.Tasks; using CommonIO; namespace MediaBrowser.ServerApplication.Native diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.cs index d8b2720c2..3c9c04acb 100644 --- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs +++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; -using System.Windows.Forms; using CommonIO; using MediaBrowser.Controller.Power; using MediaBrowser.Model.System; -- cgit v1.2.3 From f7c3ee1c6800d98ab1f71a7807a962c682254625 Mon Sep 17 00:00:00 2001 From: softworkz Date: Sat, 30 Jul 2016 01:44:14 +0200 Subject: Fix: Emby notification icon remained visible after shutdown Also implemented the recommended pattern for IDisposable. --- MediaBrowser.ServerApplication/MainStartup.cs | 6 ++ MediaBrowser.ServerApplication/ServerNotifyIcon.cs | 65 ++++++---------------- 2 files changed, 24 insertions(+), 47 deletions(-) (limited to 'MediaBrowser.ServerApplication') diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index bdfd7d1bb..aba4952f3 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -619,6 +619,12 @@ namespace MediaBrowser.ServerApplication private static void ShutdownWindowsApplication() { + if (_serverNotifyIcon != null) + { + _serverNotifyIcon.Dispose(); + _serverNotifyIcon = null; + } + //_logger.Info("Calling Application.Exit"); //Application.Exit(); diff --git a/MediaBrowser.ServerApplication/ServerNotifyIcon.cs b/MediaBrowser.ServerApplication/ServerNotifyIcon.cs index 27816db5a..d04128a18 100644 --- a/MediaBrowser.ServerApplication/ServerNotifyIcon.cs +++ b/MediaBrowser.ServerApplication/ServerNotifyIcon.cs @@ -4,14 +4,13 @@ using MediaBrowser.Controller.Localization; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Startup.Common.Browser; using System; +using System.ComponentModel; using System.Windows.Forms; namespace MediaBrowser.ServerApplication { public class ServerNotifyIcon : IDisposable { - bool IsDisposing = false; - private NotifyIcon notifyIcon1; private ContextMenuStrip contextMenuStrip1; private ToolStripMenuItem cmdExit; @@ -21,25 +20,13 @@ namespace MediaBrowser.ServerApplication private ToolStripMenuItem cmdRestart; private ToolStripSeparator toolStripSeparator1; private ToolStripMenuItem cmdCommunity; + private Container components; private readonly ILogger _logger; private readonly IServerApplicationHost _appHost; private readonly IServerConfigurationManager _configurationManager; private readonly ILocalizationManager _localization; - public bool Visible - { - get - { - return notifyIcon1.Visible; - } - set - { - Action act = () => notifyIcon1.Visible = false; - Invoke(act); - } - } - public void Invoke(Action action) { contextMenuStrip1.Invoke(action); @@ -55,7 +42,7 @@ namespace MediaBrowser.ServerApplication _appHost = appHost; _configurationManager = configurationManager; - var components = new System.ComponentModel.Container(); + components = new System.ComponentModel.Container(); var resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); contextMenuStrip1 = new ContextMenuStrip(components); @@ -138,32 +125,6 @@ namespace MediaBrowser.ServerApplication LocalizeText(); notifyIcon1.DoubleClick += notifyIcon1_DoubleClick; - Application.ThreadExit += Application_ThreadExit; - Application.ApplicationExit += Application_ApplicationExit; - } - - void Application_ThreadExit(object sender, EventArgs e) - { - try - { - notifyIcon1.Visible = false; - } - catch - { - - } - } - - void Application_ApplicationExit(object sender, EventArgs e) - { - try - { - notifyIcon1.Visible = false; - } - catch - { - - } } void notifyIcon1_DoubleClick(object sender, EventArgs e) @@ -222,16 +183,26 @@ namespace MediaBrowser.ServerApplication _appHost.Shutdown(); } - ~ServerNotifyIcon() + public void Dispose() { - Dispose(); + Dispose(true); } - public void Dispose() + protected virtual void Dispose(bool disposing) { - if (!IsDisposing) + if (disposing) { - IsDisposing = true; + if (notifyIcon1 != null) + { + notifyIcon1.Visible = false; + notifyIcon1.Dispose(); + notifyIcon1 = null; + } + + if (components != null) + { + components.Dispose(); + } } } } -- cgit v1.2.3 From b55c02f25d2aa7fd2901b42df4789b2c838896d8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 16 Aug 2016 01:36:41 -0400 Subject: target 4.6.2 --- MediaBrowser.ServerApplication/App.config | 2 +- MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.ServerApplication') diff --git a/MediaBrowser.ServerApplication/App.config b/MediaBrowser.ServerApplication/App.config index 6d840c191..fa7bc9f89 100644 --- a/MediaBrowser.ServerApplication/App.config +++ b/MediaBrowser.ServerApplication/App.config @@ -17,7 +17,7 @@ - + diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index b01d8c43f..9c5470358 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -9,7 +9,7 @@ Properties MediaBrowser.ServerApplication MediaBrowser.ServerApplication - v4.6 + v4.6.2 512 ..\ -- cgit v1.2.3 From 510fbf139cf1df9ba7659351d96cf74eb92c0b23 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 26 Aug 2016 15:29:28 -0400 Subject: fix repeated guide refreshes --- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 5 ++-- MediaBrowser.Model/Dlna/StreamBuilder.cs | 2 +- .../LiveTv/LiveTvManager.cs | 7 +++-- .../LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs | 4 +-- .../Sync/SyncRepository.cs | 32 +++++++++++++++++++++- .../Migrations/UpdateLevelMigration.cs | 4 +-- MediaBrowser.ServerApplication/MainStartup.cs | 2 +- 7 files changed, 44 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.ServerApplication') diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index fe69b38cb..ed64127c3 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -331,12 +331,11 @@ namespace MediaBrowser.Controller.LiveTv /// The user. /// Task. Task AddInfoToProgramDto(List> programs, List fields, User user = null); + /// /// Saves the tuner host. /// - /// The information. - /// Task. - Task SaveTunerHost(TunerHostInfo info); + Task SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true); /// /// Saves the listing provider. /// diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index d042125b9..13d559773 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -602,7 +602,7 @@ namespace MediaBrowser.Model.Dlna private int GetAudioBitrate(string subProtocol, int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream) { - var defaultBitrate = audioStream.BitRate ?? 192000; + var defaultBitrate = audioStream == null ? 192000 : audioStream.BitRate ?? 192000; // Reduce the bitrate if we're downmixing if (targetAudioChannels.HasValue && audioStream != null && audioStream.Channels.HasValue && targetAudioChannels.Value < audioStream.Channels.Value) { diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index ccbcb910d..88017aa59 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2475,7 +2475,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return await _libraryManager.GetNamedView(name, CollectionType.LiveTv, name, cancellationToken).ConfigureAwait(false); } - public async Task SaveTunerHost(TunerHostInfo info) + public async Task SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true) { info = (TunerHostInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(TunerHostInfo)); @@ -2508,7 +2508,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv _config.SaveConfiguration("livetv", config); - _taskManager.CancelIfRunningAndQueue(); + if (dataSourceChanged) + { + _taskManager.CancelIfRunningAndQueue(); + } return info; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs index 43f48b37b..9d5dba282 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs @@ -111,7 +111,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp M3UUrl = info.M3UUrl, IsEnabled = true - }).ConfigureAwait(false); + }, true).ConfigureAwait(false); } else { @@ -120,7 +120,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp existing.M3UUrl = info.M3UUrl; existing.FriendlyName = info.FriendlyName; existing.Tuners = info.Tuners; - await _liveTvManager.SaveTunerHost(existing).ConfigureAwait(false); + await _liveTvManager.SaveTunerHost(existing, false).ConfigureAwait(false); } } catch (OperationCanceledException) diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index 8b0a1d560..64ed00ded 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -618,6 +618,8 @@ namespace MediaBrowser.Server.Implementations.Sync { var result = new Dictionary(); + var now = DateTime.UtcNow; + using (var connection = CreateConnection(true).Result) { using (var cmd = connection.CreateCommand()) @@ -648,10 +650,12 @@ namespace MediaBrowser.Server.Implementations.Sync .Replace("select ItemId,Status,Progress from SyncJobItems", "select ItemIds,Status,Progress from SyncJobs") .Replace("'Synced'", "'Completed','CompletedWithError'"); - Logger.Debug(cmd.CommandText); + //Logger.Debug(cmd.CommandText); using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { + LogQueryTime("GetSyncedItemProgresses", cmd, now); + while (reader.Read()) { AddStatusResult(reader, result, false); @@ -671,6 +675,32 @@ namespace MediaBrowser.Server.Implementations.Sync return result; } + private void LogQueryTime(string methodName, IDbCommand cmd, DateTime startDate) + { + var elapsed = (DateTime.UtcNow - startDate).TotalMilliseconds; + + var slowThreshold = 1000; + +#if DEBUG + slowThreshold = 50; +#endif + + if (elapsed >= slowThreshold) + { + Logger.Debug("{2} query time (slow): {0}ms. Query: {1}", + Convert.ToInt32(elapsed), + cmd.CommandText, + methodName); + } + else + { + //Logger.Debug("{2} query time: {0}ms. Query: {1}", + // Convert.ToInt32(elapsed), + // cmd.CommandText, + // methodName); + } + } + private void AddStatusResult(IDataReader reader, Dictionary result, bool multipleIds) { if (reader.IsDBNull(0)) diff --git a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs index 6d22aaed0..5212b8ac3 100644 --- a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs +++ b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations Version version; if (Version.TryParse(release.tag_name, out version)) { - if (currentVersion >= version) + if (currentVersion > version) { newUpdateLevel = PackageVersionClass.Beta; } @@ -83,7 +83,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations Version version; if (Version.TryParse(release.tag_name, out version)) { - if (currentVersion >= version) + if (currentVersion > version) { newUpdateLevel = PackageVersionClass.Dev; } diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index c40e63374..8f153f33f 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -163,7 +163,7 @@ namespace MediaBrowser.ServerApplication { _logger.Info("Found a duplicate process. Giving it time to exit."); - if (!duplicate.WaitForExit(15000)) + if (!duplicate.WaitForExit(20000)) { _logger.Info("The duplicate process did not exit."); return true; -- cgit v1.2.3