Browse Source

More cleanup and testing

tags/1.9.4
falkTX 11 years ago
parent
commit
5ba815a922
6 changed files with 75 additions and 44 deletions
  1. +4
    -1
      source/backend/CarlaPlugin.hpp
  2. +33
    -33
      source/backend/plugin/CarlaPlugin.cpp
  3. +12
    -2
      source/backend/standalone/CarlaStandalone.cpp
  4. +0
    -1
      source/modules/utils/CarlaLogThread.hpp
  5. +19
    -1
      source/tests/ANSI.cpp
  6. +7
    -6
      source/tests/Makefile

+ 4
- 1
source/backend/CarlaPlugin.hpp View File

@@ -821,7 +821,10 @@ public:
/*!
* Handy function used and required by CarlaEngine::clonePlugin().
*/
virtual const void* getExtraStuff() const noexcept;
virtual const void* getExtraStuff() const noexcept
{
return nullptr;
}

#ifndef DOXYGEN
struct Initializer {


+ 33
- 33
source/backend/plugin/CarlaPlugin.cpp View File

@@ -328,7 +328,7 @@ CarlaPlugin::~CarlaPlugin()
// -------------------------------------------------------------------
// Information (base)

uint32_t CarlaPlugin::latency() const noexcept
uint32_t CarlaPlugin::getLatencyInFrames() const noexcept
{
return pData->latency;
}
@@ -336,32 +336,32 @@ uint32_t CarlaPlugin::latency() const noexcept
// -------------------------------------------------------------------
// Information (count)

uint32_t CarlaPlugin::audioInCount() const noexcept
uint32_t CarlaPlugin::getAudioInCount() const noexcept
{
return pData->audioIn.count;
}

uint32_t CarlaPlugin::audioOutCount() const noexcept
uint32_t CarlaPlugin::getAudioOutCount() const noexcept
{
return pData->audioOut.count;
}

uint32_t CarlaPlugin::midiInCount() const noexcept
uint32_t CarlaPlugin::getMidiInCount() const noexcept
{
return (pData->extraHints & PLUGIN_HINT_HAS_MIDI_IN) ? 1 : 0;
}

uint32_t CarlaPlugin::midiOutCount() const
uint32_t CarlaPlugin::getMidiOutCount() const noexcept
{
return (pData->extraHints & PLUGIN_HINT_HAS_MIDI_OUT) ? 1 : 0;
}

uint32_t CarlaPlugin::parameterCount() const noexcept
uint32_t CarlaPlugin::getParameterCount() const noexcept
{
return pData->param.count;
}

uint32_t CarlaPlugin::parameterScalePointCount(const uint32_t parameterId) const
uint32_t CarlaPlugin::getParameterScalePointCount(const uint32_t parameterId) const
{
CARLA_ASSERT(parameterId < pData->param.count);
return 0;
@@ -370,17 +370,17 @@ uint32_t CarlaPlugin::parameterScalePointCount(const uint32_t parameterId) const
(void)parameterId;
}

uint32_t CarlaPlugin::programCount() const noexcept
uint32_t CarlaPlugin::getProgramCount() const noexcept
{
return pData->prog.count;
}

uint32_t CarlaPlugin::midiProgramCount() const noexcept
uint32_t CarlaPlugin::getMidiProgramCount() const noexcept
{
return pData->midiprog.count;
}

uint32_t CarlaPlugin::customDataCount() const noexcept
uint32_t CarlaPlugin::getCustomDataCount() const noexcept
{
return pData->custom.count();
}
@@ -388,52 +388,52 @@ uint32_t CarlaPlugin::customDataCount() const noexcept
// -------------------------------------------------------------------
// Information (current data)

int32_t CarlaPlugin::currentProgram() const noexcept
int32_t CarlaPlugin::getCurrentProgram() const noexcept
{
return pData->prog.current;
}

int32_t CarlaPlugin::currentMidiProgram() const noexcept
int32_t CarlaPlugin::getCurrentMidiProgram() const noexcept
{
return pData->midiprog.current;
}

const ParameterData& CarlaPlugin::parameterData(const uint32_t parameterId) const
const ParameterData& CarlaPlugin::getParameterData(const uint32_t parameterId) const
{
CARLA_ASSERT(parameterId < pData->param.count);

return (parameterId < pData->param.count) ? pData->param.data[parameterId] : kParameterDataNull;
}

const ParameterRanges& CarlaPlugin::parameterRanges(const uint32_t parameterId) const
const ParameterRanges& CarlaPlugin::getParameterRanges(const uint32_t parameterId) const
{
CARLA_ASSERT(parameterId < pData->param.count);

return (parameterId < pData->param.count) ? pData->param.ranges[parameterId] : kParameterRangesNull;
}

bool CarlaPlugin::parameterIsOutput(const uint32_t parameterId) const
bool CarlaPlugin::isParameterOutput(const uint32_t parameterId) const
{
CARLA_ASSERT(parameterId < pData->param.count);

return (parameterId < pData->param.count) ? (pData->param.data[parameterId].type == PARAMETER_OUTPUT) : false;
}

const MidiProgramData& CarlaPlugin::midiProgramData(const uint32_t index) const
const MidiProgramData& CarlaPlugin::getMidiProgramData(const uint32_t index) const
{
CARLA_ASSERT(index < pData->midiprog.count);

return (index < pData->midiprog.count) ? pData->midiprog.data[index] : kMidiProgramDataNull;
}

const CustomData& CarlaPlugin::customData(const uint32_t index) const
const CustomData& CarlaPlugin::getCustomData(const uint32_t index) const
{
CARLA_ASSERT(index < pData->custom.count());

return (index < pData->custom.count()) ? pData->custom.getAt(index) : kCustomDataNull;
}

int32_t CarlaPlugin::chunkData(void** const dataPtr)
int32_t CarlaPlugin::getChunkData(void** const dataPtr) const
{
CARLA_ASSERT(dataPtr != nullptr);
CARLA_ASSERT(false); // this should never happen
@@ -446,13 +446,13 @@ int32_t CarlaPlugin::chunkData(void** const dataPtr)
// -------------------------------------------------------------------
// Information (per-plugin data)

unsigned int CarlaPlugin::availableOptions()
unsigned int CarlaPlugin::getAvailableOptions() const
{
CARLA_ASSERT(false); // this should never happen
return 0x0;
}

float CarlaPlugin::getParameterValue(const uint32_t parameterId)
float CarlaPlugin::getParameterValue(const uint32_t parameterId) const
{
CARLA_ASSERT(parameterId < parameterCount());
CARLA_ASSERT(false); // this should never happen
@@ -462,7 +462,7 @@ float CarlaPlugin::getParameterValue(const uint32_t parameterId)
(void)parameterId;
}

float CarlaPlugin::getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId)
float CarlaPlugin::getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId) const
{
CARLA_ASSERT(parameterId < parameterCount());
CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId));
@@ -474,27 +474,27 @@ float CarlaPlugin::getParameterScalePointValue(const uint32_t parameterId, const
(void)scalePointId;
}

void CarlaPlugin::getLabel(char* const strBuf) noexcept
void CarlaPlugin::getLabel(char* const strBuf) const noexcept
{
*strBuf = '\0';
}

void CarlaPlugin::getMaker(char* const strBuf) noexcept
void CarlaPlugin::getMaker(char* const strBuf) const noexcept
{
*strBuf = '\0';
}

void CarlaPlugin::getCopyright(char* const strBuf) noexcept
void CarlaPlugin::getCopyright(char* const strBuf) const noexcept
{
*strBuf = '\0';
}

void CarlaPlugin::getRealName(char* const strBuf) noexcept
void CarlaPlugin::getRealName(char* const strBuf) const noexcept
{
*strBuf = '\0';
}

void CarlaPlugin::getParameterName(const uint32_t parameterId, char* const strBuf)
void CarlaPlugin::getParameterName(const uint32_t parameterId, char* const strBuf) const
{
CARLA_ASSERT(parameterId < parameterCount());
CARLA_ASSERT(false); // this should never happen
@@ -505,7 +505,7 @@ void CarlaPlugin::getParameterName(const uint32_t parameterId, char* const strBu
(void)parameterId;
}

void CarlaPlugin::getParameterSymbol(const uint32_t parameterId, char* const strBuf)
void CarlaPlugin::getParameterSymbol(const uint32_t parameterId, char* const strBuf) const
{
CARLA_ASSERT(parameterId < parameterCount());
*strBuf = '\0';
@@ -515,7 +515,7 @@ void CarlaPlugin::getParameterSymbol(const uint32_t parameterId, char* const str
(void)parameterId;
}

void CarlaPlugin::getParameterText(const uint32_t parameterId, char* const strBuf)
void CarlaPlugin::getParameterText(const uint32_t parameterId, char* const strBuf) const
{
CARLA_ASSERT(parameterId < parameterCount());
CARLA_ASSERT(false); // this should never happen
@@ -526,7 +526,7 @@ void CarlaPlugin::getParameterText(const uint32_t parameterId, char* const strBu
(void)parameterId;
}

void CarlaPlugin::getParameterUnit(const uint32_t parameterId, char* const strBuf)
void CarlaPlugin::getParameterUnit(const uint32_t parameterId, char* const strBuf) const
{
CARLA_ASSERT(parameterId < parameterCount());
*strBuf = '\0';
@@ -536,7 +536,7 @@ void CarlaPlugin::getParameterUnit(const uint32_t parameterId, char* const strBu
(void)parameterId;
}

void CarlaPlugin::getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf)
void CarlaPlugin::getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf) const
{
CARLA_ASSERT(parameterId < parameterCount());
CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId));
@@ -549,7 +549,7 @@ void CarlaPlugin::getParameterScalePointLabel(const uint32_t parameterId, const
(void)scalePointId;
}

void CarlaPlugin::getProgramName(const uint32_t index, char* const strBuf)
void CarlaPlugin::getProgramName(const uint32_t index, char* const strBuf) const
{
CARLA_ASSERT(index < pData->prog.count);
CARLA_ASSERT(pData->prog.names[index] != nullptr);
@@ -560,7 +560,7 @@ void CarlaPlugin::getProgramName(const uint32_t index, char* const strBuf)
*strBuf = '\0';
}

void CarlaPlugin::getMidiProgramName(const uint32_t index, char* const strBuf)
void CarlaPlugin::getMidiProgramName(const uint32_t index, char* const strBuf) const
{
CARLA_ASSERT(index < pData->midiprog.count);
CARLA_ASSERT(pData->midiprog.data[index].name != nullptr);
@@ -571,7 +571,7 @@ void CarlaPlugin::getMidiProgramName(const uint32_t index, char* const strBuf)
*strBuf = '\0';
}

void CarlaPlugin::getParameterCountInfo(uint32_t* const ins, uint32_t* const outs, uint32_t* const total)
void CarlaPlugin::getParameterCountInfo(uint32_t* const ins, uint32_t* const outs, uint32_t* const total) const
{
CARLA_ASSERT(ins != nullptr);
CARLA_ASSERT(outs != nullptr);


+ 12
- 2
source/backend/standalone/CarlaStandalone.cpp View File

@@ -34,6 +34,10 @@
# include <QtGui/QApplication>
#endif

#if ! (defined(DEBUG) || defined(WANT_LOGS) || defined(BUILD_ANSI_TEST))
# define WANT_LOGS
#endif

namespace CB = CarlaBackend;

using CB::CarlaEngine;
@@ -68,6 +72,12 @@ struct CarlaBackendStandalone {
~CarlaBackendStandalone()
{
CARLA_ASSERT(engine == nullptr);

if (needsInit)
{
CARLA_ASSERT(app == nullptr);
CARLA_ASSERT(style == nullptr);
}
}

void init()
@@ -126,7 +136,7 @@ struct CarlaBackendStandalone {
CARLA_DECLARE_NON_COPY_STRUCT(CarlaBackendStandalone)
};

#ifndef DEBUG
#ifdef WANT_LOGS
static CarlaLogThread gLogThread;
#endif
static CarlaBackendStandalone gStandalone;
@@ -513,7 +523,7 @@ void carla_set_engine_callback(CarlaCallbackFunc func, void* ptr)
if (gStandalone.engine != nullptr)
gStandalone.engine->setCallback(func, ptr);

#ifndef DEBUG
#ifdef WANT_LOGS
gLogThread.setCallback(func, ptr);
#endif
}


+ 0
- 1
source/modules/utils/CarlaLogThread.hpp View File

@@ -151,7 +151,6 @@ private:
void* fCallbackPtr;
CarlaString fOldBuffer;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaLogThread)
};



+ 19
- 1
source/tests/ANSI.cpp View File

@@ -77,7 +77,7 @@
#if ANSI_TEST_N == 2
// Carla Standalone
#include "CarlaStandalone.hpp"
#include "standalone/CarlaStandalone.cpp"
#include "CarlaUtils.hpp"
#endif

// #include "plugin/CarlaPluginThread.hpp"
@@ -591,6 +591,24 @@ int main()
assert(obj.count == 2); // List fRetValue + t1
}
// ANSI_TEST_N == 1
#endif

#if ANSI_TEST_N == 2
carla_stdout("NOTICE LICENSE:");
carla_stdout(carla_get_extended_license_text());
carla_stdout("");

carla_stdout("FILETYPES:");
carla_stdout(carla_get_supported_file_types());
carla_stdout("");

carla_engine_init("beh", "bah");
carla_stdout(carla_get_last_error());

carla_engine_close();
carla_stdout(carla_get_last_error());

// ANSI_TEST_N == 2
#endif

return 0;


+ 7
- 6
source/tests/Makefile View File

@@ -41,8 +41,8 @@ all: $(TARGETS) RUN

# --------------------------------------------------------------

ANSI: ANSI.cpp
$(CXX) $^ $(BUILD_CXX_FLAGS) $(ANSI_CXX_FLAGS) $(LINK_FLAGS) -pthread -lpthread -o $@
ANSI: ANSI.cpp ../backend/standalone/CarlaStandalone.cpp.o CarlaBackendDummy.cpp.o ../modules/theme.a
$(CXX) $^ $(BUILD_CXX_FLAGS) $(ANSI_CXX_FLAGS) $(LINK_FLAGS) -L/opt/kxstudio/lib -lQtCore -lQtGui -llo -o $@

CarlaString: CarlaString.cpp ../modules/utils/CarlaString.hpp
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@
@@ -71,10 +71,11 @@ RUN: $(TARGETS)

# --------------------------------------------------------------

resources.cpp.o: ../../resources/resources.qrc
%.cpp.o: %.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) $(ANSI_CXX_FLAGS) -c -o $@

resources.cpp: ../../resources/resources.qrc
$(RCC) $< -o resources.cpp
$(CXX) resources.cpp $(BUILD_CXX_FLAGS) -c -o $@
rm resources.cpp

../modules/%.a:
$(MAKE) -C ../modules $*
@@ -82,7 +83,7 @@ resources.cpp.o: ../../resources/resources.qrc
# --------------------------------------------------------------

clean:
rm -f *.o $(TARGETS)
rm -f *.o resources.cpp $(TARGETS)

debug:
$(MAKE) DEBUG=true

Loading…
Cancel
Save