Skip to content

Commit

Permalink
AUDIO: Fix Fluidsynth soundfont path check on iOS
Browse files Browse the repository at this point in the history
On iOS a sandboxed filesystem is used where the root is in the
Application folder instead of being the filesystem root. As a
result path used in ScummVM (for example for FSNode) are different
from filesystem paths. For fluidsynth the internal soundfont path
is transformed to a filesystem path to pass to the fluidsynth
library. On iOS trying to create a FSNode with that full path does
not work and that caused the soundfont existence check to fail.
  • Loading branch information
criezy committed Dec 26, 2024
1 parent e3ddf67 commit 9fcea62
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions audio/softsynth/fluidsynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class MidiDriver_FluidSynth : public MidiDriver_Emulated {
public:
MidiDriver_FluidSynth(Audio::Mixer *mixer);

static Common::Path getSoundFontPath();
static Common::Path getSoundFontPath(bool *exists = nullptr);

int open() override;
void close() override;
Expand Down Expand Up @@ -280,13 +280,18 @@ static long SoundFontMemLoader_tell(void *handle) {

#endif // USE_FLUIDLITE

Common::Path MidiDriver_FluidSynth::getSoundFontPath() {
Common::Path MidiDriver_FluidSynth::getSoundFontPath(bool *exists) {
Common::Path path = ConfMan.getPath("soundfont");
if (path.empty())
if (path.empty()) {
if (exists)
*exists = false;
return path;
}

Common::FSNode fileNode(path);
if (fileNode.exists()) {
if (exists)
*exists = true;
// Return the full system path to the soundfont
return Common::Path(g_system->getFilesystemFactory()->getSystemFullPath(path.toString(Common::Path::kNativeSeparator)), Common::Path::kNativeSeparator);
}
Expand All @@ -296,8 +301,11 @@ Common::Path MidiDriver_FluidSynth::getSoundFontPath() {
Common::FSNode dirNode(ConfMan.getPath("soundfontpath"));
if (dirNode.exists() && dirNode.isDirectory()) {
fileNode = dirNode.getChild(path.baseName());
if (fileNode.exists())
if (fileNode.exists()) {
if (exists)
*exists = true;
return fileNode.getPath();
}
}
}

Expand All @@ -309,10 +317,15 @@ Common::Path MidiDriver_FluidSynth::getSoundFontPath() {
if (!dir)
continue;
fileNode = dir->getFSNode().getChild(file.arcMember->getPathInArchive().toString(Common::Path::kNativeSeparator));
if (fileNode.exists())
if (fileNode.exists()) {
if (exists)
*exists = true;
return fileNode.getPath();
}
}

if (exists)
*exists = false;
return path;
}

Expand Down Expand Up @@ -608,11 +621,9 @@ bool FluidSynthMusicPlugin::checkDevice(MidiDriver::DeviceHandle, int flags, boo
return true;
#endif

Common::Path sfPath = MidiDriver_FluidSynth::getSoundFontPath();
if (sfPath.empty())
return false;

return Common::FSNode(sfPath).exists();
bool exists = false;
Common::Path sfPath = MidiDriver_FluidSynth::getSoundFontPath(&exists);
return !sfPath.empty() && exists;
}

Common::Error FluidSynthMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
Expand Down

0 comments on commit 9fcea62

Please sign in to comment.