Signed-off-by: falkTX <falktx@gmail.com>tags/v2.1-alpha2
@@ -26,8 +26,5 @@ make -C source/modules/sfzero | |||
make -C source/modules/water | |||
make -C source/theme all qt4 qt5 | |||
# FIXME | |||
make -C source/libjack | |||
# Build native stuff | |||
make TESTBUILD=true |
@@ -286,9 +286,11 @@ CARLA_BRIDGE_UI_END_NAMESPACE | |||
// ------------------------------------------------------------------------- | |||
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) | |||
// missing declaration | |||
int qInitResources(); | |||
int qCleanupResources(); | |||
#endif | |||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) | |||
# include "resources.qt5.cpp" | |||
@@ -0,0 +1,236 @@ | |||
/* | |||
* Carla JACK API for external applications | |||
* Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* 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 General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#ifndef CARLA_LIBJACK_API_H_INCLUDED | |||
#define CARLA_LIBJACK_API_H_INCLUDED | |||
#include "CarlaDefines.h" | |||
#include "jackbridge/JackBridge.hpp" | |||
#include <pthread.h> | |||
extern "C" { | |||
typedef uint32_t jack_port_type_id_t; | |||
typedef void *(*JackThreadCallback)(void* arg); | |||
int jack_carla_interposed_action(int, int, void*); | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// jack.h | |||
void jack_get_version(int*, int*, int*, int*); | |||
const char* jack_get_version_string(void); | |||
jack_client_t* jack_client_open(const char*, jack_options_t, jack_status_t*, ...); | |||
jack_client_t* jack_client_new(const char*); | |||
int jack_client_close(jack_client_t*); | |||
int jack_client_name_size(void); | |||
char * jack_get_client_name(jack_client_t*); | |||
char *jack_get_uuid_for_client_name(jack_client_t*, const char*); | |||
char *jack_get_client_name_by_uuid(jack_client_t*, const char*); | |||
int jack_internal_client_new(const char*, const char*, const char*); | |||
void jack_internal_client_close(const char*); | |||
int jack_activate(jack_client_t*); | |||
int jack_deactivate(jack_client_t*); | |||
int jack_get_client_pid(const char*); | |||
pthread_t jack_client_thread_id(jack_client_t*); | |||
int jack_is_realtime(jack_client_t*); | |||
jack_nframes_t jack_thread_wait(jack_client_t*, int); | |||
jack_nframes_t jack_cycle_wait(jack_client_t*); | |||
void jack_cycle_signal(jack_client_t*, int); | |||
int jack_set_process_thread(jack_client_t*, JackThreadCallback, void*); | |||
int jack_set_thread_init_callback(jack_client_t*, JackThreadInitCallback, void*); | |||
void jack_on_shutdown(jack_client_t*, JackShutdownCallback, void*); | |||
void jack_on_info_shutdown(jack_client_t*, JackInfoShutdownCallback, void*); | |||
int jack_set_process_callback(jack_client_t*, JackProcessCallback, void*); | |||
int jack_set_freewheel_callback(jack_client_t*, JackFreewheelCallback, void*); | |||
int jack_set_buffer_size_callback(jack_client_t*, JackBufferSizeCallback, void*); | |||
int jack_set_sample_rate_callback(jack_client_t*, JackSampleRateCallback, void*); | |||
int jack_set_client_registration_callback(jack_client_t*, JackClientRegistrationCallback, void*); | |||
int jack_set_port_registration_callback(jack_client_t*, JackPortRegistrationCallback, void*); | |||
int jack_set_port_connect_callback(jack_client_t*, JackPortConnectCallback, void*); | |||
int jack_set_port_rename_callback(jack_client_t*, JackPortRenameCallback, void*); | |||
int jack_set_graph_order_callback(jack_client_t*, JackGraphOrderCallback, void*); | |||
int jack_set_xrun_callback(jack_client_t*, JackXRunCallback, void*); | |||
int jack_set_latency_callback(jack_client_t*, JackLatencyCallback, void*); | |||
int jack_set_freewheel(jack_client_t*, int); | |||
int jack_set_buffer_size(jack_client_t*, jack_nframes_t); | |||
jack_nframes_t jack_get_sample_rate(jack_client_t*); | |||
jack_nframes_t jack_get_buffer_size(jack_client_t*); | |||
int jack_engine_takeover_timebase(jack_client_t*); | |||
float jack_cpu_load(jack_client_t*); | |||
jack_port_t * jack_port_register(jack_client_t*, const char*, const char*, unsigned long, unsigned long); | |||
int jack_port_unregister(jack_client_t*, jack_port_t*); | |||
void * jack_port_get_buffer(jack_port_t*, jack_nframes_t); | |||
jack_uuid_t jack_port_uuid(const jack_port_t*); | |||
const char * jack_port_name(const jack_port_t*); | |||
const char * jack_port_short_name(const jack_port_t*); | |||
int jack_port_flags(const jack_port_t*); | |||
const char * jack_port_type(const jack_port_t*); | |||
jack_port_type_id_t jack_port_type_id(const jack_port_t*); | |||
int jack_port_is_mine(const jack_client_t*, const jack_port_t*); | |||
int jack_port_connected(const jack_port_t*); | |||
int jack_port_connected_to(const jack_port_t*, const char*); | |||
const char** jack_port_get_connections(const jack_port_t*); | |||
const char** jack_port_get_all_connections(const jack_client_t*, const jack_port_t*); | |||
int jack_port_tie(jack_port_t*, jack_port_t*); | |||
int jack_port_untie(jack_port_t*); | |||
int jack_port_set_name(jack_port_t*, const char*); | |||
int jack_port_rename(jack_client_t*, jack_port_t*, const char*); | |||
int jack_port_set_alias(jack_port_t*, const char*); | |||
int jack_port_unset_alias(jack_port_t*, const char*); | |||
int jack_port_get_aliases(const jack_port_t*, char* const aliases[2]); | |||
int jack_port_request_monitor(jack_port_t*, int); | |||
int jack_port_request_monitor_by_name(jack_client_t*, const char*, int); | |||
int jack_port_ensure_monitor(jack_port_t*, int); | |||
int jack_port_monitoring_input(jack_port_t*); | |||
int jack_connect(jack_client_t*, const char*, const char*); | |||
int jack_disconnect(jack_client_t*, const char*, const char*); | |||
int jack_port_disconnect(jack_client_t*, jack_port_t*); | |||
int jack_port_name_size(void); | |||
int jack_port_type_size(void); | |||
size_t jack_port_type_get_buffer_size(jack_client_t*, const char*); | |||
void jack_port_set_latency(jack_port_t*, jack_nframes_t); | |||
void jack_port_get_latency_range(jack_port_t*, jack_latency_callback_mode_t, jack_latency_range_t*); | |||
void jack_port_set_latency_range(jack_port_t*, jack_latency_callback_mode_t, jack_latency_range_t*); | |||
int jack_recompute_total_latencies(jack_client_t*); | |||
jack_nframes_t jack_port_get_latency(jack_port_t*); | |||
jack_nframes_t jack_port_get_total_latency(jack_client_t*, jack_port_t*); | |||
int jack_recompute_total_latency(jack_client_t*, jack_port_t*); | |||
const char** jack_get_ports(jack_client_t*, const char*, const char*, unsigned long); | |||
jack_port_t* jack_port_by_name(jack_client_t*, const char*); | |||
jack_port_t* jack_port_by_id(jack_client_t*, jack_port_id_t); | |||
jack_nframes_t jack_frames_since_cycle_start(const jack_client_t*); | |||
jack_nframes_t jack_frame_time(const jack_client_t*); | |||
jack_nframes_t jack_last_frame_time(const jack_client_t*); | |||
int jack_get_cycle_times(const jack_client_t*, jack_nframes_t*, jack_time_t*, jack_time_t*, float*); | |||
jack_time_t jack_frames_to_time(const jack_client_t*, jack_nframes_t); | |||
jack_nframes_t jack_time_to_frames(const jack_client_t*, jack_time_t); | |||
jack_time_t jack_get_time(void); | |||
void jack_free(void*); | |||
extern void(*jack_error_callback)(const char *msg); | |||
void jack_set_error_function(void (*func)(const char *)); | |||
extern void (*jack_info_callback)(const char *msg); | |||
void jack_set_info_function(void (*func)(const char *)); | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// medadata.h | |||
int jack_set_property(jack_client_t*, jack_uuid_t, const char*, const char*, const char*); | |||
int jack_get_property(jack_uuid_t, const char*, char**, char**); | |||
void jack_free_description(jack_description_t*, int); | |||
int jack_get_properties(jack_uuid_t, jack_description_t*); | |||
int jack_get_all_properties(jack_description_t**); | |||
int jack_remove_property(jack_client_t*, jack_uuid_t, const char*); | |||
int jack_remove_properties(jack_client_t*, jack_uuid_t); | |||
int jack_remove_all_properties(jack_client_t*); | |||
int jack_set_property_change_callback(jack_client_t*, JackPropertyChangeCallback, void*); | |||
// extern const char* JACK_METADATA_PRETTY_NAME; | |||
// extern const char* JACK_METADATA_HARDWARE; | |||
// extern const char* JACK_METADATA_CONNECTED; | |||
// extern const char* JACK_METADATA_PORT_GROUP; | |||
// extern const char* JACK_METADATA_ICON_SMALL; | |||
// extern const char* JACK_METADATA_ICON_LARGE; | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// midiport.h | |||
uint32_t jack_midi_get_event_count(void*); | |||
int jack_midi_event_get(jack_midi_event_t*, void*, uint32_t); | |||
void jack_midi_clear_buffer(void*); | |||
void jack_midi_reset_buffer(void*); | |||
size_t jack_midi_max_event_size(void*); | |||
jack_midi_data_t* jack_midi_event_reserve(void*, jack_nframes_t, size_t); | |||
int jack_midi_event_write(void*, jack_nframes_t, const jack_midi_data_t*, size_t); | |||
uint32_t jack_midi_get_lost_event_count(void*); | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// thread.h | |||
int jack_client_real_time_priority(jack_client_t*); | |||
int jack_client_max_real_time_priority(jack_client_t*); | |||
int jack_acquire_real_time_scheduling(pthread_t, int ); | |||
int jack_client_create_thread(jack_client_t*, pthread_t*, int, int, void *(*start_routine)(void*), void*); | |||
int jack_drop_real_time_scheduling(pthread_t); | |||
int jack_client_stop_thread(jack_client_t*, pthread_t); | |||
int jack_client_kill_thread(jack_client_t*, pthread_t); | |||
typedef int (*jack_thread_creator_t)(pthread_t*, const pthread_attr_t*, void* (*function)(void*), void* arg); | |||
void jack_set_thread_creator(jack_thread_creator_t); | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// session.h | |||
int jack_set_session_callback(jack_client_t*, JackSessionCallback, void*); | |||
int jack_session_reply(jack_client_t*, jack_session_event_t*); | |||
void jack_session_event_free(jack_session_event_t*); | |||
char* jack_client_get_uuid(jack_client_t*); | |||
jack_session_command_t* jack_session_notify( jack_client_t*, const char*, jack_session_event_type_t, const char*); | |||
void jack_session_commands_free(jack_session_command_t*); | |||
int jack_reserve_client_name(jack_client_t*, const char*, const char*); | |||
int jack_client_has_session_callback(jack_client_t*, const char*); | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// statistics.h | |||
float jack_get_max_delayed_usecs(jack_client_t*); | |||
float jack_get_xrun_delayed_usecs(jack_client_t*); | |||
void jack_reset_max_delayed_usecs(jack_client_t*); | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// transport.h | |||
int jack_release_timebase(jack_client_t*); | |||
int jack_set_sync_callback(jack_client_t*, JackSyncCallback, void*); | |||
int jack_set_sync_timeout(jack_client_t*, jack_time_t); | |||
int jack_set_timebase_callback(jack_client_t*, int, JackTimebaseCallback, void*); | |||
int jack_transport_locate(jack_client_t*, jack_nframes_t); | |||
jack_transport_state_t jack_transport_query(const jack_client_t*, jack_position_t*); | |||
jack_nframes_t jack_get_current_transport_frame(const jack_client_t*); | |||
int jack_transport_reposition(jack_client_t*, const jack_position_t*); | |||
void jack_transport_start(jack_client_t*); | |||
void jack_transport_stop(jack_client_t*); | |||
void jack_get_transport_info(jack_client_t*, void*); | |||
void jack_set_transport_info(jack_client_t*, void*); | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// uuid.h | |||
#define JACK_UUID_SIZE 36 | |||
#define JACK_UUID_STRING_SIZE (JACK_UUID_SIZE+1) /* includes trailing null */ | |||
// #define JACK_UUID_EMPTY_INITIALIZER 0 | |||
jack_uuid_t jack_client_uuid_generate(); | |||
jack_uuid_t jack_port_uuid_generate(uint32_t port_id); | |||
uint32_t jack_uuid_to_index(jack_uuid_t); | |||
int jack_uuid_compare(jack_uuid_t, jack_uuid_t); | |||
void jack_uuid_copy(jack_uuid_t* dst, jack_uuid_t src); | |||
void jack_uuid_clear(jack_uuid_t*); | |||
int jack_uuid_parse(const char *buf, jack_uuid_t*); | |||
void jack_uuid_unparse(jack_uuid_t, char buf[JACK_UUID_STRING_SIZE]); | |||
int jack_uuid_empty(jack_uuid_t); | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
} | |||
#endif |
@@ -23,6 +23,8 @@ | |||
#include <sys/prctl.h> | |||
#include <sys/time.h> | |||
// --------------------------------------------------------------------------------------------------------------------- | |||
typedef int (*CarlaInterposedCallback)(int, void*); | |||
CARLA_EXPORT | |||
@@ -32,8 +34,12 @@ int jack_carla_interposed_action(int, int, void*) | |||
return 1337; | |||
} | |||
// --------------------------------------------------------------------------------------------------------------------- | |||
CARLA_BACKEND_START_NAMESPACE | |||
// --------------------------------------------------------------------------------------------------------------------- | |||
static int64_t getCurrentTimeMilliseconds() noexcept | |||
{ | |||
struct timeval tv; | |||
@@ -41,6 +47,8 @@ static int64_t getCurrentTimeMilliseconds() noexcept | |||
return ((int64_t) tv.tv_sec) * 1000 + tv.tv_usec / 1000; | |||
} | |||
static int carla_interposed_callback(int, void*); | |||
// --------------------------------------------------------------------------------------------------------------------- | |||
class CarlaJackRealtimeThread : public CarlaThread | |||
@@ -95,8 +103,6 @@ private: | |||
CARLA_DECLARE_NON_COPY_CLASS(CarlaJackNonRealtimeThread) | |||
}; | |||
static int carla_interposed_callback(int, void*); | |||
// --------------------------------------------------------------------------------------------------------------------- | |||
class CarlaJackAppClient : public CarlaJackRealtimeThread::Callback, | |||
@@ -125,7 +131,8 @@ public: | |||
fSessionManager(0), | |||
fSetupHints(0), | |||
fRealtimeThread(this), | |||
fNonRealtimeThread(this) | |||
fNonRealtimeThread(this), | |||
fRealtimeThreadMutex() | |||
{ | |||
carla_debug("CarlaJackAppClient::CarlaJackAppClient()"); | |||
@@ -609,7 +616,7 @@ bool CarlaJackAppClient::handleRtData() | |||
const BridgeTimeInfo& bridgeTimeInfo(fShmRtClientControl.data->timeInfo); | |||
fServer.playing = bridgeTimeInfo.playing; | |||
fServer.position.frame = bridgeTimeInfo.frame; | |||
fServer.position.frame = static_cast<jack_nframes_t>(bridgeTimeInfo.frame); | |||
fServer.position.usecs = bridgeTimeInfo.usecs; | |||
if (bridgeTimeInfo.validFlags & kPluginBridgeTimeInfoValidBBT) | |||
@@ -687,7 +694,7 @@ bool CarlaJackAppClient::handleRtData() | |||
} | |||
if (i < fServer.numAudioIns) | |||
{ | |||
const std::size_t remainingBufferSize = fServer.bufferSize * (fServer.numAudioIns - i); | |||
const std::size_t remainingBufferSize = fServer.bufferSize * static_cast<uint8_t>(fServer.numAudioIns - i); | |||
//fdataReal += remainingBufferSize; | |||
fdataCopy += remainingBufferSize; | |||
} | |||
@@ -715,7 +722,7 @@ bool CarlaJackAppClient::handleRtData() | |||
} | |||
if (i < fServer.numAudioOuts) | |||
{ | |||
const std::size_t remainingBufferSize = fServer.bufferSize * (fServer.numAudioOuts - i); | |||
const std::size_t remainingBufferSize = fServer.bufferSize * static_cast<uint8_t>(fServer.numAudioOuts - i); | |||
carla_zeroFloats(fdataCopy, remainingBufferSize); | |||
//fdataCopy += remainingBufferSize; | |||
} | |||
@@ -1158,15 +1165,24 @@ void CarlaJackAppClient::runNonRealtimeThread() | |||
carla_debug("CarlaJackAppClient runNonRealtimeThread FINISHED"); | |||
} | |||
CARLA_BACKEND_END_NAMESPACE | |||
// --------------------------------------------------------------------------------------------------------------------- | |||
using CarlaBackend::CarlaJackAppClient; | |||
using CarlaBackend::JackClientState; | |||
static CarlaJackAppClient gClient; | |||
CARLA_BACKEND_START_NAMESPACE | |||
static int carla_interposed_callback(int cb_action, void* ptr) | |||
{ | |||
return gClient.handleInterposerCallback(cb_action, ptr); | |||
} | |||
CARLA_BACKEND_END_NAMESPACE | |||
// --------------------------------------------------------------------------------------------------------------------- | |||
CARLA_EXPORT | |||
@@ -1247,8 +1263,6 @@ pthread_t jack_client_thread_id(jack_client_t* client) | |||
return jackAppPtr->getRealtimeThreadId(); | |||
} | |||
CARLA_BACKEND_END_NAMESPACE | |||
// --------------------------------------------------------------------------------------------------------------------- | |||
#include "jackbridge/JackBridge2.cpp" | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
* Carla JACK API for external applications | |||
* Copyright (C) 2016-2017 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
@@ -44,7 +44,7 @@ | |||
#endif | |||
// must be last include | |||
#include "jackbridge/JackBridge.hpp" | |||
#include "api.hpp" | |||
// small check to not hurt myself | |||
#ifdef JACKBRIDGE_DIRECT | |||
@@ -100,7 +100,7 @@ struct JackPortState { | |||
const char* fullname; | |||
void* buffer; | |||
uint index; | |||
uint flags; | |||
int flags; | |||
jack_uuid_t uuid; | |||
bool isMidi : 1; | |||
bool isSystem : 1; | |||
@@ -119,7 +119,7 @@ struct JackPortState { | |||
isConnected(false), | |||
unused(false) {} | |||
JackPortState(const char* const clientName, const char* const portName, const uint i, const uint f, | |||
JackPortState(const char* const clientName, const char* const portName, const uint i, const int f, | |||
const bool midi, const bool sys, const bool con) | |||
: name(portName != nullptr ? strdup(portName) : nullptr), | |||
fullname(nullptr), | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
* Carla JACK API for external applications | |||
* Copyright (C) 2016-2017 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
@@ -17,10 +17,6 @@ | |||
#include "libjack.hpp" | |||
#define JACK_UUID_SIZE 36 | |||
#define JACK_UUID_STRING_SIZE (JACK_UUID_SIZE+1) /* includes trailing null */ | |||
#define JACK_UUID_EMPTY_INITIALIZER 0 | |||
CARLA_BACKEND_USE_NAMESPACE | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
* Carla JACK API for external applications | |||
* Copyright (C) 2016-2017 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
@@ -23,7 +23,7 @@ CARLA_BACKEND_USE_NAMESPACE | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
const char* allocate_port_name(const char* const prefix, const uint32_t num) | |||
static const char* allocate_port_name(const char* const prefix, const uint num) | |||
{ | |||
static CarlaStringList portList; | |||
@@ -39,6 +39,8 @@ const char* allocate_port_name(const char* const prefix, const uint32_t num) | |||
return portList.getLast(); | |||
} | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
CARLA_EXPORT | |||
const char** jack_get_ports(jack_client_t* client, const char* a, const char* b, unsigned long flags) | |||
{ | |||
@@ -49,21 +51,21 @@ const char** jack_get_ports(jack_client_t* client, const char* a, const char* b, | |||
const JackServerState& jserver(jclient->server); | |||
const uint32_t numIns = jserver.numAudioIns + jserver.numMidiIns; | |||
const uint32_t numOuts = jserver.numAudioOuts + jserver.numMidiOuts; | |||
const uint numIns = static_cast<uint>(jserver.numAudioIns + jserver.numMidiIns); | |||
const uint numOuts = static_cast<uint>(jserver.numAudioOuts + jserver.numMidiOuts); | |||
if (flags == 0 || (flags & (JackPortIsInput|JackPortIsOutput)) == (JackPortIsInput|JackPortIsOutput)) | |||
{ | |||
if (const char** const ret = (const char**)calloc(numIns+numOuts, sizeof(const char*))) | |||
{ | |||
uint32_t i=0; | |||
for (uint32_t j=0; j<jserver.numAudioIns; ++i, ++j) | |||
uint i=0; | |||
for (uint j=0; j<jserver.numAudioIns; ++i, ++j) | |||
ret[i] = allocate_port_name("system:capture_", j); | |||
for (uint32_t j=0; j<jserver.numAudioOuts; ++i, ++j) | |||
for (uint j=0; j<jserver.numAudioOuts; ++i, ++j) | |||
ret[i] = allocate_port_name("system:playback_", j); | |||
for (uint32_t j=0; j<jserver.numMidiIns; ++i, ++j) | |||
for (uint j=0; j<jserver.numMidiIns; ++i, ++j) | |||
ret[i] = allocate_port_name("system:midi_capture_", j); | |||
for (uint32_t j=0; j<jserver.numMidiOuts; ++i, ++j) | |||
for (uint j=0; j<jserver.numMidiOuts; ++i, ++j) | |||
ret[i] = allocate_port_name("system:midi_playback_", j); | |||
return ret; | |||
@@ -74,10 +76,10 @@ const char** jack_get_ports(jack_client_t* client, const char* a, const char* b, | |||
{ | |||
if (const char** const ret = (const char**)calloc(numIns, sizeof(const char*))) | |||
{ | |||
uint32_t i=0; | |||
for (uint32_t j=0; j<jserver.numAudioOuts; ++i, ++j) | |||
uint i=0; | |||
for (uint j=0; j<jserver.numAudioOuts; ++i, ++j) | |||
ret[i] = allocate_port_name("system:playback_", j); | |||
for (uint32_t j=0; j<jserver.numMidiOuts; ++i, ++j) | |||
for (uint j=0; j<jserver.numMidiOuts; ++i, ++j) | |||
ret[i] = allocate_port_name("system:midi_playback_", j); | |||
return ret; | |||
@@ -88,10 +90,10 @@ const char** jack_get_ports(jack_client_t* client, const char* a, const char* b, | |||
{ | |||
if (const char** const ret = (const char**)calloc(numOuts, sizeof(const char*))) | |||
{ | |||
uint32_t i=0; | |||
for (uint32_t j=0; j<jserver.numAudioIns; ++i, ++j) | |||
uint i=0; | |||
for (uint j=0; j<jserver.numAudioIns; ++i, ++j) | |||
ret[i] = allocate_port_name("system:capture_", j); | |||
for (uint32_t j=0; j<jserver.numMidiIns; ++i, ++j) | |||
for (uint j=0; j<jserver.numMidiIns; ++i, ++j) | |||
ret[i] = allocate_port_name("system:midi_capture_", j); | |||
return ret; | |||
@@ -107,7 +109,7 @@ jack_port_t* jack_port_by_name(jack_client_t* client, const char* name) | |||
carla_debug("%s(%p, %s)", __FUNCTION__, client, name); | |||
JackClientState* const jclient = (JackClientState*)client; | |||
CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 0); | |||
CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, nullptr); | |||
if (std::strncmp(name, "system:", 7) == 0) | |||
{ | |||
@@ -141,7 +143,7 @@ jack_port_t* jack_port_by_name(jack_client_t* client, const char* name) | |||
const int index = std::atoi(name)-1; | |||
CARLA_SAFE_ASSERT_RETURN(index >= 0 && index < jserver.numAudioIns, nullptr); | |||
retPort.index = index; | |||
retPort.index = static_cast<uint>(index); | |||
retPort.flags = commonFlags|JackPortIsOutput; | |||
retPort.isMidi = false; | |||
retPort.isConnected = jserver.numAudioIns > index; | |||
@@ -153,7 +155,7 @@ jack_port_t* jack_port_by_name(jack_client_t* client, const char* name) | |||
const int index = std::atoi(name)-1; | |||
CARLA_SAFE_ASSERT_RETURN(index >= 0 && index < jserver.numAudioOuts, nullptr); | |||
retPort.index = (jserver.numAudioIns) + index; | |||
retPort.index = static_cast<uint>(jserver.numAudioIns + index); | |||
retPort.flags = commonFlags|JackPortIsInput; | |||
retPort.isMidi = false; | |||
retPort.isConnected = jserver.numAudioOuts > index; | |||
@@ -165,7 +167,7 @@ jack_port_t* jack_port_by_name(jack_client_t* client, const char* name) | |||
const int index = std::atoi(name)-1; | |||
CARLA_SAFE_ASSERT_RETURN(index >= 0 && index < jserver.numMidiIns, nullptr); | |||
retPort.index = index; | |||
retPort.index = static_cast<uint>(index); | |||
retPort.flags = commonFlags|JackPortIsOutput; | |||
retPort.isMidi = true; | |||
retPort.isConnected = jserver.numMidiIns > index; | |||
@@ -177,7 +179,7 @@ jack_port_t* jack_port_by_name(jack_client_t* client, const char* name) | |||
const int index = std::atoi(name)-1; | |||
CARLA_SAFE_ASSERT_RETURN(index >= 0 && index < jserver.numMidiOuts, nullptr); | |||
retPort.index = (jserver.numAudioIns) + index; | |||
retPort.index = static_cast<uint>(jserver.numMidiIns + index); | |||
retPort.flags = commonFlags|JackPortIsInput; | |||
retPort.isMidi = true; | |||
retPort.isConnected = jserver.numMidiOuts > index; | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
* Carla JACK API for external applications | |||
* Copyright (C) 2016-2018 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
@@ -40,7 +40,9 @@ jack_port_t* jack_port_register(jack_client_t* client, const char* port_name, co | |||
if (flags & JackPortIsInput) | |||
{ | |||
const std::size_t index = jclient->audioIns.count(); | |||
JackPortState* const port = new JackPortState(jclient->name, port_name, index, flags, | |||
JackPortState* const port = new JackPortState(jclient->name, port_name, | |||
static_cast<uint>(index), | |||
static_cast<int>(flags), | |||
false, false, index < jserver.numAudioIns); | |||
{ | |||
@@ -55,7 +57,9 @@ jack_port_t* jack_port_register(jack_client_t* client, const char* port_name, co | |||
if (flags & JackPortIsOutput) | |||
{ | |||
const std::size_t index = jclient->audioOuts.count(); | |||
JackPortState* const port = new JackPortState(jclient->name, port_name, index, flags, | |||
JackPortState* const port = new JackPortState(jclient->name, port_name, | |||
static_cast<uint>(index), | |||
static_cast<int>(flags), | |||
false, false, index < jserver.numAudioOuts); | |||
{ | |||
@@ -76,7 +80,9 @@ jack_port_t* jack_port_register(jack_client_t* client, const char* port_name, co | |||
if (flags & JackPortIsInput) | |||
{ | |||
const std::size_t index = jclient->midiIns.count(); | |||
JackPortState* const port = new JackPortState(jclient->name, port_name, index, flags, | |||
JackPortState* const port = new JackPortState(jclient->name, port_name, | |||
static_cast<uint>(index), | |||
static_cast<int>(flags), | |||
true, false, index < jserver.numMidiIns); | |||
{ | |||
@@ -91,7 +97,9 @@ jack_port_t* jack_port_register(jack_client_t* client, const char* port_name, co | |||
if (flags & JackPortIsOutput) | |||
{ | |||
const std::size_t index = jclient->midiOuts.count(); | |||
JackPortState* const port = new JackPortState(jclient->name, port_name, index, flags, | |||
JackPortState* const port = new JackPortState(jclient->name, port_name, | |||
static_cast<uint>(index), | |||
static_cast<int>(flags), | |||
true, false, index < jserver.numMidiOuts); | |||
{ | |||
@@ -183,7 +191,7 @@ jack_uuid_t jack_port_uuid(const jack_port_t* port) | |||
{ | |||
carla_debug("%s(%p)", __FUNCTION__, port); | |||
JackPortState* const jport = (JackPortState*)port; | |||
const JackPortState* const jport = (const JackPortState*)port; | |||
CARLA_SAFE_ASSERT_RETURN(jport != nullptr, 0); | |||
return jport->uuid; | |||
@@ -194,7 +202,7 @@ const char* jack_port_name(const jack_port_t* port) | |||
{ | |||
carla_debug("%s(%p)", __FUNCTION__, port); | |||
JackPortState* const jport = (JackPortState*)port; | |||
const JackPortState* const jport = (const JackPortState*)port; | |||
CARLA_SAFE_ASSERT_RETURN(jport != nullptr, nullptr); | |||
return jport->fullname; | |||
@@ -205,7 +213,7 @@ const char* jack_port_short_name(const jack_port_t* port) | |||
{ | |||
carla_debug("%s(%p)", __FUNCTION__, port); | |||
JackPortState* const jport = (JackPortState*)port; | |||
const JackPortState* const jport = (const JackPortState*)port; | |||
CARLA_SAFE_ASSERT_RETURN(jport != nullptr, nullptr); | |||
return jport->name; | |||
@@ -216,7 +224,7 @@ int jack_port_flags(const jack_port_t* port) | |||
{ | |||
carla_debug("%s(%p)", __FUNCTION__, port); | |||
JackPortState* const jport = (JackPortState*)port; | |||
const JackPortState* const jport = (const JackPortState*)port; | |||
CARLA_SAFE_ASSERT_RETURN(jport != nullptr, 0); | |||
return jport->flags; | |||
@@ -227,7 +235,7 @@ const char* jack_port_type(const jack_port_t* port) | |||
{ | |||
carla_debug("%s(%p)", __FUNCTION__, port); | |||
JackPortState* const jport = (JackPortState*)port; | |||
const JackPortState* const jport = (const JackPortState*)port; | |||
CARLA_SAFE_ASSERT_RETURN(jport != nullptr, nullptr); | |||
static const char* const kAudioType = JACK_DEFAULT_AUDIO_TYPE; | |||
@@ -241,7 +249,7 @@ uint32_t jack_port_type_id(const jack_port_t* port) | |||
{ | |||
carla_debug("%s(%p)", __FUNCTION__, port); | |||
JackPortState* const jport = (JackPortState*)port; | |||
const JackPortState* const jport = (const JackPortState*)port; | |||
CARLA_SAFE_ASSERT_RETURN(jport != nullptr, 0); | |||
return jport->isMidi ? 1 : 0; | |||
@@ -252,7 +260,7 @@ uint32_t jack_port_type_id(const jack_port_t* port) | |||
CARLA_EXPORT | |||
int jack_port_is_mine(const jack_client_t*, const jack_port_t* port) | |||
{ | |||
JackPortState* const jport = (JackPortState*)port; | |||
const JackPortState* const jport = (const JackPortState*)port; | |||
CARLA_SAFE_ASSERT_RETURN(jport != nullptr, 0); | |||
return jport->isSystem ? 0 : 1; | |||
@@ -261,7 +269,7 @@ int jack_port_is_mine(const jack_client_t*, const jack_port_t* port) | |||
CARLA_EXPORT | |||
int jack_port_connected(const jack_port_t* port) | |||
{ | |||
JackPortState* const jport = (JackPortState*)port; | |||
const JackPortState* const jport = (const JackPortState*)port; | |||
CARLA_SAFE_ASSERT_RETURN(jport != nullptr, 0); | |||
return jport->isConnected ? 1 : 0; | |||
@@ -272,7 +280,7 @@ int jack_port_connected_to(const jack_port_t* port, const char* port_name) | |||
{ | |||
carla_stderr2("%s(%p, %s) WIP", __FUNCTION__, port, port_name); | |||
JackPortState* const jport = (JackPortState*)port; | |||
const JackPortState* const jport = (const JackPortState*)port; | |||
CARLA_SAFE_ASSERT_RETURN(jport != nullptr, 0); | |||
if (! jport->isConnected) | |||
@@ -382,10 +390,10 @@ int jack_port_unset_alias(jack_port_t* port, const char* alias) | |||
} | |||
CARLA_EXPORT | |||
int jack_port_get_aliases(const jack_port_t*, const char* aliases[2]) | |||
int jack_port_get_aliases(const jack_port_t*, char* const aliases[2]) | |||
{ | |||
static const char nullChar = '\0'; | |||
aliases[0] = aliases[1] = &nullChar; | |||
*aliases[0] = '\0'; | |||
*aliases[1] = '\0'; | |||
return 0; | |||
} | |||
@@ -51,7 +51,7 @@ jack_nframes_t jack_get_sample_rate(jack_client_t* client) | |||
JackClientState* const jclient = (JackClientState*)client; | |||
CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 0); | |||
return jclient->server.sampleRate; | |||
return static_cast<jack_nframes_t>(jclient->server.sampleRate); | |||
} | |||
CARLA_EXPORT | |||
@@ -38,7 +38,7 @@ jack_nframes_t jack_frame_time(const jack_client_t* client) | |||
CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 0); | |||
// FIXME | |||
return jclient->server.position.usecs; | |||
return static_cast<jack_nframes_t>(jclient->server.position.usecs); | |||
} | |||
CARLA_EXPORT | |||
@@ -48,7 +48,7 @@ jack_nframes_t jack_last_frame_time(const jack_client_t* client) | |||
CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 0); | |||
// FIXME | |||
return jclient->server.position.usecs; | |||
return static_cast<jack_nframes_t>(jclient->server.position.usecs); | |||
} | |||
// int jack_get_cycle_times(const jack_client_t *client, | |||
@@ -65,7 +65,7 @@ jack_time_t jack_frames_to_time(const jack_client_t* client, jack_nframes_t fram | |||
const JackClientState* const jclient = (const JackClientState*)client; | |||
CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 0); | |||
return static_cast<double>(frames) / jclient->server.sampleRate * 1000000.0; | |||
return static_cast<jack_time_t>(static_cast<double>(frames) / jclient->server.sampleRate * 1000000.0); | |||
} | |||
CARLA_EXPORT | |||
@@ -74,7 +74,7 @@ jack_nframes_t jack_time_to_frames(const jack_client_t* client, jack_time_t time | |||
const JackClientState* const jclient = (const JackClientState*)client; | |||
CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 0); | |||
return static_cast<double>(time) / 1000000.0 * jclient->server.sampleRate; | |||
return static_cast<jack_nframes_t>(static_cast<double>(time) / 1000000.0 * jclient->server.sampleRate); | |||
} | |||
CARLA_EXPORT | |||
@@ -82,7 +82,7 @@ jack_time_t jack_get_time(void) | |||
{ | |||
timespec t; | |||
clock_gettime(CLOCK_MONOTONIC, &t); | |||
return t.tv_sec * 1000000 + t.tv_nsec / 1000; | |||
return static_cast<jack_time_t>(t.tv_sec * 1000000 + t.tv_nsec / 1000); | |||
} | |||
// -------------------------------------------------------------------------------------------------------------------- |
@@ -87,7 +87,7 @@ int jack_transport_locate(jack_client_t* client, jack_nframes_t frame) | |||
CARLA_EXPORT | |||
jack_transport_state_t jack_transport_query(const jack_client_t* client, jack_position_t* pos) | |||
{ | |||
if (const JackClientState* const jclient = (JackClientState*)client) | |||
if (const JackClientState* const jclient = (const JackClientState*)client) | |||
{ | |||
const JackServerState& jserver(jclient->server); | |||
@@ -106,7 +106,7 @@ jack_transport_state_t jack_transport_query(const jack_client_t* client, jack_po | |||
CARLA_EXPORT | |||
jack_nframes_t jack_get_current_transport_frame(const jack_client_t* client) | |||
{ | |||
if (const JackClientState* const jclient = (JackClientState*)client) | |||
if (const JackClientState* const jclient = (const JackClientState*)client) | |||
return jclient->server.position.frame; | |||
return 0; | |||