Skip to content

Commit

Permalink
AUDIO: Improve code to map the soundfont path to system path on iOS
Browse files Browse the repository at this point in the history
The code looks a bit less hack-ish and also now supports using path
in the application bundle and not only in the documents folder.
  • Loading branch information
criezy committed Nov 20, 2023
1 parent 5aa7f92 commit 45cf63c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions audio/softsynth/fluidsynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
#include "audio/mpu401.h"
#include "audio/softsynth/emumidi.h"
#include "gui/message.h"
#if defined(IPHONE_IOS7)
#include "backends/platform/ios7/ios7_common.h"
#if defined(POSIX)
#include "backends/fs/chroot/chroot-fs-factory.h"
#endif
#ifdef __ANDROID__
#include "backends/fs/android/android-fs-factory.h"
Expand Down Expand Up @@ -288,17 +288,16 @@ Common::String MidiDriver_FluidSynth::getSoundFontPath() const {
return path;

// First check if this is a full path
#if defined(IPHONE_IOS7)
// HACK: Due to the sandbox on non-jailbroken iOS devices, we need to deal
// with the chroot filesystem. All the path selected by the user are
// relative to the Document directory. So, we need to adjust the path to
// reflect that.
Common::FSNode fileNode(iOS7_getDocumentsDir() + path);
#else
Common::FSNode fileNode(path);
Common::String fullPath = path;
#if defined(POSIX)
// If using a sandbox FS, we need to map the path to the full system path
ChRootFilesystemFactory* sandboxFS = dynamic_cast<ChRootFilesystemFactory*>(g_system->getFilesystemFactory());
if (sandboxFS)
fullPath = sandboxFS->getSystemFullPath(fullPath);
#endif
Common::FSNode fileNode(fullPath);
if (fileNode.exists())
return fileNode.getPath();
return fullPath;

// Then check with soundfontpath
if (ConfMan.hasKey("soundfontpath")) {
Expand Down

0 comments on commit 45cf63c

Please sign in to comment.