Browse Source

More bridge work

tags/1.9.4
falkTX 11 years ago
parent
commit
7e5ad021da
12 changed files with 279 additions and 140 deletions
  1. +2
    -1
      source/backend/engine/CarlaEngineJack.cpp
  2. +1
    -1
      source/backend/plugin/BridgePlugin.cpp
  3. +6
    -0
      source/backend/plugin/DssiPlugin.cpp
  4. +9
    -0
      source/backend/plugin/FluidSynthPlugin.cpp
  5. +6
    -0
      source/backend/plugin/LadspaPlugin.cpp
  6. +6
    -0
      source/backend/plugin/Lv2Plugin.cpp
  7. +6
    -0
      source/backend/plugin/NativePlugin.cpp
  8. +1
    -4
      source/backend/plugin/VstPlugin.cpp
  9. +5
    -15
      source/bridges/CarlaBridgePlugin.cpp
  10. +152
    -116
      source/libs/jackbridge/JackBridge1.cpp
  11. +82
    -0
      source/libs/jackbridge/JackBridge2.cpp
  12. +3
    -3
      source/libs/jackbridge/Makefile

+ 2
- 1
source/backend/engine/CarlaEngineJack.cpp View File

@@ -22,7 +22,8 @@
#ifdef JACKBRIDGE_EXPORT
# include "jackbridge/JackBridge.hpp"
#else
# include "jackbridge/JackBridge.cpp"
# include "jackbridge/JackBridge1.cpp"
# include "jackbridge/JackBridge2.cpp"
#endif

#include <cmath>


+ 1
- 1
source/backend/plugin/BridgePlugin.cpp View File

@@ -866,7 +866,7 @@ public:
fParams = nullptr;
}

CARLA_SAFE_ASSERT_INT2(pTotal < (int32_t)kData->engine->getOptions().maxParameters, pTotal, kData->engine->getOptions().maxParameters);
CARLA_SAFE_ASSERT_INT2(pTotal < static_cast<int32_t>(kData->engine->getOptions().maxParameters), pTotal, kData->engine->getOptions().maxParameters);

const int32_t count(carla_min<int32_t>(pTotal, kData->engine->getOptions().maxParameters, 0));



+ 6
- 0
source/backend/plugin/DssiPlugin.cpp View File

@@ -1558,6 +1558,12 @@ public:
}
#endif
} // End of Post-processing
#else
for (i=0; i < kData->audioOut.count; ++i)
{
for (k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = fAudioOutBuffers[i][k];
}
#endif

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


+ 9
- 0
source/backend/plugin/FluidSynthPlugin.cpp View File

@@ -1365,6 +1365,15 @@ public:
}

} // End of Post-processing
#else
if (kUses16Outs)
{
for (i=0; i < kData->audioOut.count; ++i)
{
for (k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = fAudio16Buffers[i][k];
}
}
#endif

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


+ 6
- 0
source/backend/plugin/LadspaPlugin.cpp View File

@@ -1213,6 +1213,12 @@ public:
}
#endif
} // End of Post-processing
#else
for (i=0; i < kData->audioOut.count; ++i)
{
for (k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = fAudioOutBuffers[i][k];
}
#endif

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


+ 6
- 0
source/backend/plugin/Lv2Plugin.cpp View File

@@ -2875,6 +2875,12 @@ public:
}
#endif
} // End of Post-processing
#else
for (i=0; i < kData->audioOut.count; ++i)
{
for (k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = fAudioOutBuffers[i][k];
}
#endif

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


+ 6
- 0
source/backend/plugin/NativePlugin.cpp View File

@@ -1745,6 +1745,12 @@ public:
}

} // End of Post-processing
#else
for (i=0; i < kData->audioOut.count; ++i)
{
for (k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = fAudioOutBuffers[i][k];
}
#endif

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


+ 1
- 4
source/backend/plugin/VstPlugin.cpp View File

@@ -2228,9 +2228,6 @@ public:
dispatcher(effSetBlockSize, 0, kData->engine->getBufferSize(), nullptr, 0.0f);
dispatcher(effSetProcessPrecision, 0, kVstProcessPrecision32, nullptr, 0.0f);

dispatcher(effStopProcess, 0, 0, nullptr, 0.0f);
dispatcher(effMainsChanged, 0, 0, nullptr, 0.0f);

if (dispatcher(effGetVstVersion, 0, 0, nullptr, 0.0f) < kVstVersion)
fHints |= PLUGIN_USES_OLD_VSTSDK;

@@ -2283,7 +2280,7 @@ public:

// load settings
kData->idStr = "VST/";
kData->idStr += std::strrchr(filename, OS_SEP)+1;
kData->idStr += std::strrchr(filename, OS_SEP)+1; // FIXME!
kData->idStr += "/";
kData->idStr += CarlaString(uniqueId());
fOptions = kData->loadSettings(fOptions, availableOptions());


+ 5
- 15
source/bridges/CarlaBridgePlugin.cpp View File

@@ -18,6 +18,7 @@
#include "CarlaBridgeClient.hpp"
#include "CarlaBridgeToolkit.hpp"

#include "CarlaBackendUtils.hpp"
#include "CarlaBridgeUtils.hpp"
#include "CarlaStandalone.hpp"
#include "CarlaEngine.hpp"
@@ -321,8 +322,7 @@ protected:
}
else
{
// hide gui
//sendOscConfigure();
// show-gui button
fEngine->osc_send_bridge_configure(CARLA_BRIDGE_MSG_HIDE_GUI, "");
}
break;
@@ -484,19 +484,9 @@ int main(int argc, char* argv[])
std::strncpy(bridgeBaseControlName, argv[6]+6, 6);
}

CarlaBackend::PluginType itype;

if (std::strcmp(stype, "LADSPA") == 0)
itype = CarlaBackend::PLUGIN_LADSPA;
else if (std::strcmp(stype, "DSSI") == 0)
itype = CarlaBackend::PLUGIN_DSSI;
else if (std::strcmp(stype, "LV2") == 0)
itype = CarlaBackend::PLUGIN_LV2;
else if (std::strcmp(stype, "VST") == 0)
itype = CarlaBackend::PLUGIN_VST;
else if (std::strcmp(stype, "VST3") == 0)
itype = CarlaBackend::PLUGIN_VST3;
else
CarlaBackend::PluginType itype(CarlaBackend::getPluginTypeFromString(stype));

if (itype == CarlaBackend::PLUGIN_NONE)
{
carla_stderr("Invalid plugin type '%s'", stype);
return 1;


source/libs/jackbridge/JackBridge.cpp → source/libs/jackbridge/JackBridge1.cpp View File

@@ -1,5 +1,5 @@
/*
* JackBridge
* JackBridge (Part 1, JACK functions)
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
@@ -16,22 +16,7 @@

#include "JackBridge.hpp"

#include <stdlib.h>
#include <stdio.h>

#ifndef JACKBRIDGE_DUMMY
# include <semaphore.h>
# include <sys/time.h>
#endif

#ifdef __WINE__
struct timespec { // FIXME!
__time_t tv_sec; /* Seconds. */
long int tv_nsec; /* Nanoseconds. */
};
#endif

#ifndef JACKBRIDGE_DIRECT
#if ! (defined(JACKBRIDGE_DIRECT) || defined(JACKBRIDGE_DUMMY))

#include "CarlaLibUtils.hpp"

@@ -203,13 +188,13 @@ struct JackBridge {
transport_stop_ptr(nullptr),
transport_query_ptr(nullptr)
{
#if defined(CARLA_OS_MAC)
const char* const filename = "libjack.dylib";
#elif defined(CARLA_OS_WIN)
const char* const filename = "libjack.dll";
#else
const char* const filename = "libjack.so.0";
#endif
# if defined(CARLA_OS_MAC)
const char* const filename("libjack.dylib");
# elif defined(CARLA_OS_WIN)
const char* const filename("libjack.dll");
# else
const char* const filename("libjack.so.0");
# endif

lib = lib_open(filename);

@@ -296,7 +281,9 @@ static JackBridge bridge;

const char* jackbridge_get_version_string()
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_get_version_string();
#else
if (bridge.get_version_string_ptr != nullptr)
@@ -307,7 +294,9 @@ const char* jackbridge_get_version_string()

jack_client_t* jackbridge_client_open(const char* client_name, jack_options_t options, jack_status_t* status, ...)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_client_open(client_name, options, status);
#else
if (bridge.client_open_ptr != nullptr)
@@ -318,9 +307,13 @@ jack_client_t* jackbridge_client_open(const char* client_name, jack_options_t op

const char* jackbridge_client_rename(jack_client_t* client, const char* new_name)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
//return jack_client_rename(client, new_name);
return nullptr;

// unused, for now
(void)client;
(void)new_name;
#else
@@ -334,7 +327,9 @@ const char* jackbridge_client_rename(jack_client_t* client, const char* new_name

bool jackbridge_client_close(jack_client_t* client)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_client_close(client) == 0);
#else
if (bridge.client_close_ptr != nullptr)
@@ -345,7 +340,9 @@ bool jackbridge_client_close(jack_client_t* client)

int jackbridge_client_name_size()
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return 0;
#elif JACKBRIDGE_DIRECT
return jack_client_name_size();
#else
if (bridge.client_name_size_ptr != nullptr)
@@ -356,7 +353,9 @@ int jackbridge_client_name_size()

char* jackbridge_get_client_name(jack_client_t* client)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_get_client_name(client);
#else
if (bridge.get_client_name_ptr != nullptr)
@@ -369,7 +368,9 @@ char* jackbridge_get_client_name(jack_client_t* client)

bool jackbridge_activate(jack_client_t* client)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_activate(client) == 0);
#else
if (bridge.activate_ptr != nullptr)
@@ -380,7 +381,9 @@ bool jackbridge_activate(jack_client_t* client)

bool jackbridge_deactivate(jack_client_t* client)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_deactivate(client) == 0);
#else
if (bridge.deactivate_ptr != nullptr)
@@ -391,7 +394,8 @@ bool jackbridge_deactivate(jack_client_t* client)

void jackbridge_on_shutdown(jack_client_t* client, JackShutdownCallback shutdown_callback, void* arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
#elif JACKBRIDGE_DIRECT
jack_on_shutdown(client, shutdown_callback, arg);
#else
if (bridge.on_shutdown_ptr != nullptr)
@@ -401,7 +405,9 @@ void jackbridge_on_shutdown(jack_client_t* client, JackShutdownCallback shutdown

bool jackbridge_set_process_callback(jack_client_t* client, JackProcessCallback process_callback, void* arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_set_process_callback(client, process_callback, arg) == 0);
#else
if (bridge.set_process_callback_ptr != nullptr)
@@ -412,7 +418,9 @@ bool jackbridge_set_process_callback(jack_client_t* client, JackProcessCallback

bool jackbridge_set_freewheel_callback(jack_client_t* client, JackFreewheelCallback freewheel_callback, void* arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_set_freewheel_callback(client, freewheel_callback, arg) == 0);
#else
if (bridge.set_freewheel_callback_ptr != nullptr)
@@ -423,7 +431,9 @@ bool jackbridge_set_freewheel_callback(jack_client_t* client, JackFreewheelCallb

bool jackbridge_set_buffer_size_callback(jack_client_t* client, JackBufferSizeCallback bufsize_callback, void* arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_set_buffer_size_callback(client, bufsize_callback, arg) == 0);
#else
if (bridge.set_buffer_size_callback_ptr != nullptr)
@@ -434,7 +444,9 @@ bool jackbridge_set_buffer_size_callback(jack_client_t* client, JackBufferSizeCa

bool jackbridge_set_sample_rate_callback(jack_client_t* client, JackSampleRateCallback srate_callback, void* arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_set_sample_rate_callback(client, srate_callback, arg) == 0);
#else
if (bridge.set_sample_rate_callback_ptr != nullptr)
@@ -445,7 +457,9 @@ bool jackbridge_set_sample_rate_callback(jack_client_t* client, JackSampleRateCa

bool jackbridge_set_client_registration_callback(jack_client_t* client, JackClientRegistrationCallback registration_callback, void* arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_set_client_registration_callback(client, registration_callback, arg) == 0);
#else
if (bridge.set_client_registration_callback_ptr != nullptr)
@@ -454,9 +468,11 @@ bool jackbridge_set_client_registration_callback(jack_client_t* client, JackClie
#endif
}

bool jackbridge_set_port_registration_callback (jack_client_t* client, JackPortRegistrationCallback registration_callback, void *arg)
bool jackbridge_set_port_registration_callback(jack_client_t* client, JackPortRegistrationCallback registration_callback, void *arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_set_port_registration_callback(client, registration_callback, arg) == 0);
#else
if (bridge.set_port_registration_callback_ptr != nullptr)
@@ -465,9 +481,11 @@ bool jackbridge_set_port_registration_callback (jack_client_t* client, JackPortR
#endif
}

bool jackbridge_set_port_connect_callback (jack_client_t* client, JackPortConnectCallback connect_callback, void* arg)
bool jackbridge_set_port_connect_callback(jack_client_t* client, JackPortConnectCallback connect_callback, void* arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_set_port_connect_callback(client, connect_callback, arg) == 0);
#else
if (bridge.set_port_connect_callback_ptr != nullptr)
@@ -476,9 +494,11 @@ bool jackbridge_set_port_connect_callback (jack_client_t* client, JackPortConnec
#endif
}

bool jackbridge_set_port_rename_callback (jack_client_t* client, JackPortRenameCallback rename_callback, void* arg)
bool jackbridge_set_port_rename_callback(jack_client_t* client, JackPortRenameCallback rename_callback, void* arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_set_port_rename_callback(client, rename_callback, arg) == 0);
#else
if (bridge.set_port_rename_callback_ptr != nullptr)
@@ -489,7 +509,9 @@ bool jackbridge_set_port_rename_callback (jack_client_t* client, JackPortRenameC

bool jackbridge_set_latency_callback(jack_client_t* client, JackLatencyCallback latency_callback, void* arg)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_set_latency_callback(client, latency_callback, arg) == 0);
#else
if (bridge.set_latency_callback_ptr != nullptr)
@@ -502,7 +524,9 @@ bool jackbridge_set_latency_callback(jack_client_t* client, JackLatencyCallback

jack_nframes_t jackbridge_get_sample_rate(jack_client_t* client)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return 0;
#elif JACKBRIDGE_DIRECT
return jack_get_sample_rate(client);
#else
if (bridge.get_sample_rate_ptr != nullptr)
@@ -513,7 +537,9 @@ jack_nframes_t jackbridge_get_sample_rate(jack_client_t* client)

jack_nframes_t jackbridge_get_buffer_size(jack_client_t* client)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return 0;
#elif JACKBRIDGE_DIRECT
return jack_get_buffer_size(client);
#else
if (bridge.get_buffer_size_ptr != nullptr)
@@ -524,7 +550,9 @@ jack_nframes_t jackbridge_get_buffer_size(jack_client_t* client)

jack_port_t* jackbridge_port_register(jack_client_t* client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_port_register(client, port_name, port_type, flags, buffer_size);
#else
if (bridge.port_register_ptr != nullptr)
@@ -535,7 +563,9 @@ jack_port_t* jackbridge_port_register(jack_client_t* client, const char* port_na

bool jackbridge_port_unregister(jack_client_t* client, jack_port_t* port)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_port_unregister(client, port) == 0);
#else
if (bridge.port_unregister_ptr != nullptr)
@@ -546,7 +576,9 @@ bool jackbridge_port_unregister(jack_client_t* client, jack_port_t* port)

void* jackbridge_port_get_buffer(jack_port_t* port, jack_nframes_t nframes)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_port_get_buffer(port, nframes);
#else
if (bridge.port_get_buffer_ptr != nullptr)
@@ -559,7 +591,9 @@ void* jackbridge_port_get_buffer(jack_port_t* port, jack_nframes_t nframes)

const char* jackbridge_port_name(const jack_port_t* port)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_port_name(port);
#else
if (bridge.port_name_ptr != nullptr)
@@ -570,7 +604,9 @@ const char* jackbridge_port_name(const jack_port_t* port)

const char* jackbridge_port_short_name(const jack_port_t* port)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_port_short_name(port);
#else
if (bridge.port_short_name_ptr != nullptr)
@@ -581,7 +617,9 @@ const char* jackbridge_port_short_name(const jack_port_t* port)

int jackbridge_port_flags(const jack_port_t* port)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return 0;
#elif JACKBRIDGE_DIRECT
return jack_port_flags(port);
#else
if (bridge.port_flags_ptr != nullptr)
@@ -592,7 +630,9 @@ int jackbridge_port_flags(const jack_port_t* port)

const char* jackbridge_port_type(const jack_port_t* port)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_port_type(port);
#else
if (bridge.port_type_ptr != nullptr)
@@ -603,7 +643,9 @@ const char* jackbridge_port_type(const jack_port_t* port)

const char** jackbridge_port_get_connections(const jack_port_t* port)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_port_get_connections(port);
#else
if (bridge.port_get_connections_ptr != nullptr)
@@ -616,7 +658,9 @@ const char** jackbridge_port_get_connections(const jack_port_t* port)

bool jackbridge_port_set_name(jack_port_t* port, const char* port_name)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_port_set_name(port, port_name) == 0);
#else
if (bridge.port_set_name_ptr != nullptr)
@@ -627,7 +671,9 @@ bool jackbridge_port_set_name(jack_port_t* port, const char* port_name)

bool jackbridge_connect(jack_client_t* client, const char* source_port, const char* destination_port)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_connect(client, source_port, destination_port) == 0);
#else
if (bridge.connect_ptr != nullptr)
@@ -638,7 +684,9 @@ bool jackbridge_connect(jack_client_t* client, const char* source_port, const ch

bool jackbridge_disconnect(jack_client_t* client, const char* source_port, const char* destination_port)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_disconnect(client, source_port, destination_port) == 0);
#else
if (bridge.disconnect_ptr != nullptr)
@@ -649,7 +697,9 @@ bool jackbridge_disconnect(jack_client_t* client, const char* source_port, const

int jackbridge_port_name_size()
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return 0;
#elif JACKBRIDGE_DIRECT
return jack_port_name_size();
#else
if (bridge.port_name_size_ptr != nullptr)
@@ -660,7 +710,8 @@ int jackbridge_port_name_size()

void jackbridge_port_get_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
#elif JACKBRIDGE_DIRECT
return jack_port_get_latency_range(port, mode, range);
#else
if (bridge.port_get_latency_range_ptr != nullptr)
@@ -670,7 +721,8 @@ void jackbridge_port_get_latency_range(jack_port_t* port, jack_latency_callback_

void jackbridge_port_set_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
#elif JACKBRIDGE_DIRECT
return jack_port_set_latency_range(port, mode, range);
#else
if (bridge.port_set_latency_range_ptr != nullptr)
@@ -680,7 +732,9 @@ void jackbridge_port_set_latency_range(jack_port_t* port, jack_latency_callback_

bool jackbridge_recompute_total_latencies(jack_client_t* client)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_recompute_total_latencies(client) == 0);
#else
if (bridge.recompute_total_latencies_ptr != nullptr)
@@ -691,7 +745,9 @@ bool jackbridge_recompute_total_latencies(jack_client_t* client)

const char** jackbridge_get_ports(jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_get_ports(client, port_name_pattern, type_name_pattern, flags);
#else
if (bridge.get_ports_ptr != nullptr)
@@ -702,7 +758,9 @@ const char** jackbridge_get_ports(jack_client_t* client, const char* port_name_p

jack_port_t* jackbridge_port_by_name(jack_client_t* client, const char* port_name)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_port_by_name(client, port_name);
#else
if (bridge.port_by_name_ptr != nullptr)
@@ -713,7 +771,9 @@ jack_port_t* jackbridge_port_by_name(jack_client_t* client, const char* port_nam

jack_port_t* jackbridge_port_by_id(jack_client_t* client, jack_port_id_t port_id)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_port_by_id(client, port_id);
#else
if (bridge.port_by_id_ptr != nullptr)
@@ -726,14 +786,15 @@ jack_port_t* jackbridge_port_by_id(jack_client_t* client, jack_port_id_t port_id

void jackbridge_free(void* ptr)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
#elif JACKBRIDGE_DIRECT
return jack_free(ptr);
#else
if (bridge.free_ptr != nullptr)
return bridge.free_ptr(ptr);

// just in case
free(ptr);
std::free(ptr);
#endif
}

@@ -741,7 +802,9 @@ void jackbridge_free(void* ptr)

uint32_t jackbridge_midi_get_event_count(void* port_buffer)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return 0;
#elif JACKBRIDGE_DIRECT
return jack_midi_get_event_count(port_buffer);
#else
if (bridge.midi_get_event_count_ptr != nullptr)
@@ -752,7 +815,9 @@ uint32_t jackbridge_midi_get_event_count(void* port_buffer)

bool jackbridge_midi_event_get(jack_midi_event_t* event, void* port_buffer, uint32_t event_index)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_midi_event_get(event, port_buffer, event_index) == 0);
#else
if (bridge.midi_event_get_ptr != nullptr)
@@ -763,7 +828,8 @@ bool jackbridge_midi_event_get(jack_midi_event_t* event, void* port_buffer, uint

void jackbridge_midi_clear_buffer(void* port_buffer)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
#elif JACKBRIDGE_DIRECT
return jack_midi_clear_buffer(port_buffer);
#else
if (bridge.midi_clear_buffer_ptr != nullptr)
@@ -773,7 +839,9 @@ void jackbridge_midi_clear_buffer(void* port_buffer)

bool jackbridge_midi_event_write(void* port_buffer, jack_nframes_t time, const jack_midi_data_t* data, size_t data_size)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return false;
#elif JACKBRIDGE_DIRECT
return (jack_midi_event_write(port_buffer, time, data, data_size) == 0);
#else
if (bridge.midi_event_write_ptr != nullptr)
@@ -784,7 +852,9 @@ bool jackbridge_midi_event_write(void* port_buffer, jack_nframes_t time, const j

jack_midi_data_t* jackbridge_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return nullptr;
#elif JACKBRIDGE_DIRECT
return jack_midi_event_reserve(port_buffer, time, data_size);
#else
if (bridge.midi_event_reserve_ptr != nullptr)
@@ -797,7 +867,9 @@ jack_midi_data_t* jackbridge_midi_event_reserve(void* port_buffer, jack_nframes_

int jackbridge_transport_locate(jack_client_t* client, jack_nframes_t frame)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return 0;
#elif JACKBRIDGE_DIRECT
return (jack_transport_locate(client, frame) == 0);
#else
if (bridge.transport_locate_ptr != nullptr)
@@ -808,7 +880,8 @@ int jackbridge_transport_locate(jack_client_t* client, jack_nframes_t frame)

void jackbridge_transport_start(jack_client_t* client)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
#elif JACKBRIDGE_DIRECT
jack_transport_start(client);
#else
if (bridge.transport_start_ptr != nullptr)
@@ -818,7 +891,8 @@ void jackbridge_transport_start(jack_client_t* client)

void jackbridge_transport_stop(jack_client_t* client)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
#elif JACKBRIDGE_DIRECT
jack_transport_stop(client);
#else
if (bridge.transport_stop_ptr != nullptr)
@@ -828,7 +902,9 @@ void jackbridge_transport_stop(jack_client_t* client)

jack_transport_state_t jackbridge_transport_query(const jack_client_t* client, jack_position_t* pos)
{
#ifdef JACKBRIDGE_DIRECT
#if JACKBRIDGE_DUMMY
return JackTransportStopped;
#elif JACKBRIDGE_DIRECT
return jack_transport_query(client, pos);
#else
if (bridge.transport_query_ptr != nullptr)
@@ -838,43 +914,3 @@ jack_transport_state_t jackbridge_transport_query(const jack_client_t* client, j
}

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

#ifdef JACKBRIDGE_DUMMY
bool jackbridge_sem_post(void* sem)
{
return false;
}

bool jackbridge_sem_timedwait(void* sem, int secs)
{
return false;
}
#else
bool jackbridge_sem_post(void* sem)
{
return (sem_post((sem_t*)sem) == 0);
}

bool jackbridge_sem_timedwait(void* sem, int secs)
{
# ifdef CARLA_OS_MAC
alarm(secs);
return (sem_wait((sem_t*)sem) == 0);
# else
timespec timeout;

# ifdef CARLA_OS_WIN
timeval now;
gettimeofday(&now, nullptr);
timeout.tv_sec = now.tv_sec;
timeout.tv_nsec = now.tv_usec * 1000;
# else
clock_gettime(CLOCK_REALTIME, &timeout);
# endif

timeout.tv_sec += secs;

return (sem_timedwait((sem_t*)sem, &timeout) == 0);
# endif
}
#endif

+ 82
- 0
source/libs/jackbridge/JackBridge2.cpp View File

@@ -0,0 +1,82 @@
/*
* JackBridge (Part 2, Semaphore functions)
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* 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 Lesser General Public License for more details.
*
* For a full copy of the license see the LGPL.txt file
*/

#include "CarlaDefines.hpp"

// don't include the whole JACK deal in this file
CARLA_EXPORT bool jackbridge_sem_post(void* sem);
CARLA_EXPORT bool jackbridge_sem_timedwait(void* sem, int secs);

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

#if JACKBRIDGE_DUMMY
bool jackbridge_sem_post(void*)
{
return false;
}

bool jackbridge_sem_timedwait(void*, int)
{
return false;
}
#else

#include <semaphore.h>

#ifdef __WINE__
# define _STRUCT_TIMEVAL 1
# define _SYS_SELECT_H 1
# include <bits/types.h>
struct timespec {
__time_t tv_sec; /* Seconds. */
long int tv_nsec; /* Nanoseconds. */
};
#endif

#ifdef CARLA_OS_WIN
# include <sys/time.h>
#else
# include <time.h>
#endif

bool jackbridge_sem_post(void* sem)
{
return (sem_post((sem_t*)sem) == 0);
}

bool jackbridge_sem_timedwait(void* sem, int secs)
{
# ifdef CARLA_OS_MAC
alarm(secs);
return (sem_wait((sem_t*)sem) == 0);
# else
timespec timeout;

# ifdef CARLA_OS_WIN
timeval now;
gettimeofday(&now, nullptr);
timeout.tv_sec = now.tv_sec;
timeout.tv_nsec = now.tv_usec * 1000;
# else
clock_gettime(CLOCK_REALTIME, &timeout);
# endif

timeout.tv_sec += secs;

return (sem_timedwait((sem_t*)sem, &timeout) == 0);
# endif
}
#endif

+ 3
- 3
source/libs/jackbridge/Makefile View File

@@ -19,17 +19,17 @@ else
LINK_FLAGS += -shared
endif

WIN_BUILD_FLAGS = $(BUILD_CXX_FLAGS) -DJACKBRIDGE_DUMMY -w
WIN_BUILD_FLAGS = $(BUILD_CXX_FLAGS) -DJACKBRIDGE_DUMMY=1 -w
WIN_32BIT_FLAGS = $(32BIT_FLAGS)
WIN_64BIT_FLAGS = $(64BIT_FLAGS)
WIN_LINK_FLAGS = $(LINK_FLAGS)

WINE_BUILD_FLAGS = $(BUILD_CXX_FLAGS) -DJACKBRIDGE_DIRECT -fPIC
WINE_BUILD_FLAGS = $(BUILD_CXX_FLAGS) -DJACKBRIDGE_DIRECT=1 -fPIC
WINE_32BIT_FLAGS = $(32BIT_FLAGS) -L/usr/lib32/wine -L/usr/lib/i386-linux-gnu/wine
WINE_64BIT_FLAGS = $(64BIT_FLAGS) -L/usr/lib64/wine -L/usr/lib/x86_64-linux-gnu/wine
WINE_LINK_FLAGS = $(LINK_FLAGS) -ldl -lrt -lpthread -ljack

OBJS = JackBridge.cpp
OBJS = JackBridge2.cpp JackBridge1.cpp

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



Loading…
Cancel
Save