Browse Source

Add callbacks for plugin added and removed

tags/1.9.4
falkTX 11 years ago
parent
commit
a5b18fca50
7 changed files with 73 additions and 54 deletions
  1. +32
    -24
      source/backend/carla_backend.hpp
  2. +7
    -7
      source/backend/carla_engine.hpp
  3. +17
    -16
      source/backend/engine/carla_engine.cpp
  4. +3
    -3
      source/backend/engine/carla_engine_internal.hpp
  5. +2
    -2
      source/backend/engine/carla_engine_osc.cpp
  6. +8
    -2
      source/bridges/carla_bridge_plugin.cpp
  7. +4
    -0
      source/utils/carla_backend_utils.hpp

+ 32
- 24
source/backend/carla_backend.hpp View File

@@ -110,7 +110,6 @@ const unsigned int PARAMETER_USES_SCALEPOINTS = 0x40; //!< Parameter uses scalep
const unsigned int PARAMETER_USES_CUSTOM_TEXT = 0x80; //!< Parameter uses custom text for displaying its value.\see CarlaPlugin::getParameterText()
/**@}*/

#if 0
/*!
* @defgroup CustomDataTypes Custom Data types
*
@@ -123,7 +122,6 @@ const char* const CUSTOM_DATA_INVALID = nullptr;
const char* const CUSTOM_DATA_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"; //!< Carla Chunk
const char* const CUSTOM_DATA_STRING = "http://kxstudio.sf.net/ns/carla/string"; //!< Carla String
/**@}*/
#endif

#if 0
/*!
@@ -398,13 +396,23 @@ enum CallbackType {
*/
CALLBACK_DEBUG = 0,

/*!
* A plugin has been added.
*/
CALLBACK_PLUGIN_ADDED = 1,

/*!
* A plugin has been removed.
*/
CALLBACK_PLUGIN_REMOVED = 2,

/*!
* A parameter has been changed.
*
* \param value1 Parameter index
* \param value3 Value
*/
CALLBACK_PARAMETER_VALUE_CHANGED = 1,
CALLBACK_PARAMETER_VALUE_CHANGED = 3,

/*!
* A parameter's MIDI channel has been changed.
@@ -412,7 +420,7 @@ enum CallbackType {
* \param value1 Parameter index
* \param value2 MIDI channel
*/
CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 2,
CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED = 4,

/*!
* A parameter's MIDI CC has been changed.
@@ -420,14 +428,14 @@ enum CallbackType {
* \param value1 Parameter index
* \param value2 MIDI CC
*/
CALLBACK_PARAMETER_MIDI_CC_CHANGED = 3,
CALLBACK_PARAMETER_MIDI_CC_CHANGED = 5,

/*!
* The current program has has been changed.
*
* \param value1 Program index
*/
CALLBACK_PROGRAM_CHANGED = 4,
CALLBACK_PROGRAM_CHANGED = 6,

/*!
* The current MIDI program has been changed.
@@ -435,7 +443,7 @@ enum CallbackType {
* \param value1 MIDI bank
* \param value2 MIDI program
*/
CALLBACK_MIDI_PROGRAM_CHANGED = 5,
CALLBACK_MIDI_PROGRAM_CHANGED = 7,

/*!
* A note has been pressed.
@@ -444,7 +452,7 @@ enum CallbackType {
* \param value2 Note
* \param value3 Velocity
*/
CALLBACK_NOTE_ON = 6,
CALLBACK_NOTE_ON = 8,

/*!
* A note has been released.
@@ -452,7 +460,7 @@ enum CallbackType {
* \param value1 Channel
* \param value2 Note
*/
CALLBACK_NOTE_OFF = 7,
CALLBACK_NOTE_OFF = 9,

/*!
* The plugin's custom GUI state has changed.
@@ -462,62 +470,62 @@ enum CallbackType {
* 1: GUI has been shown\n
* -1: GUI has crashed and should not be shown again
*/
CALLBACK_SHOW_GUI = 8,
CALLBACK_SHOW_GUI = 10,

/*!
* The plugin needs update.
*/
CALLBACK_UPDATE = 9,
CALLBACK_UPDATE = 11,

/*!
* The plugin's data/information has changed.
*/
CALLBACK_RELOAD_INFO = 10,
CALLBACK_RELOAD_INFO = 12,

/*!
* The plugin's parameters have changed.
*/
CALLBACK_RELOAD_PARAMETERS = 11,
CALLBACK_RELOAD_PARAMETERS = 13,

/*!
* The plugin's programs have changed.
*/
CALLBACK_RELOAD_PROGRAMS = 12,
CALLBACK_RELOAD_PROGRAMS = 14,

/*!
* The plugin's state has changed.
*/
CALLBACK_RELOAD_ALL = 13,
CALLBACK_RELOAD_ALL = 15,

/*!
* Non-Session-Manager Announce message.
*/
CALLBACK_NSM_ANNOUNCE = 14,
CALLBACK_NSM_ANNOUNCE = 16,

/*!
* Non-Session-Manager Open message #1.
*/
CALLBACK_NSM_OPEN1 = 15,
CALLBACK_NSM_OPEN1 = 17,

/*!
* Non-Session-Manager Open message #2.
*/
CALLBACK_NSM_OPEN2 = 16,
CALLBACK_NSM_OPEN2 = 18,

/*!
* Non-Session-Manager Save message.
*/
CALLBACK_NSM_SAVE = 17,
CALLBACK_NSM_SAVE = 19,

/*!
* An error occurred, show last error to user.
*/
CALLBACK_ERROR = 18,
CALLBACK_ERROR = 20,

/*!
* The engine has crashed or malfunctioned and will no longer work.
*/
CALLBACK_QUIT = 19
CALLBACK_QUIT = 21
};

/*!
@@ -534,11 +542,11 @@ enum ProcessMode {
};

/*!
* Callback function the backend will call when something interesting happens.
* Callback function the engine will call when something interesting happens.
*
* \see set_callback_function() and CallbackType
* \see CallbackType and set_callback_function()
*/
typedef void (*CallbackFunc)(void* ptr, CallbackType action, int pluginId, int value1, int value2, double value3, const char* valueStr);
typedef void (*CallbackFunc)(void* ptr, CallbackType action, unsigned int pluginId, int value1, int value2, double value3, const char* valueStr);

/*!
* Parameter data


+ 7
- 7
source/backend/carla_engine.hpp View File

@@ -592,13 +592,13 @@ public:
/*!
* Current number of plugins loaded.
*/
int currentPluginCount() const;
unsigned int currentPluginCount() const;

/*!
* Maximum number of loadable plugins allowed.
* \note This function returns 0 if engine is not started.
*/
int maxPluginNumber() const;
unsigned int maxPluginNumber() const;

// -------------------------------------------------------------------
// Virtual, per-engine type calls
@@ -648,12 +648,12 @@ public:
/*!
* Get plugin with id \a id.
*/
CarlaPlugin* getPlugin(const int id) const;
CarlaPlugin* getPlugin(const unsigned int id) const;

/*!
* Get plugin with id \a id, faster unchecked version.
*/
CarlaPlugin* getPluginUnchecked(const int id) const;
CarlaPlugin* getPluginUnchecked(const unsigned int id) const;

/*!
* Get a unique plugin name within the engine.\n
@@ -665,13 +665,13 @@ public:
* Add new plugin.\n
* Returns the id of the plugin, or -1 if the operation failed.
*/
int addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr);
bool addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr);

/*!
* Add new plugin, using native binary type.\n
* Returns the id of the plugin, or -1 if the operation failed.
*/
int addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr)
bool addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr)
{
return addPlugin(BINARY_NATIVE, ptype, filename, name, label, extra);
}
@@ -679,7 +679,7 @@ public:
/*!
* Remove plugin with id \a id.
*/
bool removePlugin(const int id);
bool removePlugin(const unsigned int id);

/*!
* Remove all plugins.


+ 17
- 16
source/backend/engine/carla_engine.cpp View File

@@ -452,12 +452,12 @@ unsigned int CarlaEngine::maxPortNameSize() const
return STR_MAX;
}

int CarlaEngine::currentPluginCount() const
unsigned int CarlaEngine::currentPluginCount() const
{
return fData->curPluginCount;
}

int CarlaEngine::maxPluginNumber() const
unsigned int CarlaEngine::maxPluginNumber() const
{
return fData->maxPluginNumber;
}
@@ -549,7 +549,7 @@ int CarlaEngine::getNewPluginId() const
}
#endif

CarlaPlugin* CarlaEngine::getPlugin(const int id) const
CarlaPlugin* CarlaEngine::getPlugin(const unsigned int id) const
{
qDebug("CarlaEngine::getPlugin(%i) [count:%i]", id, fData->curPluginCount);
CARLA_ASSERT(fData->curPluginCount > 0);
@@ -562,7 +562,7 @@ CarlaPlugin* CarlaEngine::getPlugin(const int id) const
return nullptr;
}

CarlaPlugin* CarlaEngine::getPluginUnchecked(const int id) const
CarlaPlugin* CarlaEngine::getPluginUnchecked(const unsigned int id) const
{
return fData->plugins[id].plugin;
}
@@ -643,7 +643,7 @@ const char* CarlaEngine::getNewUniquePluginName(const char* const name)
return strdup(sname);
}

int CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra)
bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra)
{
qDebug("CarlaEngine::addPlugin(%s, %s, \"%s\", \"%s\", \"%s\", %p)", BinaryType2Str(btype), PluginType2Str(ptype), filename, name, label, extra);
CARLA_ASSERT(btype != BINARY_NONE);
@@ -651,12 +651,12 @@ int CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const
CARLA_ASSERT(filename);
CARLA_ASSERT(label);

CarlaPlugin::Initializer init = {
this,
filename,
name,
label
};
//CarlaPlugin::Initializer init = {
// this,
// filename,
// name,
// label
//};

CarlaPlugin* plugin = nullptr;

@@ -766,19 +766,20 @@ int CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const
#endif
}

if (! plugin)
return -1;
if (plugin == nullptr)
return false;

const int id = fData->curPluginCount++;
//const int id = fData->curPluginCount++;

#if 0
plugin->setId(id);
#endif

return id;
//return id;
return true;
}

bool CarlaEngine::removePlugin(const int id)
bool CarlaEngine::removePlugin(const unsigned int id)
{
qDebug("CarlaEngine::removePlugin(%i)", id);
CARLA_ASSERT(fData->curPluginCount > 0);


+ 3
- 3
source/backend/engine/carla_engine_internal.hpp View File

@@ -150,9 +150,9 @@ struct CarlaEngineProtectedData {
QProcessEnvironment procEnv;
#endif

bool aboutToClose; // don't re-activate thread if true
int curPluginCount; // number of plugins loaded (0...max)
int maxPluginNumber; // number of plugins allowed (0, 16, 99 or 999)
bool aboutToClose; // don't re-activate thread if true
unsigned int curPluginCount; // number of plugins loaded (0...max)
unsigned int maxPluginNumber; // number of plugins allowed (0, 16, 99 or 999)

EnginePluginData* plugins;



+ 2
- 2
source/backend/engine/carla_engine_osc.cpp View File

@@ -187,7 +187,7 @@ int CarlaEngineOsc::handleMessage(const char* const path, const int argc, const
// Get plugin id from message
// eg, /carla/23/method

int pluginId = -1;
unsigned int pluginId = 0;

if (isDigit(path[nameSize+2]))
{
@@ -219,7 +219,7 @@ int CarlaEngineOsc::handleMessage(const char* const path, const int argc, const
}
}

if (pluginId < 0 || pluginId > kEngine->currentPluginCount())
if (pluginId > kEngine->currentPluginCount())
{
qCritical("CarlaEngineOsc::handleMessage() - failed to get plugin, wrong id '%i'", pluginId);
return 1;


+ 8
- 2
source/bridges/carla_bridge_plugin.cpp View File

@@ -799,7 +799,7 @@ public:
// ---------------------------------------------------------------------
// callback

static void callback(void* const ptr, CarlaBackend::CallbackType const action, const int, const int value1, const int value2, const double value3, const char* const valueStr)
static void callback(void* const ptr, CarlaBackend::CallbackType const action, const unsigned int, const int value1, const int value2, const double value3, const char* const valueStr)
{
CARLA_ASSERT(ptr);

@@ -835,6 +835,12 @@ protected:
case CALLBACK_DEBUG:
break;

case CALLBACK_PLUGIN_ADDED:
break;

case CALLBACK_PLUGIN_REMOVED:
break;

case CALLBACK_PARAMETER_VALUE_CHANGED:
parametersToUpdate.insert(value1);
break;
@@ -1113,7 +1119,7 @@ int main(int argc, char* argv[])
if (itype == CarlaBackend::PLUGIN_DSSI)
extraStuff = findDSSIGUI(filename, name, label);

// Init plugin
// Init plugin, FIXME
int id = engine->addPlugin(itype, filename, name, label, extraStuff);
int ret;



+ 4
- 0
source/utils/carla_backend_utils.hpp View File

@@ -240,6 +240,10 @@ const char* CallbackType2Str(const CallbackType& type)
{
case CALLBACK_DEBUG:
return "CALLBACK_DEBUG";
case CALLBACK_PLUGIN_ADDED:
return "CALLBACK_PLUGIN_ADDED";
case CALLBACK_PLUGIN_REMOVED:
return "CALLBACK_PLUGIN_REMOVED";
case CALLBACK_PARAMETER_VALUE_CHANGED:
return "CALLBACK_PARAMETER_VALUE_CHANGED";
case CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:


Loading…
Cancel
Save