From 2b71a249f4fc537cacc99039fdc92049d7c1f353 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 8 Feb 2019 17:56:06 +0100 Subject: [PATCH] Strict build pass for libjack, small fixes and adjustments Signed-off-by: falkTX --- .travis/script-linux-strict.sh | 3 - source/bridges-ui/CarlaBridgeToolkitQt.cpp | 2 + source/libjack/api.hpp | 236 +++++++++++++++++++++ source/libjack/libjack.cpp | 30 ++- source/libjack/libjack.hpp | 8 +- source/libjack/libjack_metadata.cpp | 6 +- source/libjack/libjack_port-searching.cpp | 42 ++-- source/libjack/libjack_ports.cpp | 42 ++-- source/libjack/libjack_server-control.cpp | 2 +- source/libjack/libjack_time.cpp | 10 +- source/libjack/libjack_transport.cpp | 4 +- 11 files changed, 320 insertions(+), 65 deletions(-) create mode 100644 source/libjack/api.hpp diff --git a/.travis/script-linux-strict.sh b/.travis/script-linux-strict.sh index 61b341c3f..0bbf93dad 100755 --- a/.travis/script-linux-strict.sh +++ b/.travis/script-linux-strict.sh @@ -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 diff --git a/source/bridges-ui/CarlaBridgeToolkitQt.cpp b/source/bridges-ui/CarlaBridgeToolkitQt.cpp index 971dc654b..c13870dba 100644 --- a/source/bridges-ui/CarlaBridgeToolkitQt.cpp +++ b/source/bridges-ui/CarlaBridgeToolkitQt.cpp @@ -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" diff --git a/source/libjack/api.hpp b/source/libjack/api.hpp new file mode 100644 index 000000000..ff0282f5e --- /dev/null +++ b/source/libjack/api.hpp @@ -0,0 +1,236 @@ +/* + * Carla JACK API for external applications + * Copyright (C) 2016-2019 Filipe Coelho + * + * 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 + +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 diff --git a/source/libjack/libjack.cpp b/source/libjack/libjack.cpp index 851b3e11e..411d0e42b 100644 --- a/source/libjack/libjack.cpp +++ b/source/libjack/libjack.cpp @@ -23,6 +23,8 @@ #include #include +// --------------------------------------------------------------------------------------------------------------------- + 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(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(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(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" diff --git a/source/libjack/libjack.hpp b/source/libjack/libjack.hpp index 2397b67fd..a34fcf5a8 100644 --- a/source/libjack/libjack.hpp +++ b/source/libjack/libjack.hpp @@ -1,6 +1,6 @@ /* * Carla JACK API for external applications - * Copyright (C) 2016-2017 Filipe Coelho + * Copyright (C) 2016-2019 Filipe Coelho * * 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), diff --git a/source/libjack/libjack_metadata.cpp b/source/libjack/libjack_metadata.cpp index 735648200..e97bccaa9 100644 --- a/source/libjack/libjack_metadata.cpp +++ b/source/libjack/libjack_metadata.cpp @@ -1,6 +1,6 @@ /* * Carla JACK API for external applications - * Copyright (C) 2016-2017 Filipe Coelho + * Copyright (C) 2016-2019 Filipe Coelho * * 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 // -------------------------------------------------------------------------------------------------------------------- diff --git a/source/libjack/libjack_port-searching.cpp b/source/libjack/libjack_port-searching.cpp index d6cf765cb..81005f344 100644 --- a/source/libjack/libjack_port-searching.cpp +++ b/source/libjack/libjack_port-searching.cpp @@ -1,6 +1,6 @@ /* * Carla JACK API for external applications - * Copyright (C) 2016-2017 Filipe Coelho + * Copyright (C) 2016-2019 Filipe Coelho * * 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(jserver.numAudioIns + jserver.numMidiIns); + const uint numOuts = static_cast(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= 0 && index < jserver.numAudioIns, nullptr); - retPort.index = index; + retPort.index = static_cast(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(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(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(jserver.numMidiIns + index); retPort.flags = commonFlags|JackPortIsInput; retPort.isMidi = true; retPort.isConnected = jserver.numMidiOuts > index; diff --git a/source/libjack/libjack_ports.cpp b/source/libjack/libjack_ports.cpp index 28f0f8a52..a6474cf9d 100644 --- a/source/libjack/libjack_ports.cpp +++ b/source/libjack/libjack_ports.cpp @@ -1,6 +1,6 @@ /* * Carla JACK API for external applications - * Copyright (C) 2016-2018 Filipe Coelho + * Copyright (C) 2016-2019 Filipe Coelho * * 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(index), + static_cast(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(index), + static_cast(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(index), + static_cast(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(index), + static_cast(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; } diff --git a/source/libjack/libjack_server-control.cpp b/source/libjack/libjack_server-control.cpp index 3f479750f..e78d91307 100644 --- a/source/libjack/libjack_server-control.cpp +++ b/source/libjack/libjack_server-control.cpp @@ -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(jclient->server.sampleRate); } CARLA_EXPORT diff --git a/source/libjack/libjack_time.cpp b/source/libjack/libjack_time.cpp index bb727b907..c36426562 100644 --- a/source/libjack/libjack_time.cpp +++ b/source/libjack/libjack_time.cpp @@ -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(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(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(frames) / jclient->server.sampleRate * 1000000.0; + return static_cast(static_cast(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(time) / 1000000.0 * jclient->server.sampleRate; + return static_cast(static_cast(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(t.tv_sec * 1000000 + t.tv_nsec / 1000); } // -------------------------------------------------------------------------------------------------------------------- diff --git a/source/libjack/libjack_transport.cpp b/source/libjack/libjack_transport.cpp index 26baeb59b..d7b406a7d 100644 --- a/source/libjack/libjack_transport.cpp +++ b/source/libjack/libjack_transport.cpp @@ -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;