Browse Source

Add new files used in bridges

tags/1.9.4
falkTX 10 years ago
parent
commit
5421d02ceb
4 changed files with 960 additions and 0 deletions
  1. +142
    -0
      source/modules/jackbridge/JackBridge3.cpp
  2. +588
    -0
      source/modules/jackbridge/JackBridgeExport.cpp
  3. +3
    -0
      source/modules/jackbridge/JackBridgeExport.def
  4. +227
    -0
      source/modules/jackbridge/JackBridgeExport.hpp

+ 142
- 0
source/modules/jackbridge/JackBridge3.cpp View File

@@ -0,0 +1,142 @@
/*
* JackBridge (Part 3, Export)
* Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "JackBridgeExport.hpp"

#include "CarlaUtils.hpp"

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

#if defined(CARLA_OS_WIN) && ! defined(__WINE__)
# define JACKBRIDGE_EXPORT extern "C" __declspec (dllexport)
#else
# define JACKBRIDGE_EXPORT extern "C" __attribute__ ((visibility("default")))
#endif

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

JACKBRIDGE_EXPORT
const JackBridgeExportedFunctions* jackbridge_get_exported_functions()
{
static JackBridgeExportedFunctions funcs;
carla_zeroStruct(funcs);

funcs.unique1 = funcs.unique2 = 0xdeadf00d;

funcs.get_version_ptr = jackbridge_get_version;
funcs.get_version_string_ptr = jackbridge_get_version_string;
funcs.client_open_ptr = jackbridge_client_open;
funcs.client_close_ptr = jackbridge_client_close;
funcs.client_name_size_ptr = jackbridge_client_name_size;
funcs.get_client_name_ptr = jackbridge_get_client_name;
funcs.get_uuid_for_client_name_ptr = jackbridge_get_uuid_for_client_name;
funcs.get_client_name_by_uuid_ptr = jackbridge_get_client_name_by_uuid;
funcs.activate_ptr = jackbridge_activate;
funcs.deactivate_ptr = jackbridge_deactivate;
funcs.is_realtime_ptr = jackbridge_is_realtime;
funcs.set_thread_init_callback_ptr = jackbridge_set_thread_init_callback;
funcs.on_shutdown_ptr = jackbridge_on_shutdown;
funcs.on_info_shutdown_ptr = jackbridge_on_info_shutdown;
funcs.set_process_callback_ptr = jackbridge_set_process_callback;
funcs.set_freewheel_callback_ptr = jackbridge_set_freewheel_callback;
funcs.set_buffer_size_callback_ptr = jackbridge_set_buffer_size_callback;
funcs.set_sample_rate_callback_ptr = jackbridge_set_sample_rate_callback;
funcs.set_client_registration_callback_ptr = jackbridge_set_client_registration_callback;
funcs.set_port_registration_callback_ptr = jackbridge_set_port_registration_callback;
funcs.set_port_rename_callback_ptr = jackbridge_set_port_rename_callback;
funcs.set_port_connect_callback_ptr = jackbridge_set_port_connect_callback;
funcs.set_graph_order_callback_ptr = jackbridge_set_graph_order_callback;
funcs.set_xrun_callback_ptr = jackbridge_set_xrun_callback;
funcs.set_latency_callback_ptr = jackbridge_set_latency_callback;
funcs.set_freewheel_ptr = jackbridge_set_freewheel;
funcs.set_buffer_size_ptr = jackbridge_set_buffer_size;
funcs.get_sample_rate_ptr = jackbridge_get_sample_rate;
funcs.get_buffer_size_ptr = jackbridge_get_buffer_size;
funcs.cpu_load_ptr = jackbridge_cpu_load;
funcs.port_register_ptr = jackbridge_port_register;
funcs.port_unregister_ptr = jackbridge_port_unregister;
funcs.port_get_buffer_ptr = jackbridge_port_get_buffer;
funcs.port_name_ptr = jackbridge_port_name;
funcs.port_uuid_ptr = jackbridge_port_uuid;
funcs.port_short_name_ptr = jackbridge_port_short_name;
funcs.port_flags_ptr = jackbridge_port_flags;
funcs.port_type_ptr = jackbridge_port_type;
funcs.port_is_mine_ptr = jackbridge_port_is_mine;
funcs.port_connected_ptr = jackbridge_port_connected;
funcs.port_connected_to_ptr = jackbridge_port_connected_to;
funcs.port_get_connections_ptr = jackbridge_port_get_connections;
funcs.port_get_all_connections_ptr = jackbridge_port_get_all_connections;
funcs.port_set_name_ptr = jackbridge_port_set_name;
funcs.port_set_alias_ptr = jackbridge_port_set_alias;
funcs.port_unset_alias_ptr = jackbridge_port_unset_alias;
funcs.port_get_aliases_ptr = jackbridge_port_get_aliases;
funcs.port_request_monitor_ptr = jackbridge_port_request_monitor;
funcs.port_request_monitor_by_name_ptr = jackbridge_port_request_monitor_by_name;
funcs.port_ensure_monitor_ptr = jackbridge_port_ensure_monitor;
funcs.port_monitoring_input_ptr = jackbridge_port_monitoring_input;
funcs.connect_ptr = jackbridge_connect;
funcs.disconnect_ptr = jackbridge_disconnect;
funcs.port_disconnect_ptr = jackbridge_port_disconnect;
funcs.port_name_size_ptr = jackbridge_port_name_size;
funcs.port_type_size_ptr = jackbridge_port_type_size;
funcs.port_type_get_buffer_size_ptr = jackbridge_port_type_get_buffer_size;
funcs.port_get_latency_range_ptr = jackbridge_port_get_latency_range;
funcs.port_set_latency_range_ptr = jackbridge_port_set_latency_range;
funcs.recompute_total_latencies_ptr = jackbridge_recompute_total_latencies;
funcs.get_ports_ptr = jackbridge_get_ports;
funcs.port_by_name_ptr = jackbridge_port_by_name;
funcs.port_by_id_ptr = jackbridge_port_by_id;
funcs.free_ptr = jackbridge_free;
funcs.midi_get_event_count_ptr = jackbridge_midi_get_event_count;
funcs.midi_event_get_ptr = jackbridge_midi_event_get;
funcs.midi_clear_buffer_ptr = jackbridge_midi_clear_buffer;
funcs.midi_event_write_ptr = jackbridge_midi_event_write;
funcs.midi_event_reserve_ptr = jackbridge_midi_event_reserve;
funcs.release_timebase_ptr = jackbridge_release_timebase;
funcs.set_sync_callback_ptr = jackbridge_set_sync_callback;
funcs.set_sync_timeout_ptr = jackbridge_set_sync_timeout;
funcs.set_timebase_callback_ptr = jackbridge_set_timebase_callback;
funcs.transport_locate_ptr = jackbridge_transport_locate;
funcs.transport_query_ptr = jackbridge_transport_query;
funcs.get_current_transport_frame_ptr = jackbridge_get_current_transport_frame;
funcs.transport_reposition_ptr = jackbridge_transport_reposition;
funcs.transport_start_ptr = jackbridge_transport_start;
funcs.transport_stop_ptr = jackbridge_transport_stop;
funcs.set_property_ptr = jackbridge_set_property;
funcs.get_property_ptr = jackbridge_get_property;
funcs.free_description_ptr = jackbridge_free_description;
funcs.get_properties_ptr = jackbridge_get_properties;
funcs.get_all_properties_ptr = jackbridge_get_all_properties;
funcs.remove_property_ptr = jackbridge_remove_property;
funcs.remove_properties_ptr = jackbridge_remove_properties;
funcs.remove_all_properties_ptr = jackbridge_remove_all_properties;
funcs.set_property_change_callback_ptr = jackbridge_set_property_change_callback;
funcs.sem_init_ptr = jackbridge_sem_init;
funcs.sem_destroy_ptr = jackbridge_sem_destroy;
funcs.sem_post_ptr = jackbridge_sem_post;
funcs.sem_timedwait_ptr = jackbridge_sem_timedwait;
funcs.shm_is_valid_ptr = jackbridge_shm_is_valid;
funcs.shm_init_ptr = jackbridge_shm_init;
funcs.shm_attach_ptr = jackbridge_shm_attach;
funcs.shm_close_ptr = jackbridge_shm_close;
funcs.shm_map_ptr = jackbridge_shm_map;

carla_stdout("jackbridge_get_exported_functions called, ptr=%p", &funcs);

return &funcs;
}

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

+ 588
- 0
source/modules/jackbridge/JackBridgeExport.cpp View File

@@ -0,0 +1,588 @@
/*
* JackBridge (Part 3, Export)
* Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "JackBridgeExport.hpp"

#include "CarlaLibUtils.hpp"

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

class JackBridgeExported
{
public:
JackBridgeExported() noexcept
: lib(nullptr),
func(nullptr)
{
#ifdef CARLA_OS_WIN64
lib = LoadLibraryA("jackbridge-wine64.dll");
//lib = lib_open("jackbridge-wine64.dll");
#else
lib = LoadLibraryA("jackbridge-wine32.dll");
//lib = lib_open("jackbridge-wine32.dll");
#endif
CARLA_SAFE_ASSERT_RETURN(lib != nullptr,);

//func = (jackbridge_exported_function_type)lib_symbol(lib, "jackbridge_get_exported_functions");
func = (jackbridge_exported_function_type)GetProcAddress(lib, "jackbridge_get_exported_functions");
CARLA_SAFE_ASSERT_RETURN(func != nullptr,);
}

~JackBridgeExported() noexcept
{
if (lib == nullptr)
return;
FreeLibrary(lib);
//lib_close(lib);
lib = nullptr;
func = nullptr;
}

static const JackBridgeExportedFunctions& getFunctions() noexcept
{
static JackBridgeExportedFunctions fallback;
carla_zeroStruct(fallback);
++fallback.unique2;

static const JackBridgeExported bridge;
CARLA_SAFE_ASSERT_RETURN(bridge.func != nullptr, fallback);

const JackBridgeExportedFunctions* const funcs(bridge.func());
CARLA_SAFE_ASSERT_RETURN(funcs != nullptr, fallback);
CARLA_SAFE_ASSERT_RETURN(funcs->unique1 != 0, fallback);
CARLA_SAFE_ASSERT_RETURN(funcs->unique1 == funcs->unique2, fallback);
CARLA_SAFE_ASSERT_RETURN(funcs->shm_map_ptr != nullptr, fallback);

carla_stdout("Got wine functions, ptr: %p; testcode: 0x%lx | 0x%lx", funcs, funcs->unique1, funcs->unique2);

#if 1
carla_stdout("Starting tests...");
carla_stdout("1. register a jack client");
jack_client_t* client = funcs->client_open_ptr("test", JackNoStartServer, nullptr);
carla_stdout("2. closing the jack client");
funcs->client_close_ptr(client);
#endif

return *funcs;
}

private:
HMODULE lib;
//void* lib;
jackbridge_exported_function_type func;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPY_CLASS(JackBridgeExported);
};

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

static const JackBridgeExportedFunctions& getBridgeInstance() noexcept
{
static const JackBridgeExportedFunctions& funcs(JackBridgeExported::getFunctions());
return funcs;
}

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

bool jackbridge_is_ok(void) noexcept
{
const JackBridgeExportedFunctions& instance(getBridgeInstance());
return (instance.unique1 != 0 && instance.unique1 == instance.unique2);
}

void jackbridge_get_version(int* major_ptr, int* minor_ptr, int* micro_ptr, int* proto_ptr)
{
return getBridgeInstance().get_version_ptr(major_ptr, minor_ptr, micro_ptr, proto_ptr);
}

const char* jackbridge_get_version_string(void)
{
return getBridgeInstance().get_version_string_ptr();
}

jack_client_t* jackbridge_client_open(const char* client_name, jack_options_t options, jack_status_t* status)
{
carla_stdout("client_open BEFORE %p 0x%x %p", client_name, options, status);
return getBridgeInstance().client_open_ptr(client_name, options, status);
}

bool jackbridge_client_close(jack_client_t* client)
{
return getBridgeInstance().client_close_ptr(client);
}

int jackbridge_client_name_size(void)
{
return getBridgeInstance().client_name_size_ptr();
}

char* jackbridge_get_client_name(jack_client_t* client)
{
return getBridgeInstance().get_client_name_ptr(client);
}

char* jackbridge_get_uuid_for_client_name(jack_client_t* client, const char* name)
{
return getBridgeInstance().get_uuid_for_client_name_ptr(client, name);
}

char* jackbridge_get_client_name_by_uuid(jack_client_t* client, const char* uuid)
{
return getBridgeInstance().get_client_name_by_uuid_ptr(client, uuid);
}

bool jackbridge_activate(jack_client_t* client)
{
return getBridgeInstance().activate_ptr(client);
}

bool jackbridge_deactivate(jack_client_t* client)
{
return getBridgeInstance().deactivate_ptr(client);
}

bool jackbridge_is_realtime(jack_client_t* client)
{
return getBridgeInstance().is_realtime_ptr(client);
}

bool jackbridge_set_thread_init_callback(jack_client_t* client, JackThreadInitCallback thread_init_callback, void* arg)
{
return getBridgeInstance().set_thread_init_callback_ptr(client, thread_init_callback, arg);
}

void jackbridge_on_shutdown(jack_client_t* client, JackShutdownCallback shutdown_callback, void* arg)
{
return getBridgeInstance().on_shutdown_ptr(client, shutdown_callback, arg);
}

void jackbridge_on_info_shutdown(jack_client_t* client, JackInfoShutdownCallback shutdown_callback, void* arg)
{
return getBridgeInstance().on_info_shutdown_ptr(client, shutdown_callback, arg);
}

bool jackbridge_set_process_callback(jack_client_t* client, JackProcessCallback process_callback, void* arg)
{
return getBridgeInstance().set_process_callback_ptr(client, process_callback, arg);
}

bool jackbridge_set_freewheel_callback(jack_client_t* client, JackFreewheelCallback freewheel_callback, void* arg)
{
return getBridgeInstance().set_freewheel_callback_ptr(client, freewheel_callback, arg);
}

bool jackbridge_set_buffer_size_callback(jack_client_t* client, JackBufferSizeCallback bufsize_callback, void* arg)
{
return getBridgeInstance().set_buffer_size_callback_ptr(client, bufsize_callback, arg);
}

bool jackbridge_set_sample_rate_callback(jack_client_t* client, JackSampleRateCallback srate_callback, void* arg)
{
return getBridgeInstance().set_sample_rate_callback_ptr(client, srate_callback, arg);
}

bool jackbridge_set_client_registration_callback(jack_client_t* client, JackClientRegistrationCallback registration_callback, void* arg)
{
return getBridgeInstance().set_client_registration_callback_ptr(client, registration_callback, arg);
}

bool jackbridge_set_port_registration_callback(jack_client_t* client, JackPortRegistrationCallback registration_callback, void *arg)
{
return getBridgeInstance().set_port_registration_callback_ptr(client, registration_callback, arg);
}

bool jackbridge_set_port_rename_callback(jack_client_t* client, JackPortRenameCallback rename_callback, void* arg)
{
return getBridgeInstance().set_port_rename_callback_ptr(client, rename_callback, arg);
}

bool jackbridge_set_port_connect_callback(jack_client_t* client, JackPortConnectCallback connect_callback, void* arg)
{
return getBridgeInstance().set_port_connect_callback_ptr(client, connect_callback, arg);
}

bool jackbridge_set_xrun_callback(jack_client_t* client, JackXRunCallback xrun_callback, void* arg)
{
return getBridgeInstance().set_xrun_callback_ptr(client, xrun_callback, arg);
}

bool jackbridge_set_latency_callback(jack_client_t* client, JackLatencyCallback latency_callback, void* arg)
{
return getBridgeInstance().set_latency_callback_ptr(client, latency_callback, arg);
}

bool jackbridge_set_freewheel(jack_client_t* client, bool onoff)
{
return getBridgeInstance().set_freewheel_ptr(client, onoff);
}

bool jackbridge_set_buffer_size(jack_client_t* client, jack_nframes_t nframes)
{
return getBridgeInstance().set_buffer_size_ptr(client, nframes);
}

jack_nframes_t jackbridge_get_sample_rate(jack_client_t* client)
{
return getBridgeInstance().get_sample_rate_ptr(client);
}

jack_nframes_t jackbridge_get_buffer_size(jack_client_t* client)
{
return getBridgeInstance().get_buffer_size_ptr(client);
}

float jackbridge_cpu_load(jack_client_t* client)
{
return getBridgeInstance().cpu_load_ptr(client);
}

jack_port_t* jackbridge_port_register(jack_client_t* client, const char* port_name, const char* port_type, ulong flags, ulong buffer_size)
{
return getBridgeInstance().port_register_ptr(client, port_name, port_type, flags, buffer_size);
}

bool jackbridge_port_unregister(jack_client_t* client, jack_port_t* port)
{
return getBridgeInstance().port_unregister_ptr(client, port);
}

void* jackbridge_port_get_buffer(jack_port_t* port, jack_nframes_t nframes)
{
return getBridgeInstance().port_get_buffer_ptr(port, nframes);
}

const char* jackbridge_port_name(const jack_port_t* port)
{
return getBridgeInstance().port_name_ptr(port);
}

jack_uuid_t jackbridge_port_uuid(const jack_port_t* port)
{
return getBridgeInstance().port_uuid_ptr(port);
}

const char* jackbridge_port_short_name(const jack_port_t* port)
{
return getBridgeInstance().port_short_name_ptr(port);
}

int jackbridge_port_flags(const jack_port_t* port)
{
return getBridgeInstance().port_flags_ptr(port);
}

const char* jackbridge_port_type(const jack_port_t* port)
{
return getBridgeInstance().port_type_ptr(port);
}

bool jackbridge_port_is_mine(const jack_client_t* client, const jack_port_t* port)
{
return getBridgeInstance().port_is_mine_ptr(client, port);
}

int jackbridge_port_connected(const jack_port_t* port)
{
return getBridgeInstance().port_connected_ptr(port);
}

bool jackbridge_port_connected_to(const jack_port_t* port, const char* port_name)
{
return getBridgeInstance().port_connected_to_ptr(port, port_name);
}

const char** jackbridge_port_get_connections(const jack_port_t* port)
{
return getBridgeInstance().port_get_connections_ptr(port);
}

const char** jackbridge_port_get_all_connections(const jack_client_t* client, const jack_port_t* port)
{
return getBridgeInstance().port_get_all_connections_ptr(client, port);
}

bool jackbridge_port_set_name(jack_port_t* port, const char* port_name)
{
return getBridgeInstance().port_set_name_ptr(port, port_name);
}

bool jackbridge_port_set_alias(jack_port_t* port, const char* alias)
{
return getBridgeInstance().port_set_alias_ptr(port, alias);
}

bool jackbridge_port_unset_alias(jack_port_t* port, const char* alias)
{
return getBridgeInstance().port_unset_alias_ptr(port, alias);
}

int jackbridge_port_get_aliases(const jack_port_t* port, char* const aliases[2])
{
return getBridgeInstance().port_get_aliases_ptr(port, aliases);
}

bool jackbridge_port_request_monitor(jack_port_t* port, bool onoff)
{
return getBridgeInstance().port_request_monitor_ptr(port, onoff);
}

bool jackbridge_port_request_monitor_by_name(jack_client_t* client, const char* port_name, bool onoff)
{
return getBridgeInstance().port_request_monitor_by_name_ptr(client, port_name, onoff);
}

bool jackbridge_port_ensure_monitor(jack_port_t* port, bool onoff)
{
return getBridgeInstance().port_ensure_monitor_ptr(port, onoff);
}

bool jackbridge_port_monitoring_input(jack_port_t* port)
{
return getBridgeInstance().port_monitoring_input_ptr(port);
}

bool jackbridge_connect(jack_client_t* client, const char* source_port, const char* destination_port)
{
return getBridgeInstance().connect_ptr(client, source_port, destination_port);
}

bool jackbridge_disconnect(jack_client_t* client, const char* source_port, const char* destination_port)
{
return getBridgeInstance().disconnect_ptr(client, source_port, destination_port);
}

bool jackbridge_port_disconnect(jack_client_t* client, jack_port_t* port)
{
return getBridgeInstance().port_disconnect_ptr(client, port);
}

int jackbridge_port_name_size(void)
{
return getBridgeInstance().port_name_size_ptr();
}

int jackbridge_port_type_size(void)
{
return getBridgeInstance().port_type_size_ptr();
}

size_t jackbridge_port_type_get_buffer_size(jack_client_t* client, const char* port_type)
{
return getBridgeInstance().port_type_get_buffer_size_ptr(client, port_type);
}

void jackbridge_port_get_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range)
{
return getBridgeInstance().port_get_latency_range_ptr(port, mode, range);
}

void jackbridge_port_set_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range)
{
return getBridgeInstance().port_set_latency_range_ptr(port, mode, range);
}

bool jackbridge_recompute_total_latencies(jack_client_t* client)
{
return getBridgeInstance().recompute_total_latencies_ptr(client);
}

const char** jackbridge_get_ports(jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, ulong flags)
{
return getBridgeInstance().get_ports_ptr(client, port_name_pattern, type_name_pattern, flags);
}

jack_port_t* jackbridge_port_by_name(jack_client_t* client, const char* port_name)
{
return getBridgeInstance().port_by_name_ptr(client, port_name);
}

jack_port_t* jackbridge_port_by_id(jack_client_t* client, jack_port_id_t port_id)
{
return getBridgeInstance().port_by_id_ptr(client, port_id);
}

void jackbridge_free(void* ptr)
{
return getBridgeInstance().free_ptr(ptr);
}

uint32_t jackbridge_midi_get_event_count(void* port_buffer)
{
return getBridgeInstance().midi_get_event_count_ptr(port_buffer);
}

bool jackbridge_midi_event_get(jack_midi_event_t* event, void* port_buffer, uint32_t event_index)
{
return getBridgeInstance().midi_event_get_ptr(event, port_buffer, event_index);
}

void jackbridge_midi_clear_buffer(void* port_buffer)
{
return getBridgeInstance().midi_clear_buffer_ptr(port_buffer);
}

bool jackbridge_midi_event_write(void* port_buffer, jack_nframes_t time, const jack_midi_data_t* data, size_t data_size)
{
return getBridgeInstance().midi_event_write_ptr(port_buffer, time, data, data_size);
}

jack_midi_data_t* jackbridge_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size)
{
return getBridgeInstance().midi_event_reserve_ptr(port_buffer, time, data_size);
}

bool jackbridge_release_timebase(jack_client_t* client)
{
return getBridgeInstance().release_timebase_ptr(client);
}

bool jackbridge_set_sync_callback(jack_client_t* client, JackSyncCallback sync_callback, void* arg)
{
return getBridgeInstance().set_sync_callback_ptr(client, sync_callback, arg);
}

bool jackbridge_set_sync_timeout(jack_client_t* client, jack_time_t timeout)
{
return getBridgeInstance().set_sync_timeout_ptr(client, timeout);
}

bool jackbridge_set_timebase_callback(jack_client_t* client, bool conditional, JackTimebaseCallback timebase_callback, void* arg)
{
return getBridgeInstance().set_timebase_callback_ptr(client, conditional, timebase_callback, arg);
}

bool jackbridge_transport_locate(jack_client_t* client, jack_nframes_t frame)
{
return getBridgeInstance().transport_locate_ptr(client, frame);
}

jack_transport_state_t jackbridge_transport_query(const jack_client_t* client, jack_position_t* pos)
{
return getBridgeInstance().transport_query_ptr(client, pos);
}

jack_nframes_t jackbridge_get_current_transport_frame(const jack_client_t* client)
{
return getBridgeInstance().get_current_transport_frame_ptr(client);
}

bool jackbridge_transport_reposition(jack_client_t* client, const jack_position_t* pos)
{
return getBridgeInstance().transport_reposition_ptr(client, pos);
}

void jackbridge_transport_start(jack_client_t* client)
{
return getBridgeInstance().transport_start_ptr(client);
}

void jackbridge_transport_stop(jack_client_t* client)
{
return getBridgeInstance().transport_stop_ptr(client);
}

bool jackbridge_set_property(jack_client_t* client, jack_uuid_t subject, const char* key, const char* value, const char* type)
{
return getBridgeInstance().set_property_ptr(client, subject, key, value, type);
}

bool jackbridge_get_property(jack_uuid_t subject, const char* key, char** value, char** type)
{
return getBridgeInstance().get_property_ptr(subject, key, value, type);
}

void jackbridge_free_description(jack_description_t* desc, bool free_description_itself)
{
return getBridgeInstance().free_description_ptr(desc, free_description_itself);
}

bool jackbridge_get_properties(jack_uuid_t subject, jack_description_t* desc)
{
return getBridgeInstance().get_properties_ptr(subject, desc);
}

bool jackbridge_get_all_properties(jack_description_t** descs)
{
return getBridgeInstance().get_all_properties_ptr(descs);
}

bool jackbridge_remove_property(jack_client_t* client, jack_uuid_t subject, const char* key)
{
return getBridgeInstance().remove_property_ptr(client, subject, key);
}

int jackbridge_remove_properties(jack_client_t* client, jack_uuid_t subject)
{
return getBridgeInstance().remove_properties_ptr(client, subject);
}

bool jackbridge_remove_all_properties(jack_client_t* client)
{
return getBridgeInstance().remove_all_properties_ptr(client);
}

bool jackbridge_set_property_change_callback(jack_client_t* client, JackPropertyChangeCallback callback, void* arg)
{
return getBridgeInstance().set_property_change_callback_ptr(client, callback, arg);
}

bool jackbridge_sem_init(void* sem) noexcept
{
return getBridgeInstance().sem_init_ptr(sem);
}

bool jackbridge_sem_destroy(void* sem) noexcept
{
return getBridgeInstance().sem_destroy_ptr(sem);
}

bool jackbridge_sem_post(void* sem) noexcept
{
return getBridgeInstance().sem_post_ptr(sem);
}

bool jackbridge_sem_timedwait(void* sem, int secs) noexcept
{
return getBridgeInstance().sem_timedwait_ptr(sem, secs);
}

bool jackbridge_shm_is_valid(const void* shm) noexcept
{
return getBridgeInstance().shm_is_valid_ptr(shm);
}

void jackbridge_shm_init(void* shm) noexcept
{
return getBridgeInstance().shm_init_ptr(shm);
}

void jackbridge_shm_attach(void* shm, const char* name) noexcept
{
return getBridgeInstance().shm_attach_ptr(shm, name);
}

void jackbridge_shm_close(void* shm) noexcept
{
return getBridgeInstance().shm_close_ptr(shm);
}

void* jackbridge_shm_map(void* shm, size_t size) noexcept
{
return getBridgeInstance().shm_map_ptr(shm, size);
}

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

+ 3
- 0
source/modules/jackbridge/JackBridgeExport.def View File

@@ -0,0 +1,3 @@
LIBRARY JackBridge
DESCRIPTION 'Carla JackBridge'
EXPORTS jackbridge_get_exported_functions

+ 227
- 0
source/modules/jackbridge/JackBridgeExport.hpp View File

@@ -0,0 +1,227 @@
/*
* JackBridge (Part 3, Export)
* Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "JackBridge.hpp"

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

typedef void (__cdecl *jackbridgesym_get_version)(int* major_ptr, int* minor_ptr, int* micro_ptr, int* proto_ptr);
typedef const char* (__cdecl *jackbridgesym_get_version_string)(void);
typedef jack_client_t* (__cdecl *jackbridgesym_client_open)(const char* client_name, jack_options_t options, jack_status_t* status);
typedef bool (__cdecl *jackbridgesym_client_close)(jack_client_t* client);
typedef int (__cdecl *jackbridgesym_client_name_size)(void);
typedef char* (__cdecl *jackbridgesym_get_client_name)(jack_client_t* client);
typedef char* (__cdecl *jackbridgesym_get_uuid_for_client_name)(jack_client_t* client, const char* name);
typedef char* (__cdecl *jackbridgesym_get_client_name_by_uuid)(jack_client_t* client, const char* uuid);
typedef bool (__cdecl *jackbridgesym_activate)(jack_client_t* client);
typedef bool (__cdecl *jackbridgesym_deactivate)(jack_client_t* client);
typedef bool (__cdecl *jackbridgesym_is_realtime)(jack_client_t* client);
typedef bool (__cdecl *jackbridgesym_set_thread_init_callback)(jack_client_t* client, JackThreadInitCallback thread_init_callback, void* arg);
typedef void (__cdecl *jackbridgesym_on_shutdown)(jack_client_t* client, JackShutdownCallback shutdown_callback, void* arg);
typedef void (__cdecl *jackbridgesym_on_info_shutdown)(jack_client_t* client, JackInfoShutdownCallback shutdown_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_process_callback)(jack_client_t* client, JackProcessCallback process_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_freewheel_callback)(jack_client_t* client, JackFreewheelCallback freewheel_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_buffer_size_callback)(jack_client_t* client, JackBufferSizeCallback bufsize_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_sample_rate_callback)(jack_client_t* client, JackSampleRateCallback srate_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_client_registration_callback)(jack_client_t* client, JackClientRegistrationCallback registration_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_port_registration_callback)(jack_client_t* client, JackPortRegistrationCallback registration_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_port_rename_callback)(jack_client_t* client, JackPortRenameCallback rename_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_port_connect_callback)(jack_client_t* client, JackPortConnectCallback connect_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_graph_order_callback)(jack_client_t* client, JackGraphOrderCallback graph_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_xrun_callback)(jack_client_t* client, JackXRunCallback xrun_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_latency_callback)(jack_client_t* client, JackLatencyCallback latency_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_freewheel)(jack_client_t* client, bool onoff);
typedef bool (__cdecl *jackbridgesym_set_buffer_size)(jack_client_t* client, jack_nframes_t nframes);
typedef jack_nframes_t (__cdecl *jackbridgesym_get_sample_rate)(jack_client_t* client);
typedef jack_nframes_t (__cdecl *jackbridgesym_get_buffer_size)(jack_client_t* client);
typedef float (__cdecl *jackbridgesym_cpu_load)(jack_client_t* client);
typedef jack_port_t* (__cdecl *jackbridgesym_port_register)(jack_client_t* client, const char* port_name, const char* port_type, ulong flags, ulong buffer_size);
typedef bool (__cdecl *jackbridgesym_port_unregister)(jack_client_t* client, jack_port_t* port);
typedef void* (__cdecl *jackbridgesym_port_get_buffer)(jack_port_t* port, jack_nframes_t nframes);
typedef const char* (__cdecl *jackbridgesym_port_name)(const jack_port_t* port);
typedef jack_uuid_t (__cdecl *jackbridgesym_port_uuid)(const jack_port_t* port);
typedef const char* (__cdecl *jackbridgesym_port_short_name)(const jack_port_t* port);
typedef int (__cdecl *jackbridgesym_port_flags)(const jack_port_t* port);
typedef const char* (__cdecl *jackbridgesym_port_type)(const jack_port_t* port);
typedef bool (__cdecl *jackbridgesym_port_is_mine)(const jack_client_t* client, const jack_port_t* port);
typedef int (__cdecl *jackbridgesym_port_connected)(const jack_port_t* port);
typedef bool (__cdecl *jackbridgesym_port_connected_to)(const jack_port_t* port, const char* port_name);
typedef const char** (__cdecl *jackbridgesym_port_get_connections)(const jack_port_t* port);
typedef const char** (__cdecl *jackbridgesym_port_get_all_connections)(const jack_client_t* client, const jack_port_t* port);
typedef bool (__cdecl *jackbridgesym_port_set_name)(jack_port_t* port, const char* port_name);
typedef bool (__cdecl *jackbridgesym_port_set_alias)(jack_port_t* port, const char* alias);
typedef bool (__cdecl *jackbridgesym_port_unset_alias)(jack_port_t* port, const char* alias);
typedef int (__cdecl *jackbridgesym_port_get_aliases)(const jack_port_t* port, char* const aliases[2]);
typedef bool (__cdecl *jackbridgesym_port_request_monitor)(jack_port_t* port, bool onoff);
typedef bool (__cdecl *jackbridgesym_port_request_monitor_by_name)(jack_client_t* client, const char* port_name, bool onoff);
typedef bool (__cdecl *jackbridgesym_port_ensure_monitor)(jack_port_t* port, bool onoff);
typedef bool (__cdecl *jackbridgesym_port_monitoring_input)(jack_port_t* port);
typedef bool (__cdecl *jackbridgesym_connect)(jack_client_t* client, const char* source_port, const char* destination_port);
typedef bool (__cdecl *jackbridgesym_disconnect)(jack_client_t* client, const char* source_port, const char* destination_port);
typedef bool (__cdecl *jackbridgesym_port_disconnect)(jack_client_t* client, jack_port_t* port);
typedef int (__cdecl *jackbridgesym_port_name_size)(void);
typedef int (__cdecl *jackbridgesym_port_type_size)(void);
typedef size_t (__cdecl *jackbridgesym_port_type_get_buffer_size)(jack_client_t* client, const char* port_type);
typedef void (__cdecl *jackbridgesym_port_get_latency_range)(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range);
typedef void (__cdecl *jackbridgesym_port_set_latency_range)(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range);
typedef bool (__cdecl *jackbridgesym_recompute_total_latencies)(jack_client_t* client);
typedef const char** (__cdecl *jackbridgesym_get_ports)(jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, ulong flags);
typedef jack_port_t* (__cdecl *jackbridgesym_port_by_name)(jack_client_t* client, const char* port_name);
typedef jack_port_t* (__cdecl *jackbridgesym_port_by_id)(jack_client_t* client, jack_port_id_t port_id);
typedef void (__cdecl *jackbridgesym_free)(void* ptr);
typedef uint32_t (__cdecl *jackbridgesym_midi_get_event_count)(void* port_buffer);
typedef bool (__cdecl *jackbridgesym_midi_event_get)(jack_midi_event_t* event, void* port_buffer, uint32_t event_index);
typedef void (__cdecl *jackbridgesym_midi_clear_buffer)(void* port_buffer);
typedef bool (__cdecl *jackbridgesym_midi_event_write)(void* port_buffer, jack_nframes_t time, const jack_midi_data_t* data, size_t data_size);
typedef jack_midi_data_t* (__cdecl *jackbridgesym_midi_event_reserve)(void* port_buffer, jack_nframes_t time, size_t data_size);
typedef bool (__cdecl *jackbridgesym_release_timebase)(jack_client_t* client);
typedef bool (__cdecl *jackbridgesym_set_sync_callback)(jack_client_t* client, JackSyncCallback sync_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_set_sync_timeout)(jack_client_t* client, jack_time_t timeout);
typedef bool (__cdecl *jackbridgesym_set_timebase_callback)(jack_client_t* client, bool conditional, JackTimebaseCallback timebase_callback, void* arg);
typedef bool (__cdecl *jackbridgesym_transport_locate)(jack_client_t* client, jack_nframes_t frame);
typedef jack_transport_state_t (__cdecl *jackbridgesym_transport_query)(const jack_client_t* client, jack_position_t* pos);
typedef jack_nframes_t (__cdecl *jackbridgesym_get_current_transport_frame)(const jack_client_t* client);
typedef bool (__cdecl *jackbridgesym_transport_reposition)(jack_client_t* client, const jack_position_t* pos);
typedef void (__cdecl *jackbridgesym_transport_start)(jack_client_t* client);
typedef void (__cdecl *jackbridgesym_transport_stop)(jack_client_t* client);
typedef bool (__cdecl *jackbridgesym_set_property)(jack_client_t* client, jack_uuid_t subject, const char* key, const char* value, const char* type);
typedef bool (__cdecl *jackbridgesym_get_property)(jack_uuid_t subject, const char* key, char** value, char** type);
typedef void (__cdecl *jackbridgesym_free_description)(jack_description_t* desc, bool free_description_itself);
typedef bool (__cdecl *jackbridgesym_get_properties)(jack_uuid_t subject, jack_description_t* desc);
typedef bool (__cdecl *jackbridgesym_get_all_properties)(jack_description_t** descs);
typedef bool (__cdecl *jackbridgesym_remove_property)(jack_client_t* client, jack_uuid_t subject, const char* key);
typedef int (__cdecl *jackbridgesym_remove_properties)(jack_client_t* client, jack_uuid_t subject);
typedef bool (__cdecl *jackbridgesym_remove_all_properties)(jack_client_t* client);
typedef bool (__cdecl *jackbridgesym_set_property_change_callback)(jack_client_t* client, JackPropertyChangeCallback callback, void* arg);
typedef bool (__cdecl *jackbridgesym_sem_init)(void* sem);
typedef bool (__cdecl *jackbridgesym_sem_destroy)(void* sem);
typedef bool (__cdecl *jackbridgesym_sem_post)(void* sem);
typedef bool (__cdecl *jackbridgesym_sem_timedwait)(void* sem, int secs);
typedef bool (__cdecl *jackbridgesym_shm_is_valid)(const void* shm);
typedef void (__cdecl *jackbridgesym_shm_init)(void* shm);
typedef void (__cdecl *jackbridgesym_shm_attach)(void* shm, const char* name);
typedef void (__cdecl *jackbridgesym_shm_close)(void* shm);
typedef void* (__cdecl *jackbridgesym_shm_map)(void* shm, size_t size);

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

struct JackBridgeExportedFunctions {
ulong unique1;
jackbridgesym_get_version get_version_ptr;
jackbridgesym_get_version_string get_version_string_ptr;
jackbridgesym_client_open client_open_ptr;
jackbridgesym_client_close client_close_ptr;
jackbridgesym_client_name_size client_name_size_ptr;
jackbridgesym_get_client_name get_client_name_ptr;
jackbridgesym_get_uuid_for_client_name get_uuid_for_client_name_ptr;
jackbridgesym_get_client_name_by_uuid get_client_name_by_uuid_ptr;
jackbridgesym_activate activate_ptr;
jackbridgesym_deactivate deactivate_ptr;
jackbridgesym_is_realtime is_realtime_ptr;
jackbridgesym_set_thread_init_callback set_thread_init_callback_ptr;
jackbridgesym_on_shutdown on_shutdown_ptr;
jackbridgesym_on_info_shutdown on_info_shutdown_ptr;
jackbridgesym_set_process_callback set_process_callback_ptr;
jackbridgesym_set_freewheel_callback set_freewheel_callback_ptr;
jackbridgesym_set_buffer_size_callback set_buffer_size_callback_ptr;
jackbridgesym_set_sample_rate_callback set_sample_rate_callback_ptr;
jackbridgesym_set_client_registration_callback set_client_registration_callback_ptr;
jackbridgesym_set_port_registration_callback set_port_registration_callback_ptr;
jackbridgesym_set_port_rename_callback set_port_rename_callback_ptr;
jackbridgesym_set_port_connect_callback set_port_connect_callback_ptr;
jackbridgesym_set_graph_order_callback set_graph_order_callback_ptr;
jackbridgesym_set_xrun_callback set_xrun_callback_ptr;
jackbridgesym_set_latency_callback set_latency_callback_ptr;
jackbridgesym_set_freewheel set_freewheel_ptr;
jackbridgesym_set_buffer_size set_buffer_size_ptr;
jackbridgesym_get_sample_rate get_sample_rate_ptr;
jackbridgesym_get_buffer_size get_buffer_size_ptr;
jackbridgesym_cpu_load cpu_load_ptr;
jackbridgesym_port_register port_register_ptr;
jackbridgesym_port_unregister port_unregister_ptr;
jackbridgesym_port_get_buffer port_get_buffer_ptr;
jackbridgesym_port_name port_name_ptr;
jackbridgesym_port_uuid port_uuid_ptr;
jackbridgesym_port_short_name port_short_name_ptr;
jackbridgesym_port_flags port_flags_ptr;
jackbridgesym_port_type port_type_ptr;
jackbridgesym_port_is_mine port_is_mine_ptr;
jackbridgesym_port_connected port_connected_ptr;
jackbridgesym_port_connected_to port_connected_to_ptr;
jackbridgesym_port_get_connections port_get_connections_ptr;
jackbridgesym_port_get_all_connections port_get_all_connections_ptr;
jackbridgesym_port_set_name port_set_name_ptr;
jackbridgesym_port_set_alias port_set_alias_ptr;
jackbridgesym_port_unset_alias port_unset_alias_ptr;
jackbridgesym_port_get_aliases port_get_aliases_ptr;
jackbridgesym_port_request_monitor port_request_monitor_ptr;
jackbridgesym_port_request_monitor_by_name port_request_monitor_by_name_ptr;
jackbridgesym_port_ensure_monitor port_ensure_monitor_ptr;
jackbridgesym_port_monitoring_input port_monitoring_input_ptr;
jackbridgesym_connect connect_ptr;
jackbridgesym_disconnect disconnect_ptr;
jackbridgesym_port_disconnect port_disconnect_ptr;
jackbridgesym_port_name_size port_name_size_ptr;
jackbridgesym_port_type_size port_type_size_ptr;
jackbridgesym_port_type_get_buffer_size port_type_get_buffer_size_ptr;
jackbridgesym_port_get_latency_range port_get_latency_range_ptr;
jackbridgesym_port_set_latency_range port_set_latency_range_ptr;
jackbridgesym_recompute_total_latencies recompute_total_latencies_ptr;
jackbridgesym_get_ports get_ports_ptr;
jackbridgesym_port_by_name port_by_name_ptr;
jackbridgesym_port_by_id port_by_id_ptr;
jackbridgesym_free free_ptr;
jackbridgesym_midi_get_event_count midi_get_event_count_ptr;
jackbridgesym_midi_event_get midi_event_get_ptr;
jackbridgesym_midi_clear_buffer midi_clear_buffer_ptr;
jackbridgesym_midi_event_write midi_event_write_ptr;
jackbridgesym_midi_event_reserve midi_event_reserve_ptr;
jackbridgesym_release_timebase release_timebase_ptr;
jackbridgesym_set_sync_callback set_sync_callback_ptr;
jackbridgesym_set_sync_timeout set_sync_timeout_ptr;
jackbridgesym_set_timebase_callback set_timebase_callback_ptr;
jackbridgesym_transport_locate transport_locate_ptr;
jackbridgesym_transport_query transport_query_ptr;
jackbridgesym_get_current_transport_frame get_current_transport_frame_ptr;
jackbridgesym_transport_reposition transport_reposition_ptr;
jackbridgesym_transport_start transport_start_ptr;
jackbridgesym_transport_stop transport_stop_ptr;
jackbridgesym_set_property set_property_ptr;
jackbridgesym_get_property get_property_ptr;
jackbridgesym_free_description free_description_ptr;
jackbridgesym_get_properties get_properties_ptr;
jackbridgesym_get_all_properties get_all_properties_ptr;
jackbridgesym_remove_property remove_property_ptr;
jackbridgesym_remove_properties remove_properties_ptr;
jackbridgesym_remove_all_properties remove_all_properties_ptr;
jackbridgesym_set_property_change_callback set_property_change_callback_ptr;
jackbridgesym_sem_init sem_init_ptr;
jackbridgesym_sem_destroy sem_destroy_ptr;
jackbridgesym_sem_post sem_post_ptr;
jackbridgesym_sem_timedwait sem_timedwait_ptr;
jackbridgesym_shm_is_valid shm_is_valid_ptr;
jackbridgesym_shm_init shm_init_ptr;
jackbridgesym_shm_attach shm_attach_ptr;
jackbridgesym_shm_close shm_close_ptr;
jackbridgesym_shm_map shm_map_ptr;
ulong unique2;
};

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

typedef const JackBridgeExportedFunctions* (*jackbridge_exported_function_type)();

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

Loading…
Cancel
Save