Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SPA support (enabling zyn-fusion) #4662

Draft
wants to merge 143 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
5a26e8c
Implement spa plugin
Dec 18, 2017
94908ce
Allow converting old zyn to new one
JohannesLorenz Sep 15, 2018
e81f9b0
Fix instrument converting
PhysSong Oct 19, 2018
1a5c0e0
Refactor getting Automatable Models to Engine
JohannesLorenz Oct 22, 2018
7e7044d
Allow dropping automation in more ways
JohannesLorenz Oct 22, 2018
da9fcfc
Allow drag-dropping onto Controller Rack
JohannesLorenz Nov 1, 2018
bdde4e3
Automized formatting changes only
JohannesLorenz Nov 1, 2018
1e091ea
Manual formatting changes only
JohannesLorenz Nov 2, 2018
42c0041
Fix instrument converting (thanks to @PhysSong)
JohannesLorenz Nov 3, 2018
2a4ad86
Make all spa includes optional
JohannesLorenz Nov 5, 2018
61d0e19
Move SpaInstrument.* to src/core
JohannesLorenz Nov 6, 2018
610d92e
Abstrahize SpaInstrument into "SpaPluginBase" and "SpaControlBase"
JohannesLorenz Nov 28, 2018
0c03c5c
Add and implement SPA effects
JohannesLorenz Nov 28, 2018
77556fd
Read step from SPA float controls
JohannesLorenz Nov 29, 2018
87918f6
Merge branch 'master' into osc-plugin
JohannesLorenz Dec 1, 2018
be995fb
Turn SPA core plugins into sub plugins
JohannesLorenz Dec 30, 2018
625f022
Merge branch 'master' into osc-plugin
JohannesLorenz Dec 30, 2018
cb97719
Merge branch 'instr-sub-plugins' into spa-work
JohannesLorenz Dec 31, 2018
b110f5e
Merge branch 'master' into spa-work
JohannesLorenz Dec 31, 2018
1be5cb3
Remove debug output
JohannesLorenz Dec 31, 2018
cd7d099
Merge branch 'spa-work' into osc-plugin
JohannesLorenz Dec 31, 2018
d4765d2
Minor cleanups
JohannesLorenz Jan 1, 2019
7e96117
Elliminate useless SpaPluginBase class
JohannesLorenz Jan 1, 2019
07666ac
Fix compile fail if SPA is disabled
JohannesLorenz Jan 1, 2019
9e21421
Cleanups, non functional
JohannesLorenz Jan 1, 2019
74e0afb
Merge branch 'master' into osc-plugin
JohannesLorenz Jan 1, 2019
3a4edc2
Merge branch 'master' into osc-plugin
JohannesLorenz Jan 2, 2019
4949059
Use QString for SubPluginFeatures' virtuals
JohannesLorenz Jan 18, 2019
0725d3a
Refactor spa views into SpaViewBase
JohannesLorenz Jan 19, 2019
d4c3d9c
Set models when model changed
JohannesLorenz Jan 19, 2019
e43d68e
Add Control classes
JohannesLorenz Mar 16, 2019
f586bac
Add linked model groups
JohannesLorenz Mar 16, 2019
2221d21
Fix wrong display names
JohannesLorenz Mar 21, 2019
f6726c4
Merge branch 'master' into instr-sub-plugins
JohannesLorenz Mar 22, 2019
8f71569
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Mar 22, 2019
827e73f
Bugfix for SubPluginFeature's return types
JohannesLorenz Mar 22, 2019
1220277
Simplify LinkedModelGroups usage
JohannesLorenz Mar 23, 2019
e6e27d2
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Mar 24, 2019
e9bf431
Fix memory cleanup
JohannesLorenz Apr 22, 2019
33df80b
Merge branch 'model-visitor' into linked-model-groups
JohannesLorenz Apr 27, 2019
b0758c1
Simplify LinkedModelGroups usage
JohannesLorenz Mar 23, 2019
dae999d
Code conventions + Merge fixes
JohannesLorenz Apr 27, 2019
27f62e6
Do not store nProc in LinkedModelGroup
JohannesLorenz Apr 27, 2019
b23fd06
Improve LinkedModelGroups member funcs
JohannesLorenz Apr 30, 2019
7d91d9b
LinkedModelGroups: Fix possible OOB read
JohannesLorenz May 15, 2019
82cba06
LinkedModelGroups: Hide if no controls
JohannesLorenz May 15, 2019
6c474fe
LinkedModelGroupViews: Fix comment
JohannesLorenz May 15, 2019
08c49a3
LinkedModelGroups: Move model into struct
JohannesLorenz May 15, 2019
78dee7d
LinkedModelGroups: Implement load/save
JohannesLorenz May 16, 2019
993fa46
Coding conventions
JohannesLorenz May 16, 2019
3e0525d
LinkedModelGroups: Fix nullptr indirection
JohannesLorenz May 25, 2019
029c2e4
Remove unused variable
JohannesLorenz May 26, 2019
2edb35e
LinkedModelGroups: Don't save linked models twice
JohannesLorenz May 27, 2019
24ca9f1
Code review
JohannesLorenz May 30, 2019
0c1758e
Review rework, thanks to @DomClark
JohannesLorenz Jun 13, 2019
2ad9db6
Update connect instructions
JohannesLorenz Jun 18, 2019
538b5a5
Fix assertion for #LinkedModelGroups == 1
JohannesLorenz Jul 26, 2019
dcd7482
LinkedModelGroups: Priv members -> nested struct
JohannesLorenz Jul 22, 2019
2ce0b7f
Implement clearing models
JohannesLorenz Jul 22, 2019
b3d1fb1
Hide model vector in derived classes
JohannesLorenz Jul 23, 2019
0960b06
Fix unique_ptr compiler issues
JohannesLorenz Jul 24, 2019
8371dea
Use LinkedModelGroups
JohannesLorenz Apr 26, 2019
2dda00c
Merge linked-model-groups into osc-plugin-laptop
JohannesLorenz Jul 28, 2019
f6125f0
Remove Mutex and includes
JohannesLorenz Jul 6, 2019
7881211
Load/save states work, reload missing yet (samplerate)
JohannesLorenz Jul 6, 2019
17bae5f
Enable reloading partially (models are not saved yet)
JohannesLorenz Jul 22, 2019
d71554d
Merge branch 'linked-model-groups' into osc-plugin-laptop
JohannesLorenz Jul 28, 2019
dd08aa4
Solely split SpaControlBase.h to itself + SpaProc.h
JohannesLorenz Jul 17, 2019
2ba3fec
Controls: allow to return model view
JohannesLorenz Dec 4, 2019
99cb22a
Implement LinkedModelGroupLayout
JohannesLorenz Dec 4, 2019
87ec01d
Merge branch linked-model-groups into osc-plugin
JohannesLorenz Dec 4, 2019
5955e37
LinkedModelGroups: Always keep groups linked
JohannesLorenz Dec 5, 2019
9654921
Merge branch linked-model-groups into osc-plugin
JohannesLorenz Dec 5, 2019
d0b7dc1
Remove linking LEDs
JohannesLorenz Dec 8, 2019
3c5a5c7
Merge branch 'linked-model-groups' into HEAD
JohannesLorenz Dec 8, 2019
94ea93e
Show only one processor view
JohannesLorenz Dec 8, 2019
ba6fc9a
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 8, 2019
74ad422
Minor cleanups, doc cleanups
JohannesLorenz Dec 10, 2019
2cef3a1
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 10, 2019
68777ef
Whitespace or non-functional fixes
JohannesLorenz Dec 10, 2019
9e971f6
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 10, 2019
be056e7
Fix broken doc/wiki submodule
JohannesLorenz Dec 10, 2019
36f1e6a
Do no set minimumSize for the view
JohannesLorenz Dec 11, 2019
a34929a
Disable buggy VST plugins during PR
JohannesLorenz Dec 18, 2019
8e5a665
Forgot to remove code after merge
JohannesLorenz Dec 18, 2019
98f9a96
Fix OSC ringbuffer race condition
JohannesLorenz Dec 18, 2019
1404365
Fix load/save order: states before ports
JohannesLorenz Dec 19, 2019
d32927c
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 21, 2019
23b6b1d
Rename LinkedModelGroupLayout to ControlLayout
JohannesLorenz Dec 21, 2019
5ce97a2
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 29, 2019
464137a
RemotePlugin: Take fix from stable-1.2
JohannesLorenz Dec 29, 2019
61fed4a
Fix segfaults in zynaddsubfx
JohannesLorenz Dec 29, 2019
14c72b0
Implement LinkedModelGroup::containsModel
JohannesLorenz Dec 30, 2019
7d4bb11
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Dec 30, 2019
ac6f014
Fix loading models not creating them
JohannesLorenz Dec 30, 2019
f8fbbac
Temporary fix to wait for zyn to load
JohannesLorenz Jan 2, 2020
6641380
Style fixes, thanks to @Veratil
JohannesLorenz Jan 2, 2020
cf23825
LinkedModelGroup::ModelInfo: Delete default CTOR
JohannesLorenz Jan 2, 2020
0ff1877
Try to fix CI error
JohannesLorenz Jan 2, 2020
0a97c6b
Fix broken wiki submodule
JohannesLorenz Jan 2, 2020
cc37562
Merge branch misc-lv2-preparation into osc-plugin
JohannesLorenz Jan 6, 2020
d38fec3
Merge branch 'instr-sub-plugins' into osc-plugin
JohannesLorenz Jan 6, 2020
87c4a03
Delete ModelInfo default CTOR
JohannesLorenz Jan 27, 2020
c6a28ed
LinkedModelGroup: Implement eraseModel() and getModel()
JohannesLorenz Jan 27, 2020
696ab26
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Jan 27, 2020
5d77256
SpaProc: Remove m_connectedModels
JohannesLorenz Jan 27, 2020
eeb1ef2
Add helpful comments
JohannesLorenz Feb 9, 2020
c9f03ba
Move removeControl from subclasses into this class
JohannesLorenz Feb 9, 2020
5e40771
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Feb 9, 2020
9f59841
Fix loading not adding models into GUI
JohannesLorenz Feb 9, 2020
210d704
Detect search bar by name, not by position
JohannesLorenz Feb 12, 2020
0c79331
Merge branch 'linked-model-groups' into osc-plugin
JohannesLorenz Feb 12, 2020
2c6d39c
Merge branch 'master' into osc-plugin-laptop
JohannesLorenz Mar 1, 2020
3e42df1
Merge branch 'master' into osc-plugin
JohannesLorenz Sep 12, 2020
af0a98a
Avoid use of osc DnD strings in the core UI
JohannesLorenz Sep 27, 2020
e62d478
Merge branch 'master' into osc-plugin
JohannesLorenz Nov 29, 2020
da61238
Merge branch 'master' into osc-plugin-merge
JohannesLorenz Feb 28, 2021
3c94a6e
Use the new SPA v0.0.3 ringbuffers
JohannesLorenz Mar 6, 2021
5c89ad0
Merge branch 'master' into osc-plugin-merge
JohannesLorenz Mar 6, 2021
8bcf420
Fix memory errors dropping xmz
JohannesLorenz Mar 7, 2021
93f42f8
Fix bug from prev commit
JohannesLorenz Mar 7, 2021
05b6644
Merge branch 'master' into osc-plugin
JohannesLorenz Mar 13, 2021
ea0066c
Merge branch 'master' into osc-plugin
JohannesLorenz Mar 21, 2021
2228da5
Merge branch 'master' into osc-plugin
JohannesLorenz Mar 21, 2021
7f1dd04
Update zyn submodule
JohannesLorenz Sep 28, 2021
f322ec4
Merge branch 'master' into osc-plugin
JohannesLorenz Sep 28, 2021
885c16f
Merge branch 'master' into osc-plugin
JohannesLorenz Oct 30, 2021
8aeb766
Merge branch 'master' into osc-plugin
JohannesLorenz Nov 5, 2021
dfe4032
Fixup osc-plugin after merge of master
JohannesLorenz Jan 30, 2022
b8af8b0
Add .clang-format and .clang-tidy
JohannesLorenz Nov 1, 2018
d358a70
Merge branch 'master' into osc-plugin
JohannesLorenz Apr 16, 2022
204a160
Merge branch 'master' into osc-plugin
JohannesLorenz Apr 16, 2022
a3925a6
Fixup merge issues
JohannesLorenz Apr 16, 2022
21045b8
Merge branch 'master' into osc-plugin
JohannesLorenz Apr 30, 2022
4b331e9
Fix ringbuffer concurrent read
JohannesLorenz May 1, 2022
bec4deb
Fix segfault at closing projects
JohannesLorenz May 1, 2022
1a9865e
Revert "Fix segfault at closing projects"
JohannesLorenz May 13, 2022
8a7908e
Remove .clang-* files (they should not be in this branch)
JohannesLorenz Jun 9, 2022
4f28410
Merge branch 'master' into osc-plugin
JohannesLorenz Jun 9, 2022
76a43d4
Merge commit '7227c89847a5472f322ae6a0702027dda18b0bc7~1' into osc-pl…
JohannesLorenz Jun 19, 2022
3c457af
Merge branch 'master' (early part) into osc-plugin
JohannesLorenz Jun 23, 2022
93d0d8f
Merge branch 'master' into osc-plugin
JohannesLorenz Jun 23, 2022
81d9458
Fix merge conflicts (namespace lmms)
JohannesLorenz Jul 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class LMMS_EXPORT LmmsCore : public QObject
return s_ladspaManager;
}

static class QMap<int, class SpaInstrument*>& getSpaInstruments()
{
return s_spaInstruments;
}

static DummyTrackContainer * dummyTrackContainer()
{
return s_dummyTC;
Expand Down Expand Up @@ -137,6 +142,7 @@ class LMMS_EXPORT LmmsCore : public QObject
static DummyTrackContainer * s_dummyTC;

static Ladspa2LMMS * s_ladspaManager;
static QMap<int, class SpaInstrument*> s_spaInstruments;

// even though most methods are static, an instance is needed for Qt slots/signals
static LmmsCore * s_instanceOfMe;
Expand Down
4 changes: 4 additions & 0 deletions include/PluginFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
#define PLUGINFACTORY_H

#include <memory>
#include <string>

#include <QtCore/QFileInfo>
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QString>
#include <QtCore/QVector>

#include "lmms_export.h"
#include "Plugin.h"
Expand Down Expand Up @@ -85,6 +88,7 @@ public slots:
DescriptorMap m_descriptors;
PluginInfoList m_pluginInfos;
QMap<QString, PluginInfo> m_pluginByExt;
QVector<std::string> m_garbage; //!< cleaned up at destruction
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved

QHash<QString, QString> m_errors;

Expand Down
80 changes: 80 additions & 0 deletions include/SpaOscModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* SpaOscModel.h - AutomatableModel which forwards OSC events
*
* Copyright (c) 2018-2018 Johannes Lorenz <j.git$$$lorenz-ho.me, $$$=@>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/

#ifndef SPAOSCMODEL_H
#define SPAOSCMODEL_H

#include "AutomatableModel.h"

template<class Base>
class SpaOscModel : public Base
{
protected:
class SpaInstrument* inst_ref;
QByteArray dest;

using Base::Base;
void init(class SpaInstrument* _inst_ref, const QString _dest) {
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved
inst_ref = _inst_ref;
dest = _dest.toUtf8();
}
};

class BoolOscModel : public SpaOscModel<BoolModel>
{
Q_OBJECT
private slots:
void sendOsc();
public:
BoolOscModel(class SpaInstrument* inst_ref, const QString dest,
bool val);
};

class IntOscModel : public SpaOscModel<IntModel>
{
Q_OBJECT
private slots:
void sendOsc();
public:
IntOscModel(class SpaInstrument* inst_ref, const QString dest,
int min, int max, int val);
};

class FloatOscModel : public SpaOscModel<FloatModel>
{
Q_OBJECT
private slots:
void sendOsc();
public:
FloatOscModel(class SpaInstrument* inst_ref, const QString dest,
float min, float max, float val);
};

struct SpaOscModelFactory
{
AutomatableModel* res;
SpaOscModelFactory(class SpaInstrument* inst_ref, const QString &dest);
};

#endif // SPAOSCMODEL_H
5 changes: 5 additions & 0 deletions include/StringPairDrag.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class LMMS_EXPORT StringPairDrag : public QDrag
return( "application/x-lmms-stringpair" );
}

static const char * mimeTypeOsc()
{
return( "application/x-osc-stringpair" );
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved
}

} ;


Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ INCLUDE_DIRECTORIES(
${SNDFILE_INCLUDE_DIRS}
${SNDIO_INCLUDE_DIRS}
${FFTW3F_INCLUDE_DIRS}
${LIBSPA_INCLUDE_DIRS}
)

IF(NOT ("${SDL2_INCLUDE_DIR}" STREQUAL ""))
Expand Down Expand Up @@ -96,6 +97,9 @@ IF(LMMS_BUILD_LINUX)
ENDIF()
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Note: LINK_DIRECTORIES only affects targets after its call
LINK_DIRECTORIES(${LIBSPA_LIBRARY_DIRS})

ADD_LIBRARY(lmmsobjs OBJECT
${LMMS_SRCS}
${LMMS_INCLUDES}
Expand Down Expand Up @@ -163,6 +167,7 @@ SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS}
${LAME_LIBRARIES}
${SAMPLERATE_LIBRARIES}
${SNDFILE_LIBRARIES}
${LIBSPA_LIBRARIES}
${EXTRA_LIBRARIES}
rpmalloc
)
Expand Down
6 changes: 6 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(spa)

set(LMMS_SRCS
${LMMS_SRCS}
core/AutomatableModel.cpp
Expand Down Expand Up @@ -61,6 +63,7 @@ set(LMMS_SRCS
core/SampleRecordHandle.cpp
core/SerializingObject.cpp
core/Song.cpp
core/SpaOscModel.cpp
core/TempoSyncKnobModel.cpp
core/ToolPlugin.cpp
core/Track.cpp
Expand Down Expand Up @@ -97,5 +100,8 @@ set(LMMS_SRCS
core/midi/MidiTime.cpp
core/midi/MidiWinMM.cpp

${SPA_SRCS}

PARENT_SCOPE
)

3 changes: 2 additions & 1 deletion src/core/DataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ bool DataFile::validate( QString extension )
case Type::UnknownType:
if (! ( extension == "mmp" || extension == "mpt" || extension == "mmpz" ||
extension == "xpf" || extension == "xml" ||
( extension == "xiz" && ! pluginFactory->pluginSupportingExtension(extension).isNull()) ||
( (extension == "xiz" || extension == "xmz") &&
! pluginFactory->pluginSupportingExtension(extension).isNull()) ||
extension == "sf2" || extension == "sf3" || extension == "pat" || extension == "mid" ||
extension == "dll"
) )
Expand Down
1 change: 1 addition & 0 deletions src/core/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ BBTrackContainer * LmmsCore::s_bbTrackContainer = NULL;
Song * LmmsCore::s_song = NULL;
ProjectJournal * LmmsCore::s_projectJournal = NULL;
Ladspa2LMMS * LmmsCore::s_ladspaManager = NULL;
QMap<int, class SpaInstrument*> LmmsCore::s_spaInstruments;
DummyTrackContainer * LmmsCore::s_dummyTC = NULL;


Expand Down
28 changes: 25 additions & 3 deletions src/core/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <QtCore/QDir>
#include <QtCore/QLibrary>
#include <QMessageBox>
#include <spa/spa.h>

#include "../core/spa/SpaInstrument.h"

#include "Plugin.h"
#include "embed.h"
Expand Down Expand Up @@ -107,8 +110,27 @@ Plugin * Plugin::instantiate( const QString& pluginName, Model * parent,
return new DummyPlugin();
}

InstantiationHook instantiationHook = ( InstantiationHook ) pi.library->resolve( "lmms_plugin_main" );
if( instantiationHook == NULL )
Plugin* inst;
spa::descriptor_loader_t spa_loader;
InstantiationHook instantiationHook;
if( (instantiationHook = ( InstantiationHook ) pi.library->resolve( "lmms_plugin_main" )) )
{
inst = instantiationHook( parent, data );
}
else if( (spa_loader = (spa::descriptor_loader_t) pi.library->resolve( spa::descriptor_name )) )
{
// instantiate a SPA Instrument
// it will load and contain the SPA plugin
// and transfer LMMS events to SPA function calls
SpaInstrument* spa_inst = new SpaInstrument(
static_cast<InstrumentTrack *>( data ),
pi.file.absoluteFilePath().toUtf8().data(),
pi.descriptor);
unsigned port = spa_inst->plugin->net_port();
Engine::getSpaInstruments().insert(port, spa_inst);
inst = spa_inst;
}
else
{
if( gui )
{
Expand All @@ -120,7 +142,7 @@ Plugin * Plugin::instantiate( const QString& pluginName, Model * parent,
return new DummyPlugin();
}

Plugin * inst = instantiationHook( parent, data );

return inst;
}

Expand Down
86 changes: 63 additions & 23 deletions src/core/PluginFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QLibrary>
#include <spa/spa.h>

#include "ConfigManager.h"
#include "Plugin.h"
#include "embed.h"

#ifdef LMMS_BUILD_WIN32
QStringList nameFilters("*.dll");
Expand Down Expand Up @@ -150,42 +153,79 @@ void PluginFactory::discoverPlugins()
for (const QFileInfo& file : files)
{
auto library = std::make_shared<QLibrary>(file.absoluteFilePath());
spa::descriptor_loader_t spaDescriptorLoader;

if (! library->load()) {
m_errors[file.baseName()] = library->errorString();
qWarning("%s", library->errorString().toLocal8Bit().data());
continue;
}
if (library->resolve("lmms_plugin_main") == nullptr) {
continue;
}

QString descriptorName = file.baseName() + "_plugin_descriptor";
if( descriptorName.left(3) == "lib" )
Plugin::Descriptor* pluginDescriptor = nullptr;
if (library->resolve("lmms_plugin_main"))
{
descriptorName = descriptorName.mid(3);
// LMMS plugin

QString descriptorName = file.baseName() + "_plugin_descriptor";
if( descriptorName.left(3) == "lib" )
{
descriptorName = descriptorName.mid(3);
}

pluginDescriptor = reinterpret_cast<Plugin::Descriptor*>(library->resolve(descriptorName.toUtf8().constData()));
if(pluginDescriptor == nullptr)
{
qWarning() << qApp->translate("PluginFactory", "LMMS plugin %1 does not have a plugin descriptor named %2!").
arg(file.absoluteFilePath()).arg(descriptorName);
continue;
}
}

Plugin::Descriptor* pluginDescriptor = reinterpret_cast<Plugin::Descriptor*>(library->resolve(descriptorName.toUtf8().constData()));
if(pluginDescriptor == nullptr)
{
qWarning() << qApp->translate("PluginFactory", "LMMS plugin %1 does not have a plugin descriptor named %2!").
arg(file.absoluteFilePath()).arg(descriptorName);
continue;
else if ((spaDescriptorLoader = (spa::descriptor_loader_t) library->resolve(spa::descriptor_name))) {
spa::descriptor* descriptor = (*spaDescriptorLoader)(0 /* = plugin number, TODO */);
if(descriptor)
{
std::string unique_name =
spa::unique_name(*descriptor);
m_garbage.push_back(unique_name);

const char** xpm = descriptor->xpm_load();
assert(xpm);
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved
QString xpmKey= "spa-plugin:" +
QString::fromStdString(unique_name);

// spa (simple plugin API) plugin
pluginDescriptor = new Plugin::Descriptor {
m_garbage.back().c_str(),
descriptor->name(),
descriptor->description_line(),
descriptor->authors(),
(int)descriptor->version_major() << 24 |
(descriptor->version_minor() & 0xff) << 16 |
(descriptor->version_patch() & 0xffff),
Plugin::Instrument, // TODO... could also be an effect
new PixmapLoader(QString("xpm:"
+ xpmKey), xpm),
descriptor->save_formats()
};
}
}

PluginInfo info;
info.file = file;
info.library = library;
info.descriptor = pluginDescriptor;
pluginInfos << info;

for (const QString& ext : QString(info.descriptor->supportedFileTypes).split(','))
if(pluginDescriptor)
{
m_pluginByExt.insert(ext, info);
PluginInfo info;
info.file = file;
info.library = library;
info.descriptor = pluginDescriptor;
pluginInfos << info;

if(info.descriptor->supportedFileTypes)
for (const QString& ext : QString(info.descriptor->supportedFileTypes).split(','))
{
m_pluginByExt.insert(ext, info);
}

descriptors.insert(info.descriptor->type, info.descriptor);
}

descriptors.insert(info.descriptor->type, info.descriptor);
}

m_pluginInfos = pluginInfos;
Expand Down
Loading