Commit 3bf1e220 authored by patrick pereira's avatar patrick pereira 🏃
Browse files

fluidsynthsoundcontroller: Try XDG_DATA_DIRS in macos


Signed-off-by: patrick pereira's avatarPatrick José Pereira <patrickelectric@gmail.com>
parent fdb95e3d
......@@ -7,6 +7,7 @@ add_library(minuetfluidsynthsoundcontroller MODULE ${fluidsynthsoundcontroller_P
target_link_libraries(minuetfluidsynthsoundcontroller
Qt5::Core
Minuet::Interfaces
Minuet::Utils
FluidSynth::FluidSynth
)
......
......@@ -28,6 +28,8 @@
#include <QJsonObject>
#include <QStandardPaths>
#include <utils/xdgdatadirs.h>
unsigned int FluidSynthSoundController::m_initialTime = 0;
FluidSynthSoundController::FluidSynthSoundController(QObject *parent)
......@@ -50,11 +52,24 @@ FluidSynthSoundController::FluidSynthSoundController(QObject *parent)
#ifdef Q_OS_WIN
const QString sf_path = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("minuet/soundfonts/GeneralUser-v1.47.sf2"));
#else
const QString sf_path = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("soundfonts/GeneralUser-v1.47.sf2"));
QString sf_path = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("soundfonts/GeneralUser-v1.47.sf2"));
#ifdef Q_OS_MACOS
if (sf_path.isEmpty()) {
const QStringList xdgDataDirs = Utils::getXdgDataDirs();
for (const auto &dirPath : xdgDataDirs) {
const QFile testFile(QDir(dirPath).absoluteFilePath(QStringLiteral("minuet/soundfonts/GeneralUser-v1.47.sf2")));
if (testFile.exists()) {
sf_path = testFile.fileName();
break;
}
}
}
#endif
#endif
int fluid_res = fluid_synth_sfload(m_synth, sf_path.toLatin1(), 1);
if (fluid_res == FLUID_FAILED)
qCritical() << "Error when loading soundfont!";
qCritical() << "Error when loading soundfont in:" << sf_path;
m_unregisteringEvent = new_fluid_event();
fluid_event_set_source(m_unregisteringEvent, -1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment