Merge pull request #23 from nyanmisaka/fix-deadlock

Fix the deadlock of ffmpeg process on Windows
This commit is contained in:
ConfusedPolarBear 2022-06-15 18:25:27 -05:00 committed by GitHub
commit d5f57f3ca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,9 +114,14 @@ public static class Chromaprint
var info = new ProcessStartInfo(ffmpegPath, args)
{
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
UseShellExecute = false,
ErrorDialog = false,
// We only consume standardOutput.
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = false
};
var ffmpeg = new Process
@ -125,7 +130,6 @@ public static class Chromaprint
};
ffmpeg.Start();
ffmpeg.WaitForExit(timeout);
using (MemoryStream ms = new MemoryStream())
{
@ -139,6 +143,8 @@ public static class Chromaprint
}
while (bytesRead > 0);
ffmpeg.WaitForExit(timeout);
return ms.ToArray().AsSpan();
}
}