Skip to content

Commit

Permalink
Fixes the wvunpack bug on linux
Browse files Browse the repository at this point in the history
I'd previously attempted to fix this bug in 7a83d59 but I hadn't noticed that the if else case used separate argument constuction methods.

I've now simplified the logic and fixed the bug.
  • Loading branch information
atruskie committed Mar 26, 2018
1 parent 9bb43e4 commit 870c09f
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/Acoustics.Tools/Audio/WavPackAudioUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class WavPackAudioUtility : AbstractAudioUtility, IAudioUtility
private const string ArgsDefault = " -m -q -w ";
private const string ArgsSkip = " --skip={0} ";
private const string ArgsUtil = " --until={0}{1} ";
private const string ArgsFile = " \"{0}\" ";
private const string ArgsInputAndOutputFile = " \"{0}\" -o \"{1}\" ";

/// <summary>
/// Initializes a new instance of the <see cref="WavPackAudioUtility"/> class.
Expand Down Expand Up @@ -148,12 +148,12 @@ protected override IEnumerable<string> InvalidOutputMediaTypes
/// </returns>
protected override string ConstructModifyArgs(FileInfo source, FileInfo output, AudioUtilityRequest request)
{
string args;
var sb = new StringBuilder(ArgsDefault);

// only deals with start and end, does not do anything with sampling, channels or bit rate.
if (request.OffsetStart.HasValue || request.OffsetEnd.HasValue)
{
var sb = new StringBuilder(ArgsDefault);

if (request.OffsetStart.HasValue && request.OffsetStart.Value > TimeSpan.Zero)
{
sb.AppendFormat(ArgsSkip, FormatTimeSpan(request.OffsetStart.Value));
Expand All @@ -163,25 +163,19 @@ protected override string ConstructModifyArgs(FileInfo source, FileInfo output,
{
if (request.OffsetStart.HasValue && request.OffsetStart.Value > TimeSpan.Zero)
{
sb.AppendFormat(ArgsUtil, "+", FormatTimeSpan(request.OffsetEnd.Value - request.OffsetStart.Value));
sb.AppendFormat(ArgsUtil, "+",
FormatTimeSpan(request.OffsetEnd.Value - request.OffsetStart.Value));
}
else
{
sb.Append(string.Format(ArgsUtil, string.Empty, FormatTimeSpan(request.OffsetEnd.Value)));
}
}

sb.AppendFormat(ArgsFile, source.FullName);
sb.AppendFormat(ArgsFile, output.FullName);

args = sb.ToString();
}
else
{
args = $" -m -q -w \"{source.FullName}\" -o \"{output.FullName}\" ";
}

return args;
sb.AppendFormat(ArgsInputAndOutputFile, source.FullName, output.FullName);

return sb.ToString();
}

/// <summary>
Expand Down

0 comments on commit 870c09f

Please sign in to comment.