From 74199a889fe9c216fae001d22839b25970dbf2df Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 6 Jun 2017 02:13:07 -0400 Subject: [PATCH 1/4] add skia to mono project --- MediaBrowser.Server.Mono/ImageEncoderHelper.cs | 10 ++++++++++ .../MediaBrowser.Server.Mono.csproj | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/MediaBrowser.Server.Mono/ImageEncoderHelper.cs b/MediaBrowser.Server.Mono/ImageEncoderHelper.cs index 2f7f2a45c..ee0c00065 100644 --- a/MediaBrowser.Server.Mono/ImageEncoderHelper.cs +++ b/MediaBrowser.Server.Mono/ImageEncoderHelper.cs @@ -8,6 +8,7 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller.Drawing; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; +using Emby.Drawing.Skia; namespace MediaBrowser.Server.Startup.Common { @@ -22,6 +23,15 @@ namespace MediaBrowser.Server.Startup.Common { if (!startupOptions.ContainsOption("-enablegdi")) { + //try + //{ + // return new SkiaEncoder(logManager.GetLogger("Skia"), appPaths, httpClient, fileSystem); + //} + //catch + //{ + // logger.Error("Error loading Skia. Will revert to ImageMagick."); + //} + try { return new ImageMagickEncoder(logManager.GetLogger("ImageMagick"), appPaths, httpClient, fileSystem); diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj index ed5e4d96e..96afcec09 100644 --- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj +++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj @@ -114,6 +114,10 @@ {6cfee013-6e7c-432b-ac37-cabf0880c69a} Emby.Drawing.ImageMagick + + {2312da6d-ff86-4597-9777-bceec32d96dd} + Emby.Drawing.Skia + {08fff49b-f175-4807-a2b5-73b0ebd9f716} Emby.Drawing From 8a780bc023c7f66871f94f22fbb1b32d5c5ca14a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 6 Jun 2017 02:13:27 -0400 Subject: [PATCH 2/4] add interlaced fix --- MediaBrowser.Model/Dlna/StreamBuilder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 1e64c04d2..0ecc413f2 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -1180,11 +1180,11 @@ namespace MediaBrowser.Model.Dlna bool isInterlaced; if (bool.TryParse(value, out isInterlaced)) { - if (isInterlaced && condition.Condition == ProfileConditionType.Equals) + if (!isInterlaced && condition.Condition == ProfileConditionType.Equals) { item.DeInterlace = true; } - else if (!isInterlaced && condition.Condition == ProfileConditionType.NotEquals) + else if (isInterlaced && condition.Condition == ProfileConditionType.NotEquals) { item.DeInterlace = true; } From 7bc2a9a081a88ab4e3087ebd3ed756fccd7a020a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 6 Jun 2017 02:13:49 -0400 Subject: [PATCH 3/4] update people editing --- Emby.Server.Core/IO/LibraryMonitor.cs | 8 +++- .../LiveTv/TunerHosts/M3uParser.cs | 14 ++++-- MediaBrowser.Api/ItemUpdateService.cs | 9 ++-- MediaBrowser.Controller/Entities/Video.cs | 3 ++ .../Manager/ProviderManager.cs | 43 ++++++++++++------- 5 files changed, 53 insertions(+), 24 deletions(-) diff --git a/Emby.Server.Core/IO/LibraryMonitor.cs b/Emby.Server.Core/IO/LibraryMonitor.cs index 0f0640a38..ebc5e5e55 100644 --- a/Emby.Server.Core/IO/LibraryMonitor.cs +++ b/Emby.Server.Core/IO/LibraryMonitor.cs @@ -332,7 +332,13 @@ namespace Emby.Server.Core.IO NotifyFilters.Attributes; newWatcher.Created += watcher_Changed; - newWatcher.Deleted += watcher_Changed; + + // Seeing mono crashes on background threads we can't catch, testing if this might help + if (_environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows) + { + newWatcher.Deleted += watcher_Changed; + } + newWatcher.Renamed += watcher_Changed; newWatcher.Changed += watcher_Changed; diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 4c1190e0e..8d73c7e2b 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -235,10 +235,18 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } else { - numberString = Path.GetFileNameWithoutExtension(mediaUrl.Split('/').Last()); - - if (!IsValidChannelNumber(numberString)) + try { + numberString = Path.GetFileNameWithoutExtension(mediaUrl.Split('/').Last()); + + if (!IsValidChannelNumber(numberString)) + { + numberString = null; + } + } + catch + { + // Seeing occasional argument exception here numberString = null; } } diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 58bce3856..8c04e979e 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -206,15 +206,16 @@ namespace MediaBrowser.Api var newLockData = request.LockData ?? false; var isLockedChanged = item.IsLocked != newLockData; - UpdateItem(request, item); - - await item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); - + // Do this first so that metadata savers can pull the updates from the database. if (request.People != null) { await _libraryManager.UpdatePeople(item, request.People.Select(x => new PersonInfo { Name = x.Name, Role = x.Role, Type = x.Type }).ToList()); } + UpdateItem(request, item); + + await item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + if (isLockedChanged && item.IsFolder) { var folder = (Folder)item; diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index fb31d9a47..b6887940e 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -633,14 +633,17 @@ namespace MediaBrowser.Controller.Entities if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Http; + info.SupportsDirectStream = false; } else if (info.Path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtmp; + info.SupportsDirectStream = false; } else if (info.Path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase)) { info.Protocol = MediaProtocol.Rtsp; + info.SupportsDirectStream = false; } else { diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index 16dfd8945..3cdda2cbb 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -13,17 +13,13 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Providers; using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.IO; - using MediaBrowser.Controller.Dto; -using MediaBrowser.Controller.IO; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; using Priority_Queue; @@ -69,6 +65,7 @@ namespace MediaBrowser.Providers.Manager private readonly Func _libraryManagerFactory; private readonly IMemoryStreamFactory _memoryStreamProvider; + private CancellationTokenSource _disposeCancellationTokenSource = new CancellationTokenSource(); /// /// Initializes a new instance of the class. @@ -882,6 +879,13 @@ namespace MediaBrowser.Providers.Manager Tuple refreshItem; var libraryManager = _libraryManagerFactory(); + if (_disposed) + { + return; + } + + var cancellationToken = _disposeCancellationTokenSource.Token; + while (_refreshQueue.TryDequeue(out refreshItem)) { if (_disposed) @@ -902,18 +906,22 @@ namespace MediaBrowser.Providers.Manager var folder = item as Folder; if (folder != null) { - await folder.ValidateChildren(new Progress(), CancellationToken.None).ConfigureAwait(false); + await folder.ValidateChildren(new Progress(), cancellationToken).ConfigureAwait(false); } } var artist = item as MusicArtist; var task = artist == null - ? RefreshItem(item, refreshItem.Item2, CancellationToken.None) - : RefreshArtist(artist, refreshItem.Item2); + ? RefreshItem(item, refreshItem.Item2, cancellationToken) + : RefreshArtist(artist, refreshItem.Item2, cancellationToken); await task.ConfigureAwait(false); } } + catch (OperationCanceledException) + { + break; + } catch (Exception ex) { _logger.ErrorException("Error refreshing item", ex); @@ -928,14 +936,14 @@ namespace MediaBrowser.Providers.Manager private async Task RefreshItem(BaseItem item, MetadataRefreshOptions options, CancellationToken cancellationToken) { - await item.RefreshMetadata(options, CancellationToken.None).ConfigureAwait(false); + await item.RefreshMetadata(options, cancellationToken).ConfigureAwait(false); // Collection folders don't validate their children so we'll have to simulate that here var collectionFolder = item as CollectionFolder; if (collectionFolder != null) { - await RefreshCollectionFolderChildren(options, collectionFolder).ConfigureAwait(false); + await RefreshCollectionFolderChildren(options, collectionFolder, cancellationToken).ConfigureAwait(false); } else { @@ -948,25 +956,23 @@ namespace MediaBrowser.Providers.Manager } } - private async Task RefreshCollectionFolderChildren(MetadataRefreshOptions options, CollectionFolder collectionFolder) + private async Task RefreshCollectionFolderChildren(MetadataRefreshOptions options, CollectionFolder collectionFolder, CancellationToken cancellationToken) { foreach (var child in collectionFolder.Children.ToList()) { - await child.RefreshMetadata(options, CancellationToken.None).ConfigureAwait(false); + await child.RefreshMetadata(options, cancellationToken).ConfigureAwait(false); if (child.IsFolder) { var folder = (Folder)child; - await folder.ValidateChildren(new Progress(), CancellationToken.None, options, true).ConfigureAwait(false); + await folder.ValidateChildren(new Progress(), cancellationToken, options, true).ConfigureAwait(false); } } } - private async Task RefreshArtist(MusicArtist item, MetadataRefreshOptions options) + private async Task RefreshArtist(MusicArtist item, MetadataRefreshOptions options, CancellationToken cancellationToken) { - var cancellationToken = CancellationToken.None; - var albums = _libraryManagerFactory() .GetItemList(new InternalItemsQuery { @@ -991,7 +997,7 @@ namespace MediaBrowser.Providers.Manager try { - await item.RefreshMetadata(options, CancellationToken.None).ConfigureAwait(false); + await item.RefreshMetadata(options, cancellationToken).ConfigureAwait(false); } catch (Exception ex) { @@ -1009,6 +1015,11 @@ namespace MediaBrowser.Providers.Manager public void Dispose() { _disposed = true; + + if (!_disposeCancellationTokenSource.IsCancellationRequested) + { + _disposeCancellationTokenSource.Cancel(); + } } } } \ No newline at end of file From 2546eaa1c2b41096204b9bc9a9e5a3854b37a3be Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 6 Jun 2017 02:14:49 -0400 Subject: [PATCH 4/4] 3.2.19.4 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index b6780901d..e8ce6af30 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.19.3")] +[assembly: AssemblyVersion("3.2.19.4")]