Fix crash with clap plugins without MIDI input
[carla.git] / source / libjack / libjack_callbacks.cpp
blobc591fa06bca1e5f5cf7a2feed3d795816bced067
1 /*
2 * Carla JACK API for external applications
3 * Copyright (C) 2016-2022 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #include "libjack.hpp"
20 CARLA_BACKEND_USE_NAMESPACE
22 // --------------------------------------------------------------------------------------------------------------------
24 CARLA_PLUGIN_EXPORT
25 int jack_set_thread_init_callback(jack_client_t* client, JackThreadInitCallback callback, void* arg)
27 carla_debug("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
29 JackClientState* const jclient = (JackClientState*)client;
30 CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 1);
32 const CarlaMutexLocker cms(jclient->mutex);
34 jclient->threadInitCb = callback;
35 jclient->threadInitCbPtr = arg;
36 return 0;
39 CARLA_PLUGIN_EXPORT
40 void jack_on_shutdown(jack_client_t* client, JackShutdownCallback callback, void* arg)
42 carla_debug("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
44 JackClientState* const jclient = (JackClientState*)client;
45 CARLA_SAFE_ASSERT_RETURN(jclient != nullptr,);
47 const CarlaMutexLocker cms(jclient->mutex);
49 jclient->shutdownCb = callback;
50 jclient->shutdownCbPtr = arg;
53 CARLA_PLUGIN_EXPORT
54 void jack_on_info_shutdown(jack_client_t* client, JackInfoShutdownCallback callback, void* arg)
56 carla_debug("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
58 JackClientState* const jclient = (JackClientState*)client;
59 CARLA_SAFE_ASSERT_RETURN(jclient != nullptr,);
61 const CarlaMutexLocker cms(jclient->mutex);
63 jclient->infoShutdownCb = callback;
64 jclient->infoShutdownCbPtr = arg;
67 CARLA_PLUGIN_EXPORT
68 int jack_set_process_callback(jack_client_t* client, JackProcessCallback callback, void* arg)
70 carla_debug("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
72 JackClientState* const jclient = (JackClientState*)client;
73 CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 1);
75 const CarlaMutexLocker cms(jclient->mutex);
77 jclient->processCb = callback;
78 jclient->processCbPtr = arg;
79 return 0;
82 CARLA_PLUGIN_EXPORT
83 int jack_set_freewheel_callback(jack_client_t* client, JackFreewheelCallback callback, void* arg)
85 carla_debug("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
87 JackClientState* const jclient = (JackClientState*)client;
88 CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 1);
90 const CarlaMutexLocker cms(jclient->mutex);
92 jclient->freewheelCb = callback;
93 jclient->freewheelCbPtr = arg;
94 return 0;
97 CARLA_PLUGIN_EXPORT
98 int jack_set_buffer_size_callback(jack_client_t* client, JackBufferSizeCallback callback, void* arg)
100 carla_debug("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
102 JackClientState* const jclient = (JackClientState*)client;
103 CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 1);
105 const CarlaMutexLocker cms(jclient->mutex);
107 jclient->bufferSizeCb = callback;
108 jclient->bufferSizeCbPtr = arg;
109 return 0;
112 CARLA_PLUGIN_EXPORT
113 int jack_set_sample_rate_callback(jack_client_t* client, JackSampleRateCallback callback, void* arg)
115 carla_debug("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
117 JackClientState* const jclient = (JackClientState*)client;
118 CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 1);
120 const CarlaMutexLocker cms(jclient->mutex);
122 jclient->sampleRateCb = callback;
123 jclient->sampleRateCbPtr = arg;
124 return 0;
127 CARLA_PLUGIN_EXPORT
128 int jack_set_client_registration_callback(jack_client_t* client, JackClientRegistrationCallback callback, void* arg)
130 carla_stderr2("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
131 return 0;
134 CARLA_PLUGIN_EXPORT
135 int jack_set_port_registration_callback(jack_client_t* client, JackPortRegistrationCallback callback, void* arg)
137 carla_stderr2("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
138 return 0;
141 CARLA_PLUGIN_EXPORT
142 int jack_set_port_connect_callback(jack_client_t* client, JackPortConnectCallback callback, void* arg)
144 carla_stderr2("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
145 return 0;
148 CARLA_PLUGIN_EXPORT
149 int jack_set_port_rename_callback(jack_client_t* client, JackPortRenameCallback callback, void* arg)
151 carla_stderr2("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
152 return 0;
155 CARLA_PLUGIN_EXPORT
156 int jack_set_graph_order_callback(jack_client_t* client, JackGraphOrderCallback callback, void* arg)
158 carla_stderr2("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
159 return 0;
162 CARLA_PLUGIN_EXPORT
163 int jack_set_xrun_callback(jack_client_t* client, JackXRunCallback callback, void* arg)
165 carla_stderr2("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
166 return 0;
169 // --------------------------------------------------------------------------------------------------------------------