rework shutdown

This commit is contained in:
Luke Pulverenti 2015-10-27 10:02:30 -04:00
parent 8d77308593
commit 60ac2e8712
8 changed files with 72 additions and 12 deletions

View File

@ -225,7 +225,7 @@ namespace Emby.Drawing
return originalImagePath;
}
var quality = options.Quality ?? 90;
var quality = options.Quality;
var outputFormat = GetOutputFormat(options.OutputFormat);
var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, outputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.UnplayedCount, options.BackgroundColor);

View File

@ -623,7 +623,7 @@ namespace MediaBrowser.Api.Images
Item = item,
MaxHeight = request.MaxHeight,
MaxWidth = request.MaxWidth,
Quality = request.Quality,
Quality = request.Quality ?? 100,
Width = request.Width,
AddPlayedIndicator = request.AddPlayedIndicator,
PercentPlayed = request.PercentPlayed ?? 0,

View File

@ -25,7 +25,7 @@ namespace MediaBrowser.Controller.Drawing
public int? MaxHeight { get; set; }
public int? Quality { get; set; }
public int Quality { get; set; }
public List<IImageEnhancer> Enhancers { get; set; }
@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Drawing
public bool HasDefaultOptionsWithoutSize(string originalImagePath)
{
return (!Quality.HasValue || Quality.Value == 100) &&
return (Quality == 100) &&
IsOutputFormatDefault(originalImagePath) &&
!AddPlayedIndicator &&
PercentPlayed.Equals(0) &&

View File

@ -130,13 +130,18 @@ namespace MediaBrowser.MediaEncoding.Probing
var stream = new MediaStream
{
Codec = streamInfo.codec_name,
CodecTag = streamInfo.codec_tag_string,
Profile = streamInfo.profile,
Level = streamInfo.level,
Index = streamInfo.index,
PixelFormat = streamInfo.pix_fmt
};
// Filter out junk
if (!string.IsNullOrWhiteSpace(streamInfo.codec_tag_string) && streamInfo.codec_tag_string.IndexOf("[0]", StringComparison.OrdinalIgnoreCase) == -1)
{
stream.CodecTag = streamInfo.codec_tag_string;
}
if (streamInfo.tags != null)
{
stream.Language = GetDictionaryValue(streamInfo.tags, "language");

View File

@ -27,6 +27,38 @@ namespace MediaBrowser.Server.Implementations.Persistence
AddIsCabacColumn();
AddKeyFramesColumn();
AddRefFramesCommand();
AddCodecTagColumn();
}
private void AddCodecTagColumn()
{
using (var cmd = _connection.CreateCommand())
{
cmd.CommandText = "PRAGMA table_info(mediastreams)";
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
{
while (reader.Read())
{
if (!reader.IsDBNull(1))
{
var name = reader.GetString(1);
if (string.Equals(name, "CodecTag", StringComparison.OrdinalIgnoreCase))
{
return;
}
}
}
}
}
var builder = new StringBuilder();
builder.AppendLine("alter table mediastreams");
builder.AppendLine("add column CodecTag TEXT");
_connection.RunQueries(new[] { builder.ToString() }, _logger);
}
private void AddPixelFormatColumnCommand()

View File

@ -121,7 +121,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
var createMediaStreamsTableCommand
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, IsCabac BIT NULL, KeyFrames TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, IsCabac BIT NULL, KeyFrames TEXT NULL, CodecTag TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
string[] queries = {
@ -320,7 +320,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"IsAnamorphic",
"RefFrames",
"IsCabac",
"KeyFrames"
"KeyFrames",
"CodecTag"
};
/// <summary>
@ -2209,6 +2210,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveStreamCommand.GetParameter(index++).Value = string.Join(",", stream.KeyFrames.Select(i => i.ToString(CultureInfo.InvariantCulture)).ToArray());
}
_saveStreamCommand.GetParameter(index++).Value = stream.CodecTag;
_saveStreamCommand.Transaction = transaction;
_saveStreamCommand.ExecuteNonQuery();
}
@ -2370,6 +2373,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
if (!reader.IsDBNull(27))
{
item.CodecTag = reader.GetString(27);
}
return item;
}

View File

@ -29,6 +29,7 @@ namespace MediaBrowser.ServerApplication
private static ILogger _logger;
private static bool _isRunningAsService = false;
private static bool _appHostDisposed;
/// <summary>
/// Defines the entry point of the application.
@ -329,7 +330,7 @@ namespace MediaBrowser.ServerApplication
{
_logger.Info("Shutting down");
_appHost.Dispose();
DisposeAppHost();
}
/// <summary>
@ -500,14 +501,15 @@ namespace MediaBrowser.ServerApplication
}
else
{
DisposeAppHost();
ShutdownWindowsApplication();
}
}
public static void Restart()
{
_logger.Info("Disposing app host");
_appHost.Dispose();
DisposeAppHost();
if (!_isRunningAsService)
{
@ -522,11 +524,24 @@ namespace MediaBrowser.ServerApplication
}
}
private static void DisposeAppHost()
{
if (!_appHostDisposed)
{
_logger.Info("Disposing app host");
_appHostDisposed = true;
_appHost.Dispose();
}
}
private static void ShutdownWindowsApplication()
{
_logger.Info("Calling Application.Exit");
Application.Exit();
Environment.Exit(0);
_logger.Info("Calling ApplicationTaskCompletionSource.SetResult");
ApplicationTaskCompletionSource.SetResult(true);
}

View File

@ -1,4 +1,4 @@
using System.Reflection;
//[assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyVersion("3.0.5768.7")]
[assembly: AssemblyVersion("3.0.*")]
//[assembly: AssemblyVersion("3.0.5768.7")]