Browse Source

Merge pull request #14960 from karm235/13697-fix-lufs-detection

Fix LUFS detection deadlock per issue #13697
Joshua M. Boniface 1 week ago
parent
commit
c88d792963

+ 11 - 3
Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs

@@ -261,14 +261,22 @@ public partial class AudioNormalizationTask : IScheduledTask
 
 
             using var reader = process.StandardError;
             using var reader = process.StandardError;
             float? lufs = null;
             float? lufs = null;
+            var foundLufs = false;
             await foreach (var line in reader.ReadAllLinesAsync(cancellationToken).ConfigureAwait(false))
             await foreach (var line in reader.ReadAllLinesAsync(cancellationToken).ConfigureAwait(false))
             {
             {
+                if (foundLufs)
+                {
+                    continue;
+                }
+
                 Match match = LUFSRegex().Match(line);
                 Match match = LUFSRegex().Match(line);
-                if (match.Success)
+                if (!match.Success)
                 {
                 {
-                    lufs = float.Parse(match.Groups[1].ValueSpan, CultureInfo.InvariantCulture.NumberFormat);
-                    break;
+                    continue;
                 }
                 }
+
+                lufs = float.Parse(match.Groups[1].ValueSpan, CultureInfo.InvariantCulture.NumberFormat);
+                foundLufs = true;
             }
             }
 
 
             if (lufs is null)
             if (lufs is null)