Browse Source

Continue cleanup

tags/1.9.4
falkTX 11 years ago
parent
commit
b20ff6dae0
7 changed files with 519 additions and 475 deletions
  1. +1
    -3
      source/backend/CarlaPlugin.hpp
  2. +2
    -2
      source/backend/CarlaStandalone.hpp
  3. +454
    -445
      source/backend/standalone/CarlaStandalone.cpp
  4. +8
    -1
      source/carla.py
  5. +2
    -2
      source/carla_backend.py
  6. +36
    -21
      source/modules/utils/CarlaLogThread.hpp
  7. +16
    -1
      source/tests/ANSI.cpp

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

@@ -20,15 +20,13 @@

#include "CarlaBackend.hpp"
#include "CarlaString.hpp"
#include "CarlaNative.h"

// Avoid including extra libs here
typedef void* lo_address;
#ifndef LADSPA_RDF_HPP_INCLUDED
struct LADSPA_RDF_Descriptor;
#endif
#ifndef CARLA_NATIVE_H_INCLUDED
struct PluginDescriptor;
#endif

CARLA_BACKEND_START_NAMESPACE



+ 2
- 2
source/backend/CarlaStandalone.hpp View File

@@ -230,7 +230,7 @@ struct CarlaScalePointInfo {
*/
struct CarlaTransportInfo {
bool playing;
uint32_t frame;
uint64_t frame;
int32_t bar;
int32_t beat;
int32_t tick;
@@ -384,7 +384,7 @@ CARLA_EXPORT void carla_transport_relocate(uint32_t frames);
/*!
* Get the current transport frame.
*/
CARLA_EXPORT uint32_t carla_get_current_transport_frame();
CARLA_EXPORT uint64_t carla_get_current_transport_frame();

/*!
* Get the engine transport information.


+ 454
- 445
source/backend/standalone/CarlaStandalone.cpp
File diff suppressed because it is too large
View File


+ 8
- 1
source/carla.py View File

@@ -2353,7 +2353,6 @@ if __name__ == '__main__':

# Init backend
Carla.host = Host(libName)
Carla.host.set_engine_callback(engineCallback)

if NSM_URL:
Carla.host.nsm_announce(NSM_URL, appName, os.getpid())
@@ -2414,6 +2413,9 @@ if __name__ == '__main__':
# Create GUI and start engine
Carla.gui = CarlaMainW()

# Only now we're ready to handle events
Carla.host.set_engine_callback(engineCallback)

# Set-up custom signal handling
setUpSignals()

@@ -2427,5 +2429,10 @@ if __name__ == '__main__':
# App-Loop
ret = app.exec_()

# Destroy GUI
tmp = Carla.gui
Carla.gui = None
del tmp

# Exit properly
sys.exit(ret)

+ 2
- 2
source/carla_backend.py View File

@@ -389,7 +389,7 @@ class CarlaScalePointInfo(Structure):
class CarlaTransportInfo(Structure):
_fields_ = [
("playing", c_bool),
("frame", c_uint32),
("frame", c_uint64),
("bar", c_int32),
("beat", c_int32),
("tick", c_int32),
@@ -475,7 +475,7 @@ class Host(object):
self.lib.carla_transport_relocate.restype = None

self.lib.carla_get_current_transport_frame.argtypes = None
self.lib.carla_get_current_transport_frame.restype = c_uint32
self.lib.carla_get_current_transport_frame.restype = c_uint64

self.lib.carla_get_transport_info.argtypes = None
self.lib.carla_get_transport_info.restype = POINTER(CarlaTransportInfo)


+ 36
- 21
source/modules/utils/CarlaLogThread.hpp View File

@@ -19,21 +19,22 @@
#define CARLA_LOG_THREAD_HPP_INCLUDED

#include "CarlaBackend.hpp"
#include "CarlaJuceUtils.hpp"
#include "CarlaString.hpp"

#include <fcntl.h>
#include <QtCore/QThread>

CARLA_BACKEND_START_NAMESPACE
using CarlaBackend::CallbackFunc;

// -----------------------------------------------------------------------
// Log thread

class LogThread : public QThread
class CarlaLogThread : public QThread
{
public:
LogThread()
: fStop(false),
CarlaLogThread()
: QThread(nullptr),
fStop(false),
fCallback(nullptr),
fCallbackPtr(nullptr)
{
@@ -48,10 +49,17 @@ public:
dup2(fPipe[1], STDERR_FILENO);

fcntl(fPipe[0], F_SETFL, O_NONBLOCK);

QThread::start(LowPriority);
}

~LogThread()
~CarlaLogThread()
{
fCallback = nullptr;
fCallbackPtr = nullptr;

stop();

fflush(stdout);
fflush(stderr);

@@ -59,14 +67,12 @@ public:
close(fPipe[1]);
}

void ready(CallbackFunc callback, void* callbackPtr)
void setCallback(CallbackFunc callback, void* callbackPtr)
{
CARLA_ASSERT(callback != nullptr);

fCallback = callback;
fCallbackPtr = callbackPtr;

start();
}

void stop()
@@ -80,23 +86,23 @@ public:
protected:
void run()
{
if (fCallback == nullptr)
return;

while (! fStop)
{
int i, r, lastRead;
size_t r, lastRead;
ssize_t r2; // to avoid sign/unsign conversions

static char bufTemp[1024+1] = { '\0' };
static char bufRead[1024+1];
static char bufSend[2048+1];

while ((r = read(fPipe[0], bufRead, sizeof(char)*1024)) > 0)
while ((r2 = read(fPipe[0], bufRead, sizeof(char)*1024)) > 0)
{
r = static_cast<size_t>(r2);

bufRead[r] = '\0';
lastRead = 0;

for (i=0; i < r; ++i)
for (size_t i=0; i < r; ++i)
{
CARLA_ASSERT(bufRead[i] != '\0');

@@ -109,14 +115,24 @@ protected:
lastRead = i;
bufTemp[0] = '\0';

fCallback(fCallbackPtr, CarlaBackend::CALLBACK_DEBUG, 0, 0, 0, 0.0f, bufSend);
if (fCallback != nullptr)
{
if (fOldBuffer.isNotEmpty())
{
fCallback(fCallbackPtr, CarlaBackend::CALLBACK_DEBUG, 0, 0, 0, 0.0f, (const char*)fOldBuffer);
fOldBuffer = nullptr;
}

fCallback(fCallbackPtr, CarlaBackend::CALLBACK_DEBUG, 0, 0, 0, 0.0f, bufSend);
}
else
fOldBuffer += bufSend;
}
}

CARLA_ASSERT(i == r);
CARLA_ASSERT(lastRead < r);

if (lastRead > 0 && lastRead < r-1)
if (lastRead > 0 && r > 0 && lastRead+1 < r)
{
std::strncpy(bufTemp, bufRead+lastRead, r-lastRead);
bufTemp[r-lastRead] = '\0';
@@ -133,13 +149,12 @@ private:

CallbackFunc fCallback;
void* fCallbackPtr;
CarlaString fOldBuffer;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LogThread)
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaLogThread)
};

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

CARLA_BACKEND_END_NAMESPACE

#endif // CARLA_LOG_THREAD_HPP_INCLUDED

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

@@ -21,6 +21,9 @@

#define RING_BUFFER_SIZE 48

#define ANSI_TEST_N 2

#if ANSI_TEST_N == 1
// includes
#include "CarlaDefines.hpp"
#include "CarlaMIDI.h"
@@ -68,13 +71,21 @@

// Carla Standalone API
#include "CarlaStandalone.hpp"
// ANSI_TEST_N == 1
#endif

#if ANSI_TEST_N == 2
// Carla Standalone
#include "CarlaStandalone.hpp"
#include "standalone/CarlaStandalone.cpp"
#endif

// // Carla Plugin
// #include "plugin/CarlaPluginThread.hpp"
// #include "plugin/CarlaPluginInternal.hpp"

// #include "standalone/CarlaStandalone.cpp"

#if ANSI_TEST_N == 1
// -----------------------------------------------------------------------

namespace CB = CarlaBackend;
@@ -84,11 +95,13 @@ int safe_assert_return_test(bool test)
CARLA_SAFE_ASSERT_RETURN(test, 1);
return 0;
}
#endif

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

int main()
{
#if ANSI_TEST_N == 1
// ladspa rdf
{
LADSPA_RDF_ScalePoint a;
@@ -577,6 +590,8 @@ int main()
obj = ListTester::getCounter();
assert(obj.count == 2); // List fRetValue + t1
}
// ANSI_TEST_N == 1
#endif

return 0;
}


Loading…
Cancel
Save