Merge pull request #2473 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2017-02-16 02:41:49 -05:00 committed by GitHub
commit e8714c2279
7 changed files with 25 additions and 41 deletions

View File

@ -16,7 +16,6 @@
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\ServiceStack\ServiceStack.csproj" />
<ProjectReference Include="..\Emby.Drawing\Emby.Drawing.csproj" /> <ProjectReference Include="..\Emby.Drawing\Emby.Drawing.csproj" />
<ProjectReference Include="..\Emby.Photos\Emby.Photos.csproj" /> <ProjectReference Include="..\Emby.Photos\Emby.Photos.csproj" />
<ProjectReference Include="..\MediaBrowser.Api\MediaBrowser.Api.csproj" /> <ProjectReference Include="..\MediaBrowser.Api\MediaBrowser.Api.csproj" />

View File

@ -56,9 +56,6 @@
"Emby.Drawing": { "Emby.Drawing": {
"target": "project" "target": "project"
}, },
"ServiceStack": {
"target": "project"
},
"SocketHttpListener.Portable": { "SocketHttpListener.Portable": {
"target": "project" "target": "project"
} }
@ -121,9 +118,6 @@
}, },
"SocketHttpListener.Portable": { "SocketHttpListener.Portable": {
"target": "project" "target": "project"
},
"ServiceStack": {
"target": "project"
} }
} }
} }

View File

@ -767,8 +767,6 @@ namespace Emby.Server.Implementations.HttpServer
{ {
if (_disposed) return; if (_disposed) return;
Dispose();
lock (_disposeLock) lock (_disposeLock)
{ {
if (_disposed) return; if (_disposed) return;

View File

@ -1477,12 +1477,7 @@ namespace Emby.Server.Implementations.LiveTv
private DateTime _lastRecordingRefreshTime; private DateTime _lastRecordingRefreshTime;
private async Task RefreshRecordings(CancellationToken cancellationToken) private async Task RefreshRecordings(CancellationToken cancellationToken)
{ {
const int cacheMinutes = 3; const int cacheMinutes = 2;
if ((DateTime.UtcNow - _lastRecordingRefreshTime).TotalMinutes < cacheMinutes)
{
return;
}
await _refreshRecordingsLock.WaitAsync(cancellationToken).ConfigureAwait(false); await _refreshRecordingsLock.WaitAsync(cancellationToken).ConfigureAwait(false);

View File

@ -303,6 +303,7 @@ namespace Emby.Server.Implementations.ServerManager
/// </summary> /// </summary>
private void DisposeHttpServer() private void DisposeHttpServer()
{ {
_logger.Info("Disposing web socket connections");
foreach (var socket in _webSocketConnections) foreach (var socket in _webSocketConnections)
{ {
// Dispose the connection // Dispose the connection
@ -314,6 +315,9 @@ namespace Emby.Server.Implementations.ServerManager
if (HttpServer != null) if (HttpServer != null)
{ {
HttpServer.WebSocketConnected -= HttpServer_WebSocketConnected; HttpServer.WebSocketConnected -= HttpServer_WebSocketConnected;
_logger.Info("Disposing http server");
HttpServer.Dispose(); HttpServer.Dispose();
} }
} }

View File

@ -19,6 +19,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.Diagnostics;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Text; using MediaBrowser.Model.Text;
using UniversalDetector; using UniversalDetector;
@ -137,18 +138,29 @@ namespace MediaBrowser.MediaEncoding.Subtitles
throw new ArgumentNullException("mediaSourceId"); throw new ArgumentNullException("mediaSourceId");
} }
var subtitle = await GetSubtitleStream(itemId, mediaSourceId, subtitleStreamIndex, cancellationToken) var mediaSources = await _mediaSourceManager.GetPlayackMediaSources(itemId, null, false, new[] { MediaType.Audio, MediaType.Video }, cancellationToken).ConfigureAwait(false);
var mediaSource = mediaSources
.First(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
var subtitleStream = mediaSource.MediaStreams
.First(i => i.Type == MediaStreamType.Subtitle && i.Index == subtitleStreamIndex);
var subtitle = await GetSubtitleStream(mediaSource, subtitleStream, cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);
var inputFormat = subtitle.Item2; var inputFormat = subtitle.Item2;
var writer = TryGetWriter(outputFormat); var writer = TryGetWriter(outputFormat);
if (string.Equals(inputFormat, outputFormat, StringComparison.OrdinalIgnoreCase) && writer == null) // Return the original if we don't have any way of converting it
if (writer == null)
{ {
return subtitle.Item1; return subtitle.Item1;
} }
if (writer == null) // Return the original if the same format is being requested
// Character encoding was already handled in GetSubtitleStream
if (string.Equals(inputFormat, outputFormat, StringComparison.OrdinalIgnoreCase))
{ {
return subtitle.Item1; return subtitle.Item1;
} }
@ -159,36 +171,17 @@ namespace MediaBrowser.MediaEncoding.Subtitles
} }
} }
private async Task<Tuple<Stream, string>> GetSubtitleStream(string itemId, private async Task<Tuple<Stream, string>> GetSubtitleStream(MediaSourceInfo mediaSource,
string mediaSourceId, MediaStream subtitleStream,
int subtitleStreamIndex,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (string.IsNullOrWhiteSpace(itemId))
{
throw new ArgumentNullException("itemId");
}
if (string.IsNullOrWhiteSpace(mediaSourceId))
{
throw new ArgumentNullException("mediaSourceId");
}
var mediaSources = await _mediaSourceManager.GetPlayackMediaSources(itemId, null, false, new[] { MediaType.Audio, MediaType.Video }, cancellationToken).ConfigureAwait(false);
var mediaSource = mediaSources
.First(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
var subtitleStream = mediaSource.MediaStreams
.First(i => i.Type == MediaStreamType.Subtitle && i.Index == subtitleStreamIndex);
var inputFiles = new[] { mediaSource.Path }; var inputFiles = new[] { mediaSource.Path };
if (mediaSource.VideoType.HasValue) if (mediaSource.VideoType.HasValue)
{ {
if (mediaSource.VideoType.Value == VideoType.BluRay || if (mediaSource.VideoType.Value == VideoType.BluRay || mediaSource.VideoType.Value == VideoType.Dvd)
mediaSource.VideoType.Value == VideoType.Dvd)
{ {
var mediaSourceItem = (Video)_libraryManager.GetItemById(new Guid(mediaSourceId)); var mediaSourceItem = (Video)_libraryManager.GetItemById(new Guid(mediaSource.Id));
inputFiles = mediaSourceItem.GetPlayableStreamFiles().ToArray(); inputFiles = mediaSourceItem.GetPlayableStreamFiles().ToArray();
} }
} }

View File

@ -676,6 +676,7 @@ namespace MediaBrowser.ServerApplication
_appHostDisposed = true; _appHostDisposed = true;
_appHost.Dispose(); _appHost.Dispose();
_logger.Info("App host dispose complete");
} }
} }