Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions build/BuildCommon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace BuildScripts;

static class BuildCommon
{
// There is an issue with FFmpeg that causes incompatible reduced quality audio (MGCB medium & low settings)
// to be produced for XAudio2 playback. For reference a ticket has been opened at https://trac.ffmpeg.org/ticket/9397#ticket
// (samples per block should be a power of 2, however FFmpeg incorrectly forces this requirement on the block size
// instead). For now, we'll just patch out the encoder's power of 2 check.
public static void FFmpegApplyXAudio2Fix(BuildContext context)
{
string filePath = "./ffmpeg/libavcodec/adpcmenc.c";
List<string> lines = context.FileReadLines(filePath).ToList();
int lineNumber = lines.FindIndex(x => x.Contains("av_log(avctx, AV_LOG_ERROR, \"block size must be power of 2\\n\");"));
if (lineNumber != -1)
{
lines.RemoveRange(lineNumber, 2);
context.FileWriteLines(filePath, lines.ToArray());
}
}
}
3 changes: 2 additions & 1 deletion build/BuildLinuxTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ public override void Run(BuildContext context)
processSettings.Arguments = $"-c \"make install\"";
context.StartProcess(shellCommandPath, processSettings);

// Build ffmpeg
// Build ffmpeg (with XAudio2 fix)
processSettings.WorkingDirectory = "./ffmpeg";
processSettings.Arguments = $"-c \"make distclean\"";
context.StartProcess(shellCommandPath, processSettings);
BuildCommon.FFmpegApplyXAudio2Fix(context);
processSettings.Arguments = $"-c \"./configure {binDirFlag} {configureFlags}\"";
context.StartProcess(shellCommandPath, processSettings);
processSettings.Arguments = $"-c \"make -j{Environment.ProcessorCount}\"";
Expand Down
3 changes: 2 additions & 1 deletion build/BuildMacOSTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ private static void BuildArm64(BuildContext context)
processSettings.Arguments = $"-c \"make install\"";
context.StartProcess(shellCommandPath, processSettings);

// Build ffmpeg
// Build ffmpeg (with XAudio2 fix)
processSettings.WorkingDirectory = "./ffmpeg";
processSettings.Arguments = $"-c \"make distclean\"";
context.StartProcess(shellCommandPath, processSettings);
BuildCommon.FFmpegApplyXAudio2Fix(context);
processSettings.Arguments = $"-c \"./configure {binDirFlag} {configureFlags} {progsSuffixFlag}\"";
context.StartProcess(shellCommandPath, processSettings);
processSettings.Arguments = $"-c \"make -j{Environment.ProcessorCount}\"";
Expand Down
3 changes: 2 additions & 1 deletion build/BuildWIndowsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ public override void Run(BuildContext context)
processSettings.Arguments = $"-c \"{exports} make install\"";
context.StartProcess(shellCommandPath, processSettings);

// Build ffmpeg
// Build ffmpeg (with XAudio2 fix)
processSettings.WorkingDirectory = "./ffmpeg";
processSettings.Arguments = $"-c \"{exports} make distclean\"";
context.StartProcess(shellCommandPath, processSettings);
BuildCommon.FFmpegApplyXAudio2Fix(context);
processSettings.Arguments = $"-c \"{exports} ./configure {binDirFlag} {configureFlags}\"";
context.StartProcess(shellCommandPath, processSettings);
processSettings.Arguments = $"-c \"{exports} make -j{Environment.ProcessorCount}\"";
Expand Down