From b8ce258d4dc9b2778b2bc5461bb4fa8e43c0e2cb Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 28 Apr 2023 09:02:57 +0200 Subject: [PATCH] sdl_mixer: try to open from common path Copy sounfont to known path for macOS and Windows CI builds (in Linux, this is already handled with a environment var SDL_SOUNDFONTS). And also use that location if there is any soundfont. --- .github/scripts/Linux/prepare.sh | 5 +++-- .github/scripts/Windows/prepare_msys.sh | 8 ++++++++ .github/scripts/defs.sh | 1 + .github/scripts/macOS/prepare.sh | 8 ++++++++ .github/workflows/ccpp.yml | 2 +- data/{ => Windows}/update.ps1 | 0 src/audio/capture/sdl_mixer.c | 19 +++++++++++++++++++ 7 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .github/scripts/defs.sh rename data/{ => Windows}/update.ps1 (100%) diff --git a/.github/scripts/Linux/prepare.sh b/.github/scripts/Linux/prepare.sh index ec6bd691a..3aee0df90 100755 --- a/.github/scripts/Linux/prepare.sh +++ b/.github/scripts/Linux/prepare.sh @@ -51,8 +51,9 @@ sudo apt install libva-dev libdrm-dev libx11-dev libx11-xcb-dev libxcb-present-d sudo apt install qtbase5-dev -sf=TimGM6mb_but_fixed__piano_.sf2 # https://musical-artifacts.com/artifacts/2642 -curl http://frakira.fi.muni.cz/~xpulec/$sf -o "$HOME/$sf" +. "$GITHUB_WORKSPACE/.github/scripts/defs.sh" +sf=$(basename "$DEFAULT_SF_URL") +curl -L "$DEFAULT_SF_URL" -o "$HOME/$sf" printf '%b' "SDL_SOUNDFONTS=$HOME/$sf\n" >> "$GITHUB_ENV" # Install cross-platform deps diff --git a/.github/scripts/Windows/prepare_msys.sh b/.github/scripts/Windows/prepare_msys.sh index eaa060685..a698fcff1 100644 --- a/.github/scripts/Windows/prepare_msys.sh +++ b/.github/scripts/Windows/prepare_msys.sh @@ -100,6 +100,13 @@ build_cineform() { ) } +install_soundfont() { + . "$GITHUB_WORKSPACE/.github/scripts/defs.sh" + sf_dir="$GITHUB_WORKSPACE/data/Windows/share/soundfonts" + mkdir -p "$sf_dir" + curl -L "$DEFAULT_SF_URL" -o "$sf_dir/default.sf2" +} + # Install cross-platform deps "$GITHUB_WORKSPACE/.github/scripts/install-common-deps.sh" @@ -111,4 +118,5 @@ build_cineform() { build_cineform install_aja +install_soundfont diff --git a/.github/scripts/defs.sh b/.github/scripts/defs.sh new file mode 100644 index 000000000..2d8eea1d7 --- /dev/null +++ b/.github/scripts/defs.sh @@ -0,0 +1 @@ +DEFAULT_SF_URL=http://frakira.fi.muni.cz/~xpulec/TimGM6mb_but_fixed__piano_.sf2 # https://musical-artifacts.com/artifacts/2642 diff --git a/.github/scripts/macOS/prepare.sh b/.github/scripts/macOS/prepare.sh index e6aa9c1a3..87b503af7 100755 --- a/.github/scripts/macOS/prepare.sh +++ b/.github/scripts/macOS/prepare.sh @@ -103,6 +103,13 @@ install_live555() { cd .. } +install_soundfont() { + . "$GITHUB_WORKSPACE/.github/scripts/defs.sh" + sf_dir="$GITHUB_WORKSPACE/data/MacOS-bundle-template/Contents/share/soundfonts" + mkdir -p "$sf_dir" + curl -L "$DEFAULT_SF_URL" -o "$sf_dir/default.sf2" +} + install_syphon() { wget --no-verbose https://github.com/Syphon/Syphon-Framework/releases/download/5/Syphon.SDK.5.zip unzip Syphon.SDK.5.zip @@ -117,6 +124,7 @@ install_deltacast install_glfw install_live555 install_ndi +install_soundfont install_syphon install_ximea diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index b539333d4..86ddc869f 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -311,7 +311,7 @@ jobs: make install for exe in "$DESTDIR"/*exe; do data/scripts/get_dll_depends.sh "$exe" | while read -r n; do cp "$n" "$DESTDIR"; done; done if command -v windeployqt-qt6 >/dev/null; then windeployqt-qt6 "$DESTDIR/uv-qt.exe"; else windeployqt "$DESTDIR/uv-qt.exe"; fi - cp data/update.ps1 "$DESTDIR" + cp -r data/Windows/* "$DESTDIR" - name: make dist-check run: PATH= /usr/bin/make distcheck TARGET=build/UltraGrid-$VERSION-win64/uv.exe REFLECTOR_TARGET=build/UltraGrid-$VERSION-win64/hd-rum-transcode.exe GUI_EXE=build/UltraGrid-$VERSION-win64/uv-qt.exe - name: Upload Release Asset diff --git a/data/update.ps1 b/data/Windows/update.ps1 similarity index 100% rename from data/update.ps1 rename to data/Windows/update.ps1 diff --git a/src/audio/capture/sdl_mixer.c b/src/audio/capture/sdl_mixer.c index 2248c1aa4..bd97286e2 100644 --- a/src/audio/capture/sdl_mixer.c +++ b/src/audio/capture/sdl_mixer.c @@ -143,6 +143,24 @@ static const char *load_song1() { return filename; } +static void try_open_soundfont() { + if (getenv("SDL_SOUNDFONT") != NULL) { + return; + } + const char *root = get_install_root(); + const char *suffix = "/share/soundfonts/default.sf2"; + const size_t len = strlen(root) + strlen(suffix) + 1; + char path[len]; + strncpy(path, root, len - 1); + strncat(path, suffix, len - strlen(path) - 1); + FILE *f = fopen(path, "r"); + if (!f) { + return; + } + fclose(f); + Mix_SetSoundFonts(path); +} + static void * audio_cap_sdl_mixer_init(struct module *parent, const char *cfg) { UNUSED(parent); @@ -182,6 +200,7 @@ static void * audio_cap_sdl_mixer_init(struct module *parent, const char *cfg) goto error; } } + try_open_soundfont(); Mix_Music *music = Mix_LoadMUS(filename); if (filename != s->req_filename) { unlink(filename);