From 0475bd48b1281a642f4eddbca82b802fbd7c642b Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Thu, 24 Jun 2021 21:49:52 -0600 Subject: [PATCH] Typos and minor corrections. --- .../AaxcDownloadDecrypt/AaxcDownloadConverter.cs | 5 +---- .../AaxcDownloadDecrypt/FFMpegAaxcProcesser.cs | 16 +++++++--------- ...{NetworkFile.cs => NetworkFileAbstraction.cs} | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) rename FileLiberator/AaxcDownloadDecrypt/{NetworkFile.cs => NetworkFileAbstraction.cs} (96%) diff --git a/FileLiberator/AaxcDownloadDecrypt/AaxcDownloadConverter.cs b/FileLiberator/AaxcDownloadDecrypt/AaxcDownloadConverter.cs index 5d54c532..fb1e413e 100644 --- a/FileLiberator/AaxcDownloadDecrypt/AaxcDownloadConverter.cs +++ b/FileLiberator/AaxcDownloadDecrypt/AaxcDownloadConverter.cs @@ -14,9 +14,7 @@ namespace FileLiberator.AaxcDownloadDecrypt public interface ISimpleAaxToM4bConverter2 { event EventHandler DecryptProgressUpdate; - bool Run(); - string AppName { get; set; } string outDir { get; } string outputFileName { get; } @@ -162,7 +160,7 @@ namespace FileLiberator.AaxcDownloadDecrypt private void AaxcProcesser_ProgressUpdate(object sender, TimeSpan e) { - double progressPercent = Math.Max(100 * e.TotalSeconds / tags.duration.TotalSeconds, 1); + double progressPercent = 100 * e.TotalSeconds / tags.duration.TotalSeconds; DecryptProgressUpdate?.Invoke(this, (int)progressPercent); } @@ -185,7 +183,6 @@ namespace FileLiberator.AaxcDownloadDecrypt public bool Step3_InsertCoverArt() { - File.WriteAllBytes(coverArtPath, tags.coverArt); var insertCoverArtInfo = new System.Diagnostics.ProcessStartInfo diff --git a/FileLiberator/AaxcDownloadDecrypt/FFMpegAaxcProcesser.cs b/FileLiberator/AaxcDownloadDecrypt/FFMpegAaxcProcesser.cs index 6503707e..309dee35 100644 --- a/FileLiberator/AaxcDownloadDecrypt/FFMpegAaxcProcesser.cs +++ b/FileLiberator/AaxcDownloadDecrypt/FFMpegAaxcProcesser.cs @@ -8,13 +8,13 @@ namespace FileLiberator.AaxcDownloadDecrypt { /// - /// Download audible aaxc, decrypt, remux, add metadata, and insert cover art. + /// Download audible aaxc, decrypt, remux,and add metadata. /// class FFMpegAaxcProcesser { public event EventHandler ProgressUpdate; public string FFMpegPath { get; } - public bool IsRunning { get; set; } = false; + public bool IsRunning { get; private set; } public bool Succeeded { get; private set; } @@ -57,16 +57,14 @@ namespace FileLiberator.AaxcDownloadDecrypt byte[] buffer = new byte[16 * 1024]; + //All the work done here. Copy download standard output into //remuxer standard input - await Task.Run(() => + do { - do - { - lastRead = pipedOutput.Read(buffer, 0, buffer.Length); - pipedInput.Write(buffer, 0, lastRead); - } while (lastRead > 0 && !remuxer.HasExited); - }); + lastRead = await pipedOutput.ReadAsync(buffer, 0, buffer.Length); + await pipedInput.WriteAsync(buffer, 0, lastRead); + } while (lastRead > 0 && !remuxer.HasExited); pipedInput.Close(); diff --git a/FileLiberator/AaxcDownloadDecrypt/NetworkFile.cs b/FileLiberator/AaxcDownloadDecrypt/NetworkFileAbstraction.cs similarity index 96% rename from FileLiberator/AaxcDownloadDecrypt/NetworkFile.cs rename to FileLiberator/AaxcDownloadDecrypt/NetworkFileAbstraction.cs index 505b07db..71ee70ba 100644 --- a/FileLiberator/AaxcDownloadDecrypt/NetworkFile.cs +++ b/FileLiberator/AaxcDownloadDecrypt/NetworkFileAbstraction.cs @@ -85,7 +85,7 @@ namespace FileLiberator.AaxcDownloadDecrypt } public override int Read(byte[] buffer, int offset, int count) { - long requiredLength = Position + offset + count; + long requiredLength = Position + count; if (requiredLength > networkBytesRead) readWebFileToPosition(requiredLength); @@ -112,7 +112,7 @@ namespace FileLiberator.AaxcDownloadDecrypt /// /// Read more data from into as needed. /// - /// + /// Length of strem required for the operation. private void readWebFileToPosition(long requiredLength) { byte[] buff = new byte[BUFF_SZ];