diff options
Diffstat (limited to 'MediaBrowser.MediaEncoding')
3 files changed, 32 insertions, 23 deletions
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 91bf42b15..d95f894c5 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -498,11 +498,12 @@ namespace MediaBrowser.MediaEncoding.Encoder _logger.LogInformation("Starting {ProcessFileName} with args {ProcessArgs}", _ffprobePath, args); + var memoryStream = new MemoryStream(); + await using (memoryStream.ConfigureAwait(false)) using (var processWrapper = new ProcessWrapper(process, this)) { - await using var memoryStream = new MemoryStream(); StartProcess(processWrapper); - await process.StandardOutput.BaseStream.CopyToAsync(memoryStream, cancellationToken); + await process.StandardOutput.BaseStream.CopyToAsync(memoryStream, cancellationToken).ConfigureAwait(false); memoryStream.Seek(0, SeekOrigin.Begin); InternalMediaInfoResult result; try diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj index 7404c2868..1233fb110 100644 --- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj +++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj @@ -11,10 +11,6 @@ <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> - <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors> - </PropertyGroup> - <ItemGroup> <Compile Include="..\SharedVersion.cs" /> </ItemGroup> @@ -35,7 +31,7 @@ <!-- Code Analyzers--> <ItemGroup Condition=" '$(Configuration)' == 'Debug' "> - <PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.3"> + <PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference> diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index b7c2fd7b1..90bc49132 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -226,7 +226,13 @@ namespace MediaBrowser.MediaEncoding.Subtitles await ExtractTextSubtitle(mediaSource, subtitleStream, outputCodec, outputPath, cancellationToken) .ConfigureAwait(false); - return new SubtitleInfo(outputPath, MediaProtocol.File, outputFormat, false); + return new SubtitleInfo() + { + Path = outputPath, + Protocol = MediaProtocol.File, + Format = outputFormat, + IsExternal = false + }; } var currentFormat = (Path.GetExtension(subtitleStream.Path) ?? subtitleStream.Codec) @@ -240,11 +246,23 @@ namespace MediaBrowser.MediaEncoding.Subtitles await ConvertTextSubtitleToSrt(subtitleStream, mediaSource, outputPath, cancellationToken).ConfigureAwait(false); - return new SubtitleInfo(outputPath, MediaProtocol.File, "srt", true); + return new SubtitleInfo() + { + Path = outputPath, + Protocol = MediaProtocol.File, + Format = "srt", + IsExternal = true + }; } // It's possible that the subtitleStream and mediaSource don't share the same protocol (e.g. .STRM file with local subs) - return new SubtitleInfo(subtitleStream.Path, _mediaSourceManager.GetPathProtocol(subtitleStream.Path), currentFormat, true); + return new SubtitleInfo() + { + Path = subtitleStream.Path, + Protocol = _mediaSourceManager.GetPathProtocol(subtitleStream.Path), + Format = currentFormat, + IsExternal = true + }; } private bool TryGetWriter(string format, [NotNullWhen(true)] out ISubtitleWriter? value) @@ -728,23 +746,17 @@ namespace MediaBrowser.MediaEncoding.Subtitles } } - public readonly struct SubtitleInfo +#pragma warning disable CA1034 // Nested types should not be visible + // Only public for the unit tests + public readonly record struct SubtitleInfo { - public SubtitleInfo(string path, MediaProtocol protocol, string format, bool isExternal) - { - Path = path; - Protocol = protocol; - Format = format; - IsExternal = isExternal; - } - - public string Path { get; } + public string Path { get; init; } - public MediaProtocol Protocol { get; } + public MediaProtocol Protocol { get; init; } - public string Format { get; } + public string Format { get; init; } - public bool IsExternal { get; } + public bool IsExternal { get; init; } } } } |
