Browse Source

More API changes

tags/1.9.4
falkTX 12 years ago
parent
commit
011cf7f41e
11 changed files with 269 additions and 131 deletions
  1. +18
    -1
      source/backend/CarlaBackend.hpp
  2. +45
    -24
      source/backend/CarlaEngine.hpp
  3. +21
    -31
      source/backend/CarlaHost.hpp
  4. +5
    -0
      source/backend/CarlaPlugin.hpp
  5. +34
    -2
      source/backend/engine/CarlaEngine.cpp
  6. +1
    -1
      source/backend/engine/CarlaEngineJuce.cpp
  7. +115
    -54
      source/backend/engine/CarlaEngineRtAudio.cpp
  8. +1
    -0
      source/backend/plugin/CarlaPlugin.cpp
  9. +10
    -6
      source/backend/standalone/CarlaStandalone.cpp
  10. +18
    -11
      source/carla_backend.py
  11. +1
    -1
      source/utils/CarlaLv2Utils.hpp

+ 18
- 1
source/backend/CarlaBackend.hpp View File

@@ -40,7 +40,7 @@ CARLA_BACKEND_START_NAMESPACE
* @defgroup CarlaBackendAPI Carla Backend API
*
* The Carla Backend API.\n
* This is the base definitions for everything in the Carla code.
* This is the base definitions for everything in the Carla backend code.
* @{
*/

@@ -53,6 +53,7 @@ const unsigned int MAX_DEFAULT_PARAMETERS = 200; //!< Maximum default number of
* @defgroup EngineDriverHints Engine Driver Hints
*
* Various engine driver hints.
* \see CarlaEngine::hints()
* @{
*/
const unsigned int ENGINE_DRIVER_HAS_CONTROL_PANEL = 0x1; //!< Engine driver has custom control-panel.
@@ -864,6 +865,22 @@ struct CustomData {
#endif
};

/*!
* Engine driver device information.
*/
struct EngineDriverDeviceInfo {
unsigned int hints;
const uint32_t* bufferSizes; // terminated with 0
const double* sampleRates; // terminated with 0.0

#ifndef DOXYGEN
EngineDriverDeviceInfo()
: hints(0x0),
bufferSizes(nullptr),
sampleRates(nullptr) {}
#endif
};

/**@}*/

// forward declarations of commonly used Carla classes


+ 45
- 24
source/backend/CarlaEngine.hpp View File

@@ -696,7 +696,7 @@ class CarlaEngine
protected:
/*!
* The constructor, protected.\n
* \note This only initializes engine data, it doesn't initialize the engine itself.
* \note This only initializes engine data, it doesn't start the engine (audio).
*/
CarlaEngine();

@@ -721,10 +721,14 @@ public:
static const char* getDriverName(const unsigned int index);

/*!
* Get the device names of driver at \a index (for use in non-JACK drivers).\n
* May return NULL.
* Get the device names of driver at \a index.
*/
static const char* const* getDriverDeviceNames(const unsigned int index);

/*!
* Get the device names of driver at \a index.
*/
static const char** getDriverDeviceNames(const unsigned int index);
static const EngineDriverDeviceInfo* getDriverDeviceInfo(const unsigned int index, const char* const driverName);

/*!
* Create a new engine, using driver \a driverName. \n
@@ -893,7 +897,15 @@ public:
// Information (base)

/*!
* Get current buffer size.
* Get the current engine driver hints.
*/
unsigned int getHints() const noexcept
{
return fHints;
}

/*!
* Get the current buffer size.
*/
uint32_t getBufferSize() const noexcept
{
@@ -901,7 +913,7 @@ public:
}

/*!
* Get current sample rate.
* Get the current sample rate.
*/
double getSampleRate() const noexcept
{
@@ -909,7 +921,7 @@ public:
}

/*!
* Get engine name.
* Get the current engine name.
*/
const char* getName() const noexcept
{
@@ -917,23 +929,23 @@ public:
}

/*!
* Get the engine options (read-only).
* Get the current engine proccess mode.
*/
const EngineOptions& getOptions() const noexcept
EngineProcessMode getProccessMode() const noexcept
{
return fOptions;
return fOptions.processMode;
}

/*!
* Get the engine proccess mode.
* Get the current engine options (read-only).
*/
EngineProcessMode getProccessMode() const noexcept
const EngineOptions& getOptions() const noexcept
{
return fOptions.processMode;
return fOptions;
}

/*!
* Get current Time information (read-only).
* Get the current Time information (read-only).
*/
const EngineTimeInfo& getTimeInfo() const noexcept
{
@@ -1089,6 +1101,12 @@ public:
// -------------------------------------------------------------------

protected:
/*!
* Current engine driver hints.
* \see getHints()
*/
unsigned int fHints;

/*!
* Current buffer size.
* \see getBufferSize()
@@ -1199,20 +1217,23 @@ private:
AUDIO_API_DS = 7
};

static CarlaEngine* newJuce(const AudioApi api);
static size_t getJuceApiCount();
static const char* getJuceApiName(const unsigned int index);
static const char** getJuceApiDeviceNames(const unsigned int index);

static CarlaEngine* newRtAudio(const AudioApi api);
static size_t getRtAudioApiCount();
static const char* getRtAudioApiName(const unsigned int index);
static const char** getRtAudioApiDeviceNames(const unsigned int index);
static CarlaEngine* newRtAudio(const AudioApi api);
static size_t getRtAudioApiCount();
static const char* getRtAudioApiName(const unsigned int index);
static const char* const* getRtAudioApiDeviceNames(const unsigned int index);
static const EngineDriverDeviceInfo* getRtAudioDeviceInfo(const unsigned int index, const char* const deviceName);

# ifdef USE_JUCE
static CarlaEngine* newJuce(const AudioApi api);
static size_t getJuceApiCount();
static const char* getJuceApiName(const unsigned int index);
static const char* const* getJuceApiDeviceNames(const unsigned int index);
static const EngineDriverDeviceInfo* getJuceDeviceInfo(const unsigned int index, const char* const deviceName);
# endif
#endif

// -------------------------------------------------------------------
// Bridge/Controller OSC stuff

public:
#ifdef BUILD_BRIDGE
void oscSend_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total);


+ 21
- 31
source/backend/CarlaHost.hpp View File

@@ -40,18 +40,19 @@
* Basic typedefs to help make code cleaner.
* @{
*/
typedef CarlaBackend::BinaryType CarlaBinaryType;
typedef CarlaBackend::PluginType CarlaPluginType;
typedef CarlaBackend::PluginCategory CarlaPluginCategory;
typedef CarlaBackend::EngineCallbackFunc CarlaEngineCallbackFunc;
typedef CarlaBackend::EngineCallbackOpcode CarlaEngineCallbackOpcode;
typedef CarlaBackend::EngineOption CarlaEngineOption;
typedef CarlaBackend::FileCallbackFunc CarlaFileCallbackFunc;
typedef CarlaBackend::FileCallbackOpcode CarlaFileCallbackOpcode;
typedef CarlaBackend::ParameterData CarlaParameterData;
typedef CarlaBackend::ParameterRanges CarlaParameterRanges;
typedef CarlaBackend::MidiProgramData CarlaMidiProgramData;
typedef CarlaBackend::CustomData CarlaCustomData;
typedef CarlaBackend::BinaryType CarlaBinaryType;
typedef CarlaBackend::PluginType CarlaPluginType;
typedef CarlaBackend::PluginCategory CarlaPluginCategory;
typedef CarlaBackend::EngineCallbackFunc CarlaEngineCallbackFunc;
typedef CarlaBackend::EngineCallbackOpcode CarlaEngineCallbackOpcode;
typedef CarlaBackend::EngineOption CarlaEngineOption;
typedef CarlaBackend::FileCallbackFunc CarlaFileCallbackFunc;
typedef CarlaBackend::FileCallbackOpcode CarlaFileCallbackOpcode;
typedef CarlaBackend::ParameterData CarlaParameterData;
typedef CarlaBackend::ParameterRanges CarlaParameterRanges;
typedef CarlaBackend::MidiProgramData CarlaMidiProgramData;
typedef CarlaBackend::CustomData CarlaCustomData;
typedef CarlaBackend::EngineDriverDeviceInfo CarlaEngineDriverDeviceInfo;
/**@}*/

/*!
@@ -249,21 +250,6 @@ struct CarlaTransportInfo {
#endif
};

/*!
* Engine driver information.
* \see carla_get_engine_driver_info()
*/
struct CarlaEngineDriverInfo {
const char* name;
unsigned int hints;

#ifndef DOXYGEN
CarlaEngineDriverInfo()
: name(nullptr),
hints(0x0) {}
#endif
};

/*!
* Get the complete license text of used third-party code and features.\n
* Returned string is in basic html format.
@@ -287,13 +273,17 @@ CARLA_EXPORT unsigned int carla_get_engine_driver_count();
/*!
* Get the engine driver info for \a index.
*/
CARLA_EXPORT const CarlaEngineDriverInfo* carla_get_engine_driver_info(unsigned int index);
CARLA_EXPORT const char* carla_get_engine_driver_name(unsigned int index);

/*!
* Get the device names of the engine driver at \a index.
*/
CARLA_EXPORT const char* const* carla_get_engine_driver_device_names(unsigned int index);

/*!
* Get the device names of the engine driver at \a index (for use in non-JACK drivers).\n
* May return NULL.
* Get a device driver info.
*/
CARLA_EXPORT const char** carla_get_engine_driver_device_names(unsigned int index);
CARLA_EXPORT const CarlaEngineDriverDeviceInfo* carla_get_engine_driver_device_info(unsigned int index, const char* driverName);

/*!
* Get how many internal plugins are available to use.


+ 5
- 0
source/backend/CarlaPlugin.hpp View File

@@ -878,6 +878,11 @@ protected:
*/
unsigned int fOptions;

/*!
* Patchbay client Id that matches this plugin, 0 if unused.
*/
int fPatchbayClientId;

/*!
* Wherever the plugin is ready for usage.\n
* When a plugin is disabled, it will never be processed or managed in any way.


+ 34
- 2
source/backend/engine/CarlaEngine.cpp View File

@@ -340,7 +340,8 @@ CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const
// Carla Engine

CarlaEngine::CarlaEngine()
: fBufferSize(0),
: fHints(0x0),
fBufferSize(0),
fSampleRate(0.0),
pData(new CarlaEngineProtectedData(this))
{
@@ -398,7 +399,7 @@ const char* CarlaEngine::getDriverName(const unsigned int index)
return nullptr;
}

const char** CarlaEngine::getDriverDeviceNames(const unsigned int index)
const char* const* CarlaEngine::getDriverDeviceNames(const unsigned int index)
{
carla_debug("CarlaEngine::getDriverDeviceNames(%i)", index);

@@ -426,6 +427,37 @@ const char** CarlaEngine::getDriverDeviceNames(const unsigned int index)
return nullptr;
}

const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const unsigned int index, const char* const deviceName)
{
carla_debug("CarlaEngine::getDriverDeviceInfo(%i, \"%s\")", index, deviceName);

if (index == 0)
{
static uint32_t bufSizes[11] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 0 };
static EngineDriverDeviceInfo devInfo;
devInfo.hints |= ENGINE_DRIVER_VARIABLE_BUFFER_SIZE;
devInfo.bufferSizes = bufSizes;
return &devInfo;
}

#ifndef BUILD_BRIDGE
const unsigned int rtAudioIndex(index-1);

if (rtAudioIndex < getRtAudioApiCount())
return getRtAudioDeviceInfo(rtAudioIndex, deviceName);

# ifdef USE_JUCE
const unsigned int juceIndex(index-rtAudioIndex-1);

if (juceIndex < getJuceApiCount())
return getJuceDeviceInfo(juceIndex, deviceName);
# endif
#endif

carla_stderr("CarlaEngine::getDriverDeviceNames(%i, \"%s\") - invalid index", index, deviceName);
return nullptr;
}

CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName)
{
CARLA_SAFE_ASSERT_RETURN(driverName != nullptr && driverName[0] != '\0', nullptr);


+ 1
- 1
source/backend/engine/CarlaEngineJuce.cpp View File

@@ -141,7 +141,7 @@ const char* CarlaEngine::getJuceApiName(const unsigned int /*index*/)
return nullptr;
}

const char** CarlaEngine::getJuceApiDeviceNames(const unsigned int /*index*/)
const char* const* CarlaEngine::getJuceApiDeviceNames(const unsigned int /*index*/)
{
#if 0
juce::ScopedPointer<juce::AudioIODeviceType> deviceType;


+ 115
- 54
source/backend/engine/CarlaEngineRtAudio.cpp View File

@@ -1455,21 +1455,22 @@ const char* CarlaEngine::getRtAudioApiName(const unsigned int index)
{
initRtApis();

if (index < gRtAudioApis.size())
{
const RtAudio::Api& api(gRtAudioApis[index]);
if (index >= gRtAudioApis.size())
return nullptr;

switch (api)
{
case RtAudio::UNSPECIFIED:
return "Unspecified";
case RtAudio::LINUX_ALSA:
return "ALSA";
case RtAudio::LINUX_PULSE:
return "PulseAudio";
case RtAudio::LINUX_OSS:
return "OSS";
case RtAudio::UNIX_JACK:
const RtAudio::Api& api(gRtAudioApis[index]);

switch (api)
{
case RtAudio::UNSPECIFIED:
return "Unspecified";
case RtAudio::LINUX_ALSA:
return "ALSA";
case RtAudio::LINUX_PULSE:
return "PulseAudio";
case RtAudio::LINUX_OSS:
return "OSS";
case RtAudio::UNIX_JACK:
#if defined(CARLA_OS_WIN)
return "JACK with WinMM";
#elif defined(CARLA_OS_MAC)
@@ -1479,68 +1480,128 @@ const char* CarlaEngine::getRtAudioApiName(const unsigned int index)
#else
return "JACK (RtAudio)";
#endif
case RtAudio::MACOSX_CORE:
return "CoreAudio";
case RtAudio::WINDOWS_ASIO:
return "ASIO";
case RtAudio::WINDOWS_DS:
return "DirectSound";
case RtAudio::RTAUDIO_DUMMY:
return "Dummy";
}
case RtAudio::MACOSX_CORE:
return "CoreAudio";
case RtAudio::WINDOWS_ASIO:
return "ASIO";
case RtAudio::WINDOWS_DS:
return "DirectSound";
case RtAudio::RTAUDIO_DUMMY:
return "Dummy";
}

return nullptr;
}

const char** CarlaEngine::getRtAudioApiDeviceNames(const unsigned int index)
const char* const* CarlaEngine::getRtAudioApiDeviceNames(const unsigned int index)
{
initRtApis();

if (index < gRtAudioApis.size())
if (index >= gRtAudioApis.size())
return nullptr;

const RtAudio::Api& api(gRtAudioApis[index]);

RtAudio rtAudio(api);

if (gRetNames != nullptr)
{
const RtAudio::Api& api(gRtAudioApis[index]);
int i=0;
while (gRetNames[i] != nullptr)
delete[] gRetNames[i++];
delete[] gRetNames;
gRetNames = nullptr;
}

RtAudio rtAudio(api);
const unsigned int devCount(rtAudio.getDeviceCount());

if (gRetNames != nullptr)
{
int i=0;
while (gRetNames[i] != nullptr)
delete[] gRetNames[i++];
delete[] gRetNames;
gRetNames = nullptr;
}
if (devCount == 0)
return nullptr;

const unsigned int devCount(rtAudio.getDeviceCount());
List<const char*> devNames;

if (devCount > 0)
{
List<const char*> devNames;
for (unsigned int i=0; i < devCount; ++i)
{
RtAudio::DeviceInfo devInfo(rtAudio.getDeviceInfo(i));

for (unsigned int i=0; i < devCount; ++i)
{
RtAudio::DeviceInfo devInfo(rtAudio.getDeviceInfo(i));
if (devInfo.probed && devInfo.outputChannels > 0 /*&& (devInfo.nativeFormats & RTAUDIO_FLOAT32) != 0*/)
devNames.append(carla_strdup(devInfo.name.c_str()));
}

if (devInfo.probed && devInfo.outputChannels > 0 /*&& (devInfo.nativeFormats & RTAUDIO_FLOAT32) != 0*/)
devNames.append(carla_strdup(devInfo.name.c_str()));
}
const unsigned int realDevCount(devNames.count());

const unsigned int realDevCount(devNames.count());
gRetNames = new const char*[realDevCount+1];

gRetNames = new const char*[realDevCount+1];
for (unsigned int i=0; i < realDevCount; ++i)
gRetNames[i] = devNames.getAt(i);

for (unsigned int i=0; i < realDevCount; ++i)
gRetNames[i] = devNames.getAt(i);
gRetNames[realDevCount] = nullptr;
devNames.clear();

gRetNames[realDevCount] = nullptr;
devNames.clear();
return gRetNames;
}

return gRetNames;
}
const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const unsigned int index, const char* const deviceName)
{
initRtApis();

if (index >= gRtAudioApis.size())
return nullptr;

const RtAudio::Api& api(gRtAudioApis[index]);

RtAudio rtAudio(api);

const unsigned int devCount(rtAudio.getDeviceCount());

if (devCount == 0)
return nullptr;

unsigned int i;
RtAudio::DeviceInfo rtAudioDevInfo;

for (i=0; i < devCount; ++i)
{
rtAudioDevInfo = rtAudio.getDeviceInfo(i);

if (rtAudioDevInfo.name == deviceName)
break;
}

return nullptr;
if (i == devCount)
return nullptr;

static EngineDriverDeviceInfo devInfo;
static uint32_t dummyBufferSizes[11] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 0 };
static double dummySampleRates[14] = { 22050.0, 32000.0, 44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, 0.0 };

// reset
devInfo.hints = 0x0;
devInfo.bufferSizes = dummyBufferSizes;

// cleanup
if (devInfo.sampleRates != nullptr && devInfo.sampleRates != dummySampleRates)
{
delete[] devInfo.sampleRates;
devInfo.sampleRates = nullptr;
}

if (size_t sampleRatesCount = rtAudioDevInfo.sampleRates.size())
{
double* sampleRates(new double[sampleRatesCount+1]);

for (size_t i=0; i < sampleRatesCount; ++i)
sampleRates[i] = rtAudioDevInfo.sampleRates[i];
sampleRates[sampleRatesCount] = 0.0;

devInfo.sampleRates = sampleRates;
}
else
{
devInfo.sampleRates = dummySampleRates;
}

return &devInfo;
}

// -----------------------------------------


+ 1
- 0
source/backend/plugin/CarlaPlugin.cpp View File

@@ -225,6 +225,7 @@ CarlaPlugin::CarlaPlugin(CarlaEngine* const engine, const unsigned int id)
: fId(id),
fHints(0x0),
fOptions(0x0),
fPatchbayClientId(0),
fEnabled(false),
fIconName("plugin"),
pData(new CarlaPluginProtectedData(engine, this))


+ 10
- 6
source/backend/standalone/CarlaStandalone.cpp View File

@@ -307,23 +307,27 @@ unsigned int carla_get_engine_driver_count()
return CarlaEngine::getDriverCount();
}

const CarlaEngineDriverInfo* carla_get_engine_driver_info(unsigned int index)
const char* carla_get_engine_driver_name(unsigned int index)
{
carla_debug("carla_get_engine_driver_info(%i)", index);

static CarlaEngineDriverInfo info;
info.name = CarlaEngine::getDriverName(index);

return &info;
return CarlaEngine::getDriverName(index);
}

const char** carla_get_engine_driver_device_names(unsigned int index)
const char* const* carla_get_engine_driver_device_names(unsigned int index)
{
carla_debug("carla_get_engine_driver_device_names(%i)", index);

return CarlaEngine::getDriverDeviceNames(index);
}

const CarlaEngineDriverDeviceInfo* carla_get_engine_driver_device_info(unsigned int index, const char* deviceName)
{
carla_debug("carla_get_engine_driver_device_info(%i, \"%s\")", index, deviceName);

return CarlaEngine::getDriverDeviceInfo(index, deviceName);
}

// -------------------------------------------------------------------------------------------------------------------

unsigned int carla_get_internal_plugin_count()


+ 18
- 11
source/carla_backend.py View File

@@ -343,6 +343,13 @@ class CustomData(Structure):
("value", c_char_p)
]

class EngineDriverDeviceInfo(Structure):
_fields_ = [
("hints", c_uint),
("bufferSizes", POINTER(c_uint32)),
("sampleRates", POINTER(c_double))
]

# ------------------------------------------------------------------------------------------------------------
# Host C++ -> Python variables

@@ -410,12 +417,6 @@ class CarlaTransportInfo(Structure):
("bpm", c_double)
]

class CarlaEngineDriverInfo(Structure):
_fields_ = [
("name", c_char_p),
("hints", c_uint)
]

# ------------------------------------------------------------------------------------------------------------
# Python object dicts compatible with ctypes struct

@@ -515,12 +516,15 @@ class Host(object):
self.lib.carla_get_engine_driver_count.argtypes = None
self.lib.carla_get_engine_driver_count.restype = c_uint

self.lib.carla_get_engine_driver_info.argtypes = [c_uint]
self.lib.carla_get_engine_driver_info.restype = POINTER(CarlaEngineDriverInfo)
self.lib.carla_get_engine_driver_name.argtypes = [c_uint]
self.lib.carla_get_engine_driver_name.restype = c_char_p

self.lib.carla_get_engine_driver_device_names.argtypes = [c_uint]
self.lib.carla_get_engine_driver_device_names.restype = POINTER(c_char_p)

self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p]
self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo)

self.lib.carla_get_internal_plugin_count.argtypes = None
self.lib.carla_get_internal_plugin_count.restype = c_uint

@@ -542,7 +546,7 @@ class Host(object):
self.lib.carla_set_engine_about_to_close.argtypes = None
self.lib.carla_set_engine_about_to_close.restype = None

self.lib.carla_set_engine_callback.argtypes = [CallbackFunc, c_void_p]
self.lib.carla_set_engine_callback.argtypes = [EngineCallbackFunc, c_void_p]
self.lib.carla_set_engine_callback.restype = None

self.lib.carla_set_engine_option.argtypes = [c_enum, c_int, c_char_p]
@@ -773,12 +777,15 @@ class Host(object):
def get_engine_driver_count(self):
return self.lib.carla_get_engine_driver_count()

def get_engine_driver_info(self, index):
return structToDict(self.lib.carla_get_engine_driver_info(index))
def get_engine_driver_name(self, index):
return self.lib.carla_get_engine_driver_name(index)

def get_engine_driver_device_names(self, index):
return charStringList(self.lib.carla_get_engine_driver_device_names(index))

def get_engine_driver_device_info(self, index, deviceName):
return structToDict(self.lib.carla_get_engine_driver_device_info(index, deviceName))

def get_internal_plugin_count(self):
return self.lib.carla_get_internal_plugin_count()



+ 1
- 1
source/utils/CarlaLv2Utils.hpp View File

@@ -81,8 +81,8 @@

#define LV2_OSC__OscEvent "http://kxstudio.sf.net/ns/lv2ext/osc#OscEvent"

#define LV2_UI__Qt5UI LV2_UI_PREFIX "Qt5UI"
#define LV2_UI__NtkUI LV2_UI_PREFIX "NtkUI"
#define LV2_UI__Qt5UI LV2_UI_PREFIX "Qt5UI"
#define LV2_UI__idle LV2_UI_PREFIX "idle"
#define LV2_UI__makeResident LV2_UI_PREFIX "makeResident"



Loading…
Cancel
Save