From 07c4f26a8eadf47858ddc6bb3e43351d3416af0b Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Sat, 14 Oct 2023 00:51:32 +0200 Subject: [PATCH 1/5] ci: Install nasm for Ubuntu AppImage build Ubuntu doesn't have ffmpeg 6.0 yet, but we want to bundle ffms2 master since the distro version still has seeking issues. Compiling the ffmpeg wrap needs nasm. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0ad7bdf9..1ec541296 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,7 +118,7 @@ jobs: if: startsWith(matrix.config.os, 'ubuntu-') run: | sudo apt-get update - sudo apt-get install ninja-build build-essential libx11-dev libwxgtk3.0-gtk3-dev libfreetype6-dev pkg-config libfontconfig1-dev libass-dev libasound2-dev libffms2-dev intltool libboost-all-dev libhunspell-dev libuchardet-dev libpulse-dev libopenal-dev libjansson-dev + sudo apt-get install ninja-build build-essential libx11-dev libwxgtk3.0-gtk3-dev libfreetype6-dev pkg-config libfontconfig1-dev libass-dev libasound2-dev libffms2-dev intltool libboost-all-dev libhunspell-dev libuchardet-dev libpulse-dev libopenal-dev libjansson-dev nasm - name: Configure run: meson setup build ${{ matrix.config.args }} -Dbuildtype=${{ matrix.config.buildtype }} From dd3016a89d9607da91aa2c6efb34385591dba617 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Sun, 15 Oct 2023 22:27:21 +0200 Subject: [PATCH 2/5] Further fixes to audio/video provider selection - Fix selection not aborting when the preferred provider returns null - Fix the default video provider being "ffmpegsource" (lowercase) instead of "FFmpegSource", which would trip up provider selection - More generally, make sure the preferred video provider actually exists and fall back to the default (FFmpegSource) if not. Fixes arch1t3cht/Aegisub#23 . Fixes arch1t3cht/Aegisub#61 . Fixes arch1t3cht/Aegisub#83 . --- src/audio_provider_factory.cpp | 14 +++++++++++--- src/libresrc/default_config.json | 4 ++-- src/libresrc/osx/default_config.json | 4 ++-- src/video_provider_manager.cpp | 14 +++++++++++--- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/audio_provider_factory.cpp b/src/audio_provider_factory.cpp index d5904a532..3af069c3b 100644 --- a/src/audio_provider_factory.cpp +++ b/src/audio_provider_factory.cpp @@ -70,6 +70,11 @@ std::unique_ptr SelectAudioProvider(fs::path const& filename Path const& path_helper, BackgroundRunner *br) { auto preferred = OPT_GET("Audio/Provider")->GetString(); + + if (!std::any_of(std::begin(providers), std::end(providers), [&](factory provider) { return provider.name == preferred; })) { + preferred = OPT_GET("Audio/Provider")->GetDefaultString(); + } + auto sorted = GetSorted(boost::make_iterator_range(std::begin(providers), std::end(providers)), preferred); RearrangeWithPriority(sorted, filename); @@ -84,9 +89,12 @@ std::unique_ptr SelectAudioProvider(fs::path const& filename std::string err; try { auto provider = factory->create(filename, br); - if (!provider) continue; - LOG_I("audio_provider") << "Using audio provider: " << factory->name; - return provider; + if (!provider) { + err = "Failed to create provider."; // Some generic error message here + } else { + LOG_I("audio_provider") << "Using audio provider: " << factory->name; + return provider; + } } catch (AudioDataNotFound const& ex) { found_file = true; diff --git a/src/libresrc/default_config.json b/src/libresrc/default_config.json index bafd52eb6..0eb8fb6b1 100644 --- a/src/libresrc/default_config.json +++ b/src/libresrc/default_config.json @@ -66,7 +66,7 @@ "Next Line on Commit" : true, "Player" : "", "Plays When Stepping Video" : false, - "Provider" : "ffmpegsource", + "Provider" : "FFmpegSource", "Renderer" : { "Spectrum" : { "Cutoff" : 0, @@ -660,7 +660,7 @@ "Last Script Resolution Mismatch Choice" : 2, "Open Audio" : true, "Overscan Mask" : false, - "Provider" : "ffmpegsource", + "Provider" : "FFmpegSource", "Script Resolution Mismatch" : 1, "Slider" : { "Fast Jump Step" : 10, diff --git a/src/libresrc/osx/default_config.json b/src/libresrc/osx/default_config.json index bcf3c42d4..faaa0d571 100644 --- a/src/libresrc/osx/default_config.json +++ b/src/libresrc/osx/default_config.json @@ -66,7 +66,7 @@ "Next Line on Commit" : true, "Player" : "", "Plays When Stepping Video" : false, - "Provider" : "ffmpegsource", + "Provider" : "FFmpegSource", "Renderer" : { "Spectrum" : { "Cutoff" : 0, @@ -660,7 +660,7 @@ "Last Script Resolution Mismatch Choice" : 2, "Open Audio" : true, "Overscan Mask" : false, - "Provider" : "ffmpegsource", + "Provider" : "FFmpegSource", "Script Resolution Mismatch" : 1, "Slider" : { "Fast Jump Step" : 10, diff --git a/src/video_provider_manager.cpp b/src/video_provider_manager.cpp index cf3c6f1b2..7f7ad117e 100644 --- a/src/video_provider_manager.cpp +++ b/src/video_provider_manager.cpp @@ -69,6 +69,11 @@ std::vector VideoProviderFactory::GetClasses() { std::unique_ptr VideoProviderFactory::GetProvider(agi::fs::path const& filename, std::string const& colormatrix, agi::BackgroundRunner *br) { auto preferred = OPT_GET("Video/Provider")->GetString(); + + if (!std::any_of(std::begin(providers), std::end(providers), [&](factory provider) { return provider.name == preferred; })) { + preferred = OPT_GET("Audio/Provider")->GetDefaultString(); + } + auto sorted = GetSorted(boost::make_iterator_range(std::begin(providers), std::end(providers)), preferred); RearrangeWithPriority(sorted, filename); @@ -89,9 +94,12 @@ std::unique_ptr VideoProviderFactory::GetProvider(agi::fs::path c std::string err; try { auto provider = factory->create(filename, colormatrix, br); - if (!provider) continue; - LOG_I("manager/video/provider") << factory->name << ": opened " << filename; - return finalize_provider(std::move(provider)); + if (!provider) { + err = "Failed to create provider."; // Some generic error message here + } else { + LOG_I("manager/video/provider") << factory->name << ": opened " << filename; + return finalize_provider(std::move(provider)); + } } catch (VideoNotSupported const& ex) { found = true; From a9eed184c292e06131761d5a54fc7c01001b8ea4 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Sun, 15 Oct 2023 22:58:23 +0200 Subject: [PATCH 3/5] Revert "avisynth: Only increase refcount when fully initialized" This reverts commit f5a730fa45343faa157af1c988c98e5badff7a6d. --- src/avisynth_wrap.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/avisynth_wrap.cpp b/src/avisynth_wrap.cpp index 1dc5d71b2..eb957fa3c 100644 --- a/src/avisynth_wrap.cpp +++ b/src/avisynth_wrap.cpp @@ -67,7 +67,7 @@ const AVS_Linkage *AVS_linkage = nullptr; typedef IScriptEnvironment* __stdcall FUNC(int); AviSynthWrapper::AviSynthWrapper() { - if (!avs_refcount){ + if (!avs_refcount++) { #ifdef _WIN32 #define CONCATENATE(x, y) x ## y #define _Lstr(x) CONCATENATE(L, x) @@ -94,8 +94,6 @@ AviSynthWrapper::AviSynthWrapper() { if (!env) throw AvisynthError("Failed to create a new avisynth script environment. Avisynth is too old?"); - avs_refcount++; - AVS_linkage = env->GetAVSLinkage(); // Set memory limit From 858f4acf3544e7938ac3c6878fb098b3b4fc386f Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Sun, 15 Oct 2023 23:08:39 +0200 Subject: [PATCH 4/5] avisynth: Decrease refcount again when constructor fails Proper fix to the issue that f5a730fa45343faa157af1c988c98e5badff7a6d was trying to fix. Fixes arch1t3cht/Aegisub#61 . --- src/avisynth_wrap.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/avisynth_wrap.cpp b/src/avisynth_wrap.cpp index eb957fa3c..3473efd94 100644 --- a/src/avisynth_wrap.cpp +++ b/src/avisynth_wrap.cpp @@ -53,6 +53,7 @@ // Allocate storage for and initialise static members namespace { int avs_refcount = 0; + bool failed = false; #ifdef _WIN32 HINSTANCE hLib = nullptr; #else @@ -66,7 +67,7 @@ const AVS_Linkage *AVS_linkage = nullptr; typedef IScriptEnvironment* __stdcall FUNC(int); -AviSynthWrapper::AviSynthWrapper() { +AviSynthWrapper::AviSynthWrapper() try { if (!avs_refcount++) { #ifdef _WIN32 #define CONCATENATE(x, y) x ## y @@ -101,6 +102,9 @@ AviSynthWrapper::AviSynthWrapper() { if (memoryMax) env->SetMemoryMax(memoryMax); } +} catch (AvisynthError const&) { + avs_refcount--; + throw; } AviSynthWrapper::~AviSynthWrapper() { From fabc6e436f38b068d6aad4def3bbaece045fb632 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 17 Oct 2023 18:26:49 +0200 Subject: [PATCH 5/5] osx: Sign executable and libraries after bundling --- tools/osx-bundle.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/osx-bundle.sh b/tools/osx-bundle.sh index 29e0fbfd9..813151a55 100755 --- a/tools/osx-bundle.sh +++ b/tools/osx-bundle.sh @@ -105,5 +105,14 @@ echo echo "---- Fixing libraries ----" sudo python3 "${SRC_DIR}/tools/osx-fix-libs.py" "${PKG_DIR}/Contents/MacOS/aegisub" || exit $? +echo +echo "---- Resigning ----" +# After bundling and rewriting dylib paths we need to resign everything. +if codesign -d "${PKG_DIR}/Contents/MacOS/aegisub"; then + for fname in "${PKG_DIR}/Contents/MacOS/"*; do + codesign -s ${AEGISUB_BUNDLE_SIGNATURE:--} -vf "${fname}" + done +fi + echo echo "Done creating \"${PKG_DIR}\""