diff --git a/Source/AaxDecrypter/AaxDecrypter.csproj b/Source/AaxDecrypter/AaxDecrypter.csproj
index 0e9ee5eb..b27b02b1 100644
--- a/Source/AaxDecrypter/AaxDecrypter.csproj
+++ b/Source/AaxDecrypter/AaxDecrypter.csproj
@@ -5,8 +5,7 @@
-
-
+
diff --git a/Source/AaxDecrypter/AaxcDownloadConvertBase.cs b/Source/AaxDecrypter/AaxcDownloadConvertBase.cs
index 72c9722e..f66e27c3 100644
--- a/Source/AaxDecrypter/AaxcDownloadConvertBase.cs
+++ b/Source/AaxDecrypter/AaxcDownloadConvertBase.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading.Tasks;
using AAXClean;
using Dinah.Core.Net.Http;
@@ -109,10 +110,11 @@ namespace AaxDecrypter
});
}
- public override void Cancel()
+ public override async Task CancelAsync()
{
IsCanceled = true;
- AaxFile?.Cancel();
+ if (AaxFile != null)
+ await AaxFile.CancelAsync();
AaxFile?.Dispose();
CloseInputFileStream();
}
diff --git a/Source/AaxDecrypter/AaxcDownloadMultiConverter.cs b/Source/AaxDecrypter/AaxcDownloadMultiConverter.cs
index 18b6851a..76026a2e 100644
--- a/Source/AaxDecrypter/AaxcDownloadMultiConverter.cs
+++ b/Source/AaxDecrypter/AaxcDownloadMultiConverter.cs
@@ -61,7 +61,7 @@ That naming may not be desirable for everyone, but it's an easy change to instea
{
var zeroProgress = Step_DownloadAudiobook_Start();
- var chapters = DownloadOptions.ChapterInfo.Chapters.ToList();
+ var chapters = DownloadOptions.ChapterInfo.Chapters;
// Ensure split files are at least minChapterLength in duration.
var splitChapters = new ChapterInfo(DownloadOptions.ChapterInfo.StartOffset);
@@ -104,8 +104,13 @@ That naming may not be desirable for everyone, but it's an easy change to instea
{
var chapterCount = 0;
return AaxFile.ConvertToMultiMp4a(splitChapters, newSplitCallback =>
- createOutputFileStream(++chapterCount, splitChapters, newSplitCallback),
- DownloadOptions.TrimOutputToChapterLength);
+ {
+ createOutputFileStream(++chapterCount, splitChapters, newSplitCallback);
+
+ newSplitCallback.TrackNumber = chapterCount;
+ newSplitCallback.TrackCount = splitChapters.Count;
+
+ }, DownloadOptions.TrimOutputToChapterLength);
}
private ConversionResult ConvertToMultiMp3(ChapterInfo splitChapters)
@@ -114,7 +119,10 @@ That naming may not be desirable for everyone, but it's an easy change to instea
return AaxFile.ConvertToMultiMp3(splitChapters, newSplitCallback =>
{
createOutputFileStream(++chapterCount, splitChapters, newSplitCallback);
- ((NAudio.Lame.LameConfig)newSplitCallback.UserState).ID3.Track = chapterCount.ToString();
+
+ newSplitCallback.TrackNumber = chapterCount;
+ newSplitCallback.TrackCount = splitChapters.Count;
+
}, DownloadOptions.LameConfig, DownloadOptions.TrimOutputToChapterLength);
}
@@ -125,7 +133,8 @@ That naming may not be desirable for everyone, but it's an easy change to instea
OutputFileName = OutputFileName,
PartsPosition = currentChapter,
PartsTotal = splitChapters.Count,
- Title = newSplitCallback?.Chapter?.Title
+ Title = newSplitCallback?.Chapter?.Title,
+
});
fileName = FileUtility.GetValidFilename(fileName);
diff --git a/Source/AaxDecrypter/AudiobookDownloadBase.cs b/Source/AaxDecrypter/AudiobookDownloadBase.cs
index 3ce6c432..34e10579 100644
--- a/Source/AaxDecrypter/AudiobookDownloadBase.cs
+++ b/Source/AaxDecrypter/AudiobookDownloadBase.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Threading.Tasks;
using Dinah.Core;
using Dinah.Core.Net.Http;
using Dinah.Core.StepRunner;
@@ -55,7 +56,7 @@ namespace AaxDecrypter
FileUtility.SaferDelete(OutputFileName);
}
- public abstract void Cancel();
+ public abstract Task CancelAsync();
public virtual void SetCoverArt(byte[] coverArt)
{
diff --git a/Source/AaxDecrypter/UnencryptedAudiobookDownloader.cs b/Source/AaxDecrypter/UnencryptedAudiobookDownloader.cs
index 885e839b..1040684b 100644
--- a/Source/AaxDecrypter/UnencryptedAudiobookDownloader.cs
+++ b/Source/AaxDecrypter/UnencryptedAudiobookDownloader.cs
@@ -1,5 +1,6 @@
using System;
using System.Threading;
+using System.Threading.Tasks;
using Dinah.Core.Net.Http;
using Dinah.Core.StepRunner;
using FileManager;
@@ -24,10 +25,11 @@ namespace AaxDecrypter
};
}
- public override void Cancel()
+ public override Task CancelAsync()
{
IsCanceled = true;
CloseInputFileStream();
+ return Task.CompletedTask;
}
protected bool Step_GetMetadata()
diff --git a/Source/FileLiberator/AudioDecodable.cs b/Source/FileLiberator/AudioDecodable.cs
index f54e4b25..800b711b 100644
--- a/Source/FileLiberator/AudioDecodable.cs
+++ b/Source/FileLiberator/AudioDecodable.cs
@@ -1,6 +1,7 @@
using LibationFileManager;
using NAudio.Lame;
using System;
+using System.Threading.Tasks;
namespace FileLiberator
{
@@ -12,7 +13,7 @@ namespace FileLiberator
public event EventHandler AuthorsDiscovered;
public event EventHandler NarratorsDiscovered;
public event EventHandler CoverImageDiscovered;
- public abstract void Cancel();
+ public abstract Task CancelAsync();
protected LameConfig GetLameOptions(Configuration config)
{
diff --git a/Source/FileLiberator/ConvertToMp3.cs b/Source/FileLiberator/ConvertToMp3.cs
index 92b2a3f2..58f54a0b 100644
--- a/Source/FileLiberator/ConvertToMp3.cs
+++ b/Source/FileLiberator/ConvertToMp3.cs
@@ -19,10 +19,7 @@ namespace FileLiberator
private long fileSize;
private static string Mp3FileName(string m4bPath) => Path.ChangeExtension(m4bPath ?? "", ".mp3");
- public override void Cancel()
- {
- m4bBook?.Cancel();
- }
+ public override Task CancelAsync() => m4bBook?.CancelAsync();
public static bool ValidateMp3(LibraryBook libraryBook)
{
diff --git a/Source/FileLiberator/DownloadDecryptBook.cs b/Source/FileLiberator/DownloadDecryptBook.cs
index 5a12657e..d0f66e3d 100644
--- a/Source/FileLiberator/DownloadDecryptBook.cs
+++ b/Source/FileLiberator/DownloadDecryptBook.cs
@@ -21,7 +21,7 @@ namespace FileLiberator
public override bool Validate(LibraryBook libraryBook) => !libraryBook.Book.Audio_Exists();
- public override void Cancel() => abDownloader?.Cancel();
+ public override Task CancelAsync() => abDownloader?.CancelAsync();
public override async Task ProcessAsync(LibraryBook libraryBook)
{
diff --git a/Source/LibationWinForms/ProcessQueue/ProcessBook.cs b/Source/LibationWinForms/ProcessQueue/ProcessBook.cs
index 0ddf4433..d4666e2e 100644
--- a/Source/LibationWinForms/ProcessQueue/ProcessBook.cs
+++ b/Source/LibationWinForms/ProcessQueue/ProcessBook.cs
@@ -143,10 +143,7 @@ namespace LibationWinForms.ProcessQueue
try
{
if (CurrentProcessable is AudioDecodable audioDecodable)
- {
- //There's some threadding bug that causes this to hang if executed synchronously.
- await Task.Run(audioDecodable.Cancel);
- }
+ await audioDecodable.CancelAsync();
}
catch (Exception ex)
{