From bc12040a6cc8efd11285721e75479baff57848da Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 25 Apr 2013 00:05:17 +0100 Subject: [PATCH] Windows build fixes --- .../backend/engine/rtaudio-4.0.12/RtAudio.cpp | 103 ++++++++++-------- source/backend/engine/rtmidi-2.0.1/RtMidi.cpp | 3 + source/backend/native/Makefile | 6 +- source/backend/native/nekofilter.c | 9 ++ source/backend/native/nekofilter/nekofilter.c | 12 +- source/backend/standalone/CarlaStandalone.cpp | 2 +- source/libs/jackbridge/JackBridge.hpp | 3 + source/libs/jackbridge/JackBridge1.cpp | 17 +++ 8 files changed, 102 insertions(+), 53 deletions(-) diff --git a/source/backend/engine/rtaudio-4.0.12/RtAudio.cpp b/source/backend/engine/rtaudio-4.0.12/RtAudio.cpp index 4b600bdb7..5ae643609 100644 --- a/source/backend/engine/rtaudio-4.0.12/RtAudio.cpp +++ b/source/backend/engine/rtaudio-4.0.12/RtAudio.cpp @@ -1818,9 +1818,10 @@ const char* RtApiCore :: getErrorCode( OSStatus code ) // devices are available (i.e., the JACK server is not running), a // stream cannot be opened. -#include +#include "jackbridge/JackBridge.hpp" #include #include +#include // A structure to hold various information related to the Jack API // implementation. @@ -1842,7 +1843,7 @@ static void jackSilentError( const char * ) {}; RtApiJack :: RtApiJack() { // Nothing to do here. -#if !defined(__RTAUDIO_DEBUG__) +#if 0 // Turn off Jack's internal error reporting. jack_set_error_function( &jackSilentError ); #endif @@ -1858,13 +1859,13 @@ unsigned int RtApiJack :: getDeviceCount( void ) // See if we can become a jack client. jack_options_t options = (jack_options_t) ( JackNoStartServer ); //JackNullOption; jack_status_t *status = NULL; - jack_client_t *client = jack_client_open( "RtApiJackCount", options, status ); + jack_client_t *client = jackbridge_client_open( "RtApiJackCount", options, status ); if ( client == 0 ) return 0; const char **ports; std::string port, previousPort; unsigned int nChannels = 0, nDevices = 0; - ports = jack_get_ports( client, NULL, NULL, 0 ); + ports = jackbridge_get_ports( client, NULL, NULL, 0 ); if ( ports ) { // Parse the port names up to the first colon (:). size_t iColon = 0; @@ -1882,7 +1883,7 @@ unsigned int RtApiJack :: getDeviceCount( void ) free( ports ); } - jack_client_close( client ); + jackbridge_client_close( client ); return nDevices; } @@ -1893,7 +1894,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device ) jack_options_t options = (jack_options_t) ( JackNoStartServer ); //JackNullOption jack_status_t *status = NULL; - jack_client_t *client = jack_client_open( "RtApiJackInfo", options, status ); + jack_client_t *client = jackbridge_client_open( "RtApiJackInfo", options, status ); if ( client == 0 ) { errorText_ = "RtApiJack::getDeviceInfo: Jack server not found or connection error!"; error( RtError::WARNING ); @@ -1903,7 +1904,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device ) const char **ports; std::string port, previousPort; unsigned int nPorts = 0, nDevices = 0; - ports = jack_get_ports( client, NULL, NULL, 0 ); + ports = jackbridge_get_ports( client, NULL, NULL, 0 ); if ( ports ) { // Parse the port names up to the first colon (:). size_t iColon = 0; @@ -1923,7 +1924,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device ) } if ( device >= nDevices ) { - jack_client_close( client ); + jackbridge_client_close( client ); errorText_ = "RtApiJack::getDeviceInfo: device ID is invalid!"; error( RtError::INVALID_USE ); return info; @@ -1931,12 +1932,12 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device ) // Get the current jack server sample rate. info.sampleRates.clear(); - info.sampleRates.push_back( jack_get_sample_rate( client ) ); + info.sampleRates.push_back( jackbridge_get_sample_rate( client ) ); // Count the available ports containing the client name as device // channels. Jack "input ports" equal RtAudio output channels. unsigned int nChannels = 0; - ports = jack_get_ports( client, info.name.c_str(), NULL, JackPortIsInput ); + ports = jackbridge_get_ports( client, info.name.c_str(), NULL, JackPortIsInput ); if ( ports ) { while ( ports[ nChannels ] ) nChannels++; free( ports ); @@ -1945,7 +1946,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device ) // Jack "output ports" equal RtAudio input channels. nChannels = 0; - ports = jack_get_ports( client, info.name.c_str(), NULL, JackPortIsOutput ); + ports = jackbridge_get_ports( client, info.name.c_str(), NULL, JackPortIsOutput ); if ( ports ) { while ( ports[ nChannels ] ) nChannels++; free( ports ); @@ -1953,7 +1954,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device ) } if ( info.outputChannels == 0 && info.inputChannels == 0 ) { - jack_client_close(client); + jackbridge_client_close(client); errorText_ = "RtApiJack::getDeviceInfo: error determining Jack input/output channels!"; error( RtError::WARNING ); return info; @@ -1972,7 +1973,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device ) if ( device == 0 && info.inputChannels > 0 ) info.isDefaultInput = true; - jack_client_close(client); + jackbridge_client_close(client); info.probed = true; return info; } @@ -1999,6 +2000,9 @@ static void *jackCloseStream( void *ptr ) object->closeStream(); pthread_exit( NULL ); +#ifdef CARLA_OS_WIN + return NULL; +#endif } static void jackShutdown( void *infoPointer ) { @@ -2012,7 +2016,7 @@ static void jackShutdown( void *infoPointer ) // other problem occurred and we should close the stream. if ( object->isStreamRunning() == false ) return; - ThreadHandle threadId; + pthread_t threadId; pthread_create( &threadId, NULL, jackCloseStream, info ); std::cerr << "\nRtApiJack: the Jack server is shutting down this client ... stream stopped and closed!!\n" << std::endl; } @@ -2040,9 +2044,9 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne jack_options_t jackoptions = (jack_options_t) ( JackNoStartServer ); //JackNullOption; jack_status_t *status = NULL; if ( options && !options->streamName.empty() ) - client = jack_client_open( options->streamName.c_str(), jackoptions, status ); + client = jackbridge_client_open( options->streamName.c_str(), jackoptions, status ); else - client = jack_client_open( "RtApiJack", jackoptions, status ); + client = jackbridge_client_open( "RtApiJack", jackoptions, status ); if ( client == 0 ) { errorText_ = "RtApiJack::probeDeviceOpen: Jack server not found or connection error!"; error( RtError::WARNING ); @@ -2057,7 +2061,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne const char **ports; std::string port, previousPort, deviceName; unsigned int nPorts = 0, nDevices = 0; - ports = jack_get_ports( client, NULL, NULL, 0 ); + ports = jackbridge_get_ports( client, NULL, NULL, 0 ); if ( ports ) { // Parse the port names up to the first colon (:). size_t iColon = 0; @@ -2086,7 +2090,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne unsigned int nChannels = 0; unsigned long flag = JackPortIsInput; if ( mode == INPUT ) flag = JackPortIsOutput; - ports = jack_get_ports( client, deviceName.c_str(), NULL, flag ); + ports = jackbridge_get_ports( client, deviceName.c_str(), NULL, flag ); if ( ports ) { while ( ports[ nChannels ] ) nChannels++; free( ports ); @@ -2100,9 +2104,9 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne } // Check the jack server sample rate. - unsigned int jackRate = jack_get_sample_rate( client ); + unsigned int jackRate = jackbridge_get_sample_rate( client ); if ( sampleRate != jackRate ) { - jack_client_close( client ); + jackbridge_client_close( client ); errorStream_ << "RtApiJack::probeDeviceOpen: the requested sample rate (" << sampleRate << ") is different than the JACK server rate (" << jackRate << ")."; errorText_ = errorStream_.str(); return FAILURE; @@ -2110,17 +2114,17 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne stream_.sampleRate = jackRate; // Get the latency of the JACK port. - ports = jack_get_ports( client, deviceName.c_str(), NULL, flag ); + ports = jackbridge_get_ports( client, deviceName.c_str(), NULL, flag ); if ( ports[ firstChannel ] ) { // Added by Ge Wang jack_latency_callback_mode_t cbmode = (mode == INPUT ? JackCaptureLatency : JackPlaybackLatency); // the range (usually the min and max are equal) jack_latency_range_t latrange; latrange.min = latrange.max = 0; // get the latency range - jack_port_get_latency_range( jack_port_by_name( client, ports[firstChannel] ), cbmode, &latrange ); + jackbridge_port_get_latency_range( jackbridge_port_by_name( client, ports[firstChannel] ), cbmode, &latrange ); // be optimistic, use the min! stream_.latency[mode] = latrange.min; - //stream_.latency[mode] = jack_port_get_latency( jack_port_by_name( client, ports[ firstChannel ] ) ); + //stream_.latency[mode] = jackbridge_port_get_latency( jackbridge_port_by_name( client, ports[ firstChannel ] ) ); } free( ports ); @@ -2139,7 +2143,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne // Get the buffer size. The buffer size and number of buffers // (periods) is set when the jack server is started. - stream_.bufferSize = (int) jack_get_buffer_size( client ); + stream_.bufferSize = (int) jackbridge_get_buffer_size( client ); *bufferSize = stream_.bufferSize; stream_.nDeviceChannels[mode] = channels; @@ -2222,9 +2226,9 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne stream_.mode = DUPLEX; else { stream_.mode = mode; - jack_set_process_callback( handle->client, jackCallbackHandler, (void *) &stream_.callbackInfo ); - jack_set_xrun_callback( handle->client, jackXrun, (void *) &handle ); - jack_on_shutdown( handle->client, jackShutdown, (void *) &stream_.callbackInfo ); + jackbridge_set_process_callback( handle->client, jackCallbackHandler, (void *) &stream_.callbackInfo ); + jackbridge_set_xrun_callback( handle->client, jackXrun, (void *) &handle ); + jackbridge_on_shutdown( handle->client, jackShutdown, (void *) &stream_.callbackInfo ); } // Register our ports. @@ -2232,14 +2236,14 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne if ( mode == OUTPUT ) { for ( unsigned int i=0; iports[0][i] = jack_port_register( handle->client, (const char *)label, + handle->ports[0][i] = jackbridge_port_register( handle->client, (const char *)label, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ); } } else { for ( unsigned int i=0; iports[1][i] = jack_port_register( handle->client, (const char *)label, + handle->ports[1][i] = jackbridge_port_register( handle->client, (const char *)label, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0 ); } } @@ -2254,7 +2258,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne error: if ( handle ) { pthread_cond_destroy( &handle->condition ); - jack_client_close( handle->client ); + jackbridge_client_close( handle->client ); if ( handle->ports[0] ) free( handle->ports[0] ); if ( handle->ports[1] ) free( handle->ports[1] ); @@ -2290,9 +2294,9 @@ void RtApiJack :: closeStream( void ) if ( handle ) { if ( stream_.state == STREAM_RUNNING ) - jack_deactivate( handle->client ); + jackbridge_deactivate( handle->client ); - jack_client_close( handle->client ); + jackbridge_client_close( handle->client ); } if ( handle ) { @@ -2329,7 +2333,7 @@ void RtApiJack :: startStream( void ) } JackHandle *handle = (JackHandle *) stream_.apiHandle; - int result = jack_activate( handle->client ); + int result = jackbridge_activate( handle->client ); if ( result ) { errorText_ = "RtApiJack::startStream(): unable to activate JACK client!"; goto unlock; @@ -2340,7 +2344,7 @@ void RtApiJack :: startStream( void ) // Get the list of available ports. if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) { result = 1; - ports = jack_get_ports( handle->client, handle->deviceName[0].c_str(), NULL, JackPortIsInput); + ports = jackbridge_get_ports( handle->client, handle->deviceName[0].c_str(), NULL, JackPortIsInput); if ( ports == NULL) { errorText_ = "RtApiJack::startStream(): error determining available JACK input ports!"; goto unlock; @@ -2352,7 +2356,7 @@ void RtApiJack :: startStream( void ) for ( unsigned int i=0; iclient, jack_port_name( handle->ports[0][i] ), ports[ stream_.channelOffset[0] + i ] ); + result = jackbridge_connect( handle->client, jackbridge_port_name( handle->ports[0][i] ), ports[ stream_.channelOffset[0] + i ] ); if ( result ) { free( ports ); errorText_ = "RtApiJack::startStream(): error connecting output ports!"; @@ -2364,7 +2368,7 @@ void RtApiJack :: startStream( void ) if ( stream_.mode == INPUT || stream_.mode == DUPLEX ) { result = 1; - ports = jack_get_ports( handle->client, handle->deviceName[1].c_str(), NULL, JackPortIsOutput ); + ports = jackbridge_get_ports( handle->client, handle->deviceName[1].c_str(), NULL, JackPortIsOutput ); if ( ports == NULL) { errorText_ = "RtApiJack::startStream(): error determining available JACK output ports!"; goto unlock; @@ -2374,7 +2378,7 @@ void RtApiJack :: startStream( void ) for ( unsigned int i=0; iclient, ports[ stream_.channelOffset[1] + i ], jack_port_name( handle->ports[1][i] ) ); + result = jackbridge_connect( handle->client, ports[ stream_.channelOffset[1] + i ], jackbridge_port_name( handle->ports[1][i] ) ); if ( result ) { free( ports ); errorText_ = "RtApiJack::startStream(): error connecting input ports!"; @@ -2407,11 +2411,15 @@ void RtApiJack :: stopStream( void ) if ( handle->drainCounter == 0 ) { handle->drainCounter = 2; +#ifdef CARLA_OS_WIN // FIXME + Sleep(500); //ms +#else pthread_cond_wait( &handle->condition, &stream_.mutex ); // block until signaled +#endif } } - jack_deactivate( handle->client ); + jackbridge_deactivate( handle->client ); stream_.state = STREAM_STOPPED; } @@ -2433,7 +2441,7 @@ void RtApiJack :: abortStream( void ) // This function will be called by a spawned thread when the user // callback function signals that the stream should be stopped or // aborted. It is necessary to handle it this way because the -// callbackEvent() function must return before the jack_deactivate() +// callbackEvent() function must return before the jackbridge_deactivate() // function will return. static void *jackStopStream( void *ptr ) { @@ -2442,6 +2450,9 @@ static void *jackStopStream( void *ptr ) object->stopStream(); pthread_exit( NULL ); +#ifdef CARLA_OS_WIN + return NULL; +#endif } bool RtApiJack :: callbackEvent( unsigned long nframes ) @@ -2463,7 +2474,7 @@ bool RtApiJack :: callbackEvent( unsigned long nframes ) // Check if we were draining the stream and signal is finished. if ( handle->drainCounter > 3 ) { - ThreadHandle threadId; + pthread_t threadId; stream_.state = STREAM_STOPPING; if ( handle->internalDrain == true ) @@ -2491,7 +2502,7 @@ bool RtApiJack :: callbackEvent( unsigned long nframes ) if ( cbReturnValue == 2 ) { stream_.state = STREAM_STOPPING; handle->drainCounter = 2; - ThreadHandle id; + pthread_t id; pthread_create( &id, NULL, jackStopStream, info ); return SUCCESS; } @@ -2508,7 +2519,7 @@ bool RtApiJack :: callbackEvent( unsigned long nframes ) if ( handle->drainCounter > 1 ) { // write zeros to the output stream for ( unsigned int i=0; iports[0][i], (jack_nframes_t) nframes ); + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[0][i], (jack_nframes_t) nframes ); memset( jackbuffer, 0, bufferBytes ); } @@ -2518,13 +2529,13 @@ bool RtApiJack :: callbackEvent( unsigned long nframes ) convertBuffer( stream_.deviceBuffer, stream_.userBuffer[0], stream_.convertInfo[0] ); for ( unsigned int i=0; iports[0][i], (jack_nframes_t) nframes ); + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[0][i], (jack_nframes_t) nframes ); memcpy( jackbuffer, &stream_.deviceBuffer[i*bufferBytes], bufferBytes ); } } else { // no buffer conversion for ( unsigned int i=0; iports[0][i], (jack_nframes_t) nframes ); + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[0][i], (jack_nframes_t) nframes ); memcpy( jackbuffer, &stream_.userBuffer[0][i*bufferBytes], bufferBytes ); } } @@ -2539,14 +2550,14 @@ bool RtApiJack :: callbackEvent( unsigned long nframes ) if ( stream_.doConvertBuffer[1] ) { for ( unsigned int i=0; iports[1][i], (jack_nframes_t) nframes ); + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[1][i], (jack_nframes_t) nframes ); memcpy( &stream_.deviceBuffer[i*bufferBytes], jackbuffer, bufferBytes ); } convertBuffer( stream_.userBuffer[1], stream_.deviceBuffer, stream_.convertInfo[1] ); } else { // no buffer conversion for ( unsigned int i=0; iports[1][i], (jack_nframes_t) nframes ); + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[1][i], (jack_nframes_t) nframes ); memcpy( &stream_.userBuffer[1][i*bufferBytes], jackbuffer, bufferBytes ); } } diff --git a/source/backend/engine/rtmidi-2.0.1/RtMidi.cpp b/source/backend/engine/rtmidi-2.0.1/RtMidi.cpp index 1fab6ee66..9a59d1c73 100644 --- a/source/backend/engine/rtmidi-2.0.1/RtMidi.cpp +++ b/source/backend/engine/rtmidi-2.0.1/RtMidi.cpp @@ -41,6 +41,9 @@ #include "RtMidi.h" #include +// not used +#undef __UNIX_JACK__ + //*********************************************************************// // RtMidi Definitions //*********************************************************************// diff --git a/source/backend/native/Makefile b/source/backend/native/Makefile index 307877da6..67ebed98f 100644 --- a/source/backend/native/Makefile +++ b/source/backend/native/Makefile @@ -60,13 +60,9 @@ OBJS = \ midi-split.c.o \ midi-through.c.o \ midi-transpose.c.o \ + nekofilter.c.o \ sunvox-file.cpp.o -ifneq ($(WIN32),true) -OBJS += \ - nekofilter.c.o -endif - # Carla OBJS += \ carla.cpp.o diff --git a/source/backend/native/nekofilter.c b/source/backend/native/nekofilter.c index 983c53f42..1142e3c26 100644 --- a/source/backend/native/nekofilter.c +++ b/source/backend/native/nekofilter.c @@ -57,12 +57,21 @@ static const PluginDescriptor nekofilterDesc = { .set_midi_program = NULL, .set_custom_data = NULL, +#if defined(__linux__) || defined(__linux) .ui_show = nekofilter_ui_show, .ui_idle = nekofilter_ui_idle, .ui_set_parameter_value = nekofilter_ui_set_parameter_value, .ui_set_midi_program = NULL, .ui_set_custom_data = NULL, +#else + .ui_show = NULL, + .ui_idle = NULL, + + .ui_set_parameter_value = NULL, + .ui_set_midi_program = NULL, + .ui_set_custom_data = NULL, +#endif .activate = NULL, .deactivate = NULL, diff --git a/source/backend/native/nekofilter/nekofilter.c b/source/backend/native/nekofilter/nekofilter.c index 23b1cb4b0..550df1843 100644 --- a/source/backend/native/nekofilter/nekofilter.c +++ b/source/backend/native/nekofilter/nekofilter.c @@ -32,7 +32,9 @@ #define LOG_LEVEL LOG_LEVEL_ERROR #include "log.h" -#include "ui.c" +#if defined(__linux__) || defined(__linux) +# include "ui.c" +#endif #define BANDS_COUNT 4 @@ -42,7 +44,9 @@ struct nekofilter float params_global[GLOBAL_PARAMETERS_COUNT]; float params_bands[BAND_PARAMETERS_COUNT*BANDS_COUNT]; HostDescriptor* host; +#if defined(__linux__) || defined(__linux) struct control* ui; +#endif }; PluginHandle @@ -62,7 +66,9 @@ nekofilter_instantiate( } nekofilter_ptr->host = host; +#if defined(__linux__) || defined(__linux) nekofilter_ptr->ui = NULL; +#endif if (!filter_create(host->get_sample_rate(host->handle), BANDS_COUNT, &nekofilter_ptr->filter)) { @@ -346,6 +352,7 @@ nekofilter_process( (void)midiEvents; } +#if defined(__linux__) || defined(__linux) void nekofilter_ui_show( PluginHandle handle, bool show) @@ -376,16 +383,19 @@ void nekofilter_ui_set_parameter_value( if (nekofilter_ptr->ui != NULL) nekoui_set_parameter_value(nekofilter_ptr->ui, index, value); } +#endif void nekofilter_cleanup( PluginHandle handle) { +#if defined(__linux__) || defined(__linux) if (nekofilter_ptr->ui != NULL) { nekoui_quit(nekofilter_ptr->ui); nekoui_cleanup(nekofilter_ptr->ui); } +#endif filter_destroy(nekofilter_ptr->filter); free(nekofilter_ptr); diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index 76774f632..a922f7474 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -31,7 +31,7 @@ # include #endif -#if defined(NDEBUG) && ! defined(BUILD_BRIDGE) +#if defined(NDEBUG) && ! (defined(CARLA_OS_WIN) || defined(BUILD_BRIDGE)) # define WANT_LOGS # include # include diff --git a/source/libs/jackbridge/JackBridge.hpp b/source/libs/jackbridge/JackBridge.hpp index d19364c35..9e0c50ecd 100644 --- a/source/libs/jackbridge/JackBridge.hpp +++ b/source/libs/jackbridge/JackBridge.hpp @@ -107,6 +107,7 @@ typedef uint32_t jack_port_id_t; typedef uint64_t jack_time_t; typedef uint64_t jack_unique_t; typedef unsigned char jack_midi_data_t; +typedef float jack_default_audio_sample_t; typedef enum JackOptions jack_options_t; typedef enum JackStatus jack_status_t; @@ -166,6 +167,7 @@ typedef void (*JackClientRegistrationCallback)(const char* name, int register_, typedef void (*JackPortConnectCallback)(jack_port_id_t a, jack_port_id_t b, int connect, void* arg); typedef int (*JackPortRenameCallback)(jack_port_id_t port, const char* old_name, const char* new_name, void *arg); typedef void (*JackFreewheelCallback)(int starting, void *arg); +typedef int (*JackXRunCallback)(void* arg); typedef void (*JackShutdownCallback)(void *arg); #endif // ! JACKBRIDGE_DIRECT @@ -190,6 +192,7 @@ CARLA_EXPORT bool jackbridge_set_port_registration_callback (jack_client_t* clie CARLA_EXPORT bool jackbridge_set_port_connect_callback (jack_client_t* client, JackPortConnectCallback connect_callback, void* arg); CARLA_EXPORT bool jackbridge_set_port_rename_callback (jack_client_t* client, JackPortRenameCallback rename_callback, void* arg); CARLA_EXPORT bool jackbridge_set_latency_callback(jack_client_t* client, JackLatencyCallback latency_callback, void* arg); +CARLA_EXPORT bool jackbridge_set_xrun_callback(jack_client_t* client, JackXRunCallback xrun_callback, void* arg); CARLA_EXPORT jack_nframes_t jackbridge_get_sample_rate(jack_client_t* client); CARLA_EXPORT jack_nframes_t jackbridge_get_buffer_size(jack_client_t* client); diff --git a/source/libs/jackbridge/JackBridge1.cpp b/source/libs/jackbridge/JackBridge1.cpp index b950c825d..24185009d 100644 --- a/source/libs/jackbridge/JackBridge1.cpp +++ b/source/libs/jackbridge/JackBridge1.cpp @@ -42,6 +42,7 @@ typedef int (*jacksym_set_port_registration_callback)(jack_client_t*, JackPortR typedef int (*jacksym_set_port_connect_callback)(jack_client_t*, JackPortConnectCallback, void*); typedef int (*jacksym_set_port_rename_callback)(jack_client_t*, JackPortRenameCallback, void*); typedef int (*jacksym_set_latency_callback)(jack_client_t*, JackLatencyCallback, void*); +typedef int (*jacksym_set_xrun_callback)(jack_client_t*, JackXRunCallback, void*); typedef jack_nframes_t (*jacksym_get_sample_rate)(jack_client_t*); typedef jack_nframes_t (*jacksym_get_buffer_size)(jack_client_t*); @@ -104,6 +105,7 @@ struct JackBridge { jacksym_set_port_connect_callback set_port_connect_callback_ptr; jacksym_set_port_rename_callback set_port_rename_callback_ptr; jacksym_set_latency_callback set_latency_callback_ptr; + jacksym_set_xrun_callback set_xrun_callback_ptr; jacksym_get_sample_rate get_sample_rate_ptr; jacksym_get_buffer_size get_buffer_size_ptr; jacksym_port_register port_register_ptr; @@ -157,6 +159,7 @@ struct JackBridge { set_port_connect_callback_ptr(nullptr), set_port_rename_callback_ptr(nullptr), set_latency_callback_ptr(nullptr), + set_xrun_callback_ptr(nullptr), get_sample_rate_ptr(nullptr), get_buffer_size_ptr(nullptr), port_register_ptr(nullptr), @@ -229,6 +232,7 @@ struct JackBridge { LIB_SYMBOL(set_port_connect_callback) LIB_SYMBOL(set_port_rename_callback) LIB_SYMBOL(set_latency_callback) + LIB_SYMBOL(set_xrun_callback) LIB_SYMBOL(get_sample_rate) LIB_SYMBOL(get_buffer_size) LIB_SYMBOL(port_register) @@ -520,6 +524,19 @@ bool jackbridge_set_latency_callback(jack_client_t* client, JackLatencyCallback #endif } +bool jackbridge_set_xrun_callback(jack_client_t* client, JackXRunCallback xrun_callback, void* arg) +{ +#if JACKBRIDGE_DUMMY + return false; +#elif JACKBRIDGE_DIRECT + return (jack_set_xrun_callback(client, xrun_callback, arg) == 0); +#else + if (bridge.set_xrun_callback_ptr != nullptr) + return (bridge.set_xrun_callback_ptr(client, xrun_callback, arg) == 0); + return false; +#endif +} + // ----------------------------------------------------------------------------- jack_nframes_t jackbridge_get_sample_rate(jack_client_t* client)