aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs47
1 files changed, 12 insertions, 35 deletions
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index 97f2c57eb..af826f231 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -50,16 +50,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim(1, 1);
/// <summary>
- /// The video image resource pool
- /// </summary>
- private readonly SemaphoreSlim _videoImageResourcePool = new SemaphoreSlim(1, 1);
-
- /// <summary>
- /// The audio image resource pool
- /// </summary>
- private readonly SemaphoreSlim _audioImageResourcePool = new SemaphoreSlim(2, 2);
-
- /// <summary>
/// The FF probe resource pool
/// </summary>
private readonly SemaphoreSlim _ffProbeResourcePool = new SemaphoreSlim(2, 2);
@@ -724,8 +714,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
private async Task<string> ExtractImage(string[] inputFiles, string container, int? imageStreamIndex, MediaProtocol protocol, bool isAudio,
Video3DFormat? threedFormat, TimeSpan? offset, CancellationToken cancellationToken)
{
- var resourcePool = isAudio ? _audioImageResourcePool : _videoImageResourcePool;
-
var inputArgument = GetInputArgument(inputFiles, protocol);
if (isAudio)
@@ -740,7 +728,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
try
{
- return await ExtractImageInternal(inputArgument, container, imageStreamIndex, protocol, threedFormat, offset, true, resourcePool, cancellationToken).ConfigureAwait(false);
+ return await ExtractImageInternal(inputArgument, container, imageStreamIndex, protocol, threedFormat, offset, true, cancellationToken).ConfigureAwait(false);
}
catch (ArgumentException)
{
@@ -752,10 +740,10 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
}
- return await ExtractImageInternal(inputArgument, container, imageStreamIndex, protocol, threedFormat, offset, false, resourcePool, cancellationToken).ConfigureAwait(false);
+ return await ExtractImageInternal(inputArgument, container, imageStreamIndex, protocol, threedFormat, offset, false, cancellationToken).ConfigureAwait(false);
}
- private async Task<string> ExtractImageInternal(string inputPath, string container, int? imageStreamIndex, MediaProtocol protocol, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
+ private async Task<string> ExtractImageInternal(string inputPath, string container, int? imageStreamIndex, MediaProtocol protocol, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(inputPath))
{
@@ -835,31 +823,21 @@ namespace MediaBrowser.MediaEncoding.Encoder
using (var processWrapper = new ProcessWrapper(process, this, _logger))
{
- await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
-
bool ranToCompletion;
- try
- {
- StartProcess(processWrapper);
+ StartProcess(processWrapper);
- var timeoutMs = ConfigurationManager.Configuration.ImageExtractionTimeoutMs;
- if (timeoutMs <= 0)
- {
- timeoutMs = DefaultImageExtractionTimeoutMs;
- }
+ var timeoutMs = ConfigurationManager.Configuration.ImageExtractionTimeoutMs;
+ if (timeoutMs <= 0)
+ {
+ timeoutMs = DefaultImageExtractionTimeoutMs;
+ }
- ranToCompletion = process.WaitForExit(timeoutMs);
+ ranToCompletion = process.WaitForExit(timeoutMs);
- if (!ranToCompletion)
- {
- StopProcess(processWrapper, 1000);
- }
-
- }
- finally
+ if (!ranToCompletion)
{
- resourcePool.Release();
+ StopProcess(processWrapper, 1000);
}
var exitCode = ranToCompletion ? processWrapper.ExitCode ?? 0 : -1;
@@ -1118,7 +1096,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
if (dispose)
{
- _videoImageResourcePool.Dispose();
StopProcesses();
}
}