Skip to content

Commit

Permalink
Merge branches 'bugfixes', 'video_provider_rework' and 'avisynth' int…
Browse files Browse the repository at this point in the history
…o feature
  • Loading branch information
arch1t3cht committed Oct 17, 2023
4 parents b3eb182 + fabc6e4 + dd3016a + 858f4ac commit 4ebdc2b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,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 }}
Expand Down
14 changes: 11 additions & 3 deletions src/audio_provider_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ std::unique_ptr<agi::AudioProvider> 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);
Expand All @@ -84,9 +89,12 @@ std::unique_ptr<agi::AudioProvider> 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;
Expand Down
10 changes: 6 additions & 4 deletions src/avisynth_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -66,8 +67,8 @@ const AVS_Linkage *AVS_linkage = nullptr;

typedef IScriptEnvironment* __stdcall FUNC(int);

AviSynthWrapper::AviSynthWrapper() {
if (!avs_refcount){
AviSynthWrapper::AviSynthWrapper() try {
if (!avs_refcount++) {
#ifdef _WIN32
#define CONCATENATE(x, y) x ## y
#define _Lstr(x) CONCATENATE(L, x)
Expand All @@ -94,15 +95,16 @@ 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
const int memoryMax = OPT_GET("Provider/Avisynth/Memory Max")->GetInt();
if (memoryMax)
env->SetMemoryMax(memoryMax);
}
} catch (AvisynthError const&) {
avs_refcount--;
throw;
}

AviSynthWrapper::~AviSynthWrapper() {
Expand Down
4 changes: 2 additions & 2 deletions src/libresrc/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"Next Line on Commit" : true,
"Player" : "",
"Plays When Stepping Video" : false,
"Provider" : "ffmpegsource",
"Provider" : "FFmpegSource",
"Renderer" : {
"Spectrum" : {
"Cutoff" : 0,
Expand Down Expand Up @@ -661,7 +661,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,
Expand Down
4 changes: 2 additions & 2 deletions src/libresrc/osx/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"Next Line on Commit" : true,
"Player" : "",
"Plays When Stepping Video" : false,
"Provider" : "ffmpegsource",
"Provider" : "FFmpegSource",
"Renderer" : {
"Spectrum" : {
"Cutoff" : 0,
Expand Down Expand Up @@ -661,7 +661,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,
Expand Down
14 changes: 11 additions & 3 deletions src/video_provider_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ std::vector<std::string> VideoProviderFactory::GetClasses() {

std::unique_ptr<VideoProvider> 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);
Expand All @@ -89,9 +94,12 @@ std::unique_ptr<VideoProvider> 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;
Expand Down
9 changes: 9 additions & 0 deletions tools/osx-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}\""

0 comments on commit 4ebdc2b

Please sign in to comment.