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 // --------------------------------------------------------------------------------------------------------------------
25 int jack_engine_takeover_timebase(jack_client_t
* client
)
27 carla_debug("%s(%p)", __FUNCTION__
, client
);
34 // --------------------------------------------------------------------------------------------------------------------
37 int jack_release_timebase(jack_client_t
* client
)
39 carla_debug("%s(%p)", __FUNCTION__
, client
);
47 int jack_set_sync_callback(jack_client_t
* client
, JackSyncCallback callback
, void* arg
)
49 carla_debug("%s(%p, %p, %p)", __FUNCTION__
, client
, callback
, arg
);
51 JackClientState
* const jclient
= (JackClientState
*)client
;
52 CARLA_SAFE_ASSERT_RETURN(jclient
!= nullptr, 1);
54 const CarlaMutexLocker
cms(jclient
->mutex
);
56 jclient
->syncCb
= callback
;
57 jclient
->syncCbPtr
= arg
;
62 int jack_set_sync_timeout(jack_client_t
* client
, jack_time_t timeout
)
64 carla_stderr2("%s(%p, " P_UINT64
")", __FUNCTION__
, client
, timeout
);
69 int jack_set_timebase_callback(jack_client_t
* client
, int conditional
, JackTimebaseCallback callback
, void* arg
)
71 carla_debug("%s(%p, %i, %p, %p)", __FUNCTION__
, client
, conditional
, callback
, arg
);
72 return conditional
? EBUSY
: 0;
81 int jack_transport_locate(jack_client_t
* client
, jack_nframes_t frame
)
83 carla_stderr2("%s(%p, %u)", __FUNCTION__
, client
, frame
);
88 jack_transport_state_t
jack_transport_query(const jack_client_t
* client
, jack_position_t
* pos
)
90 if (const JackClientState
* const jclient
= (const JackClientState
*)client
)
92 const JackServerState
& jserver(jclient
->server
);
95 std::memcpy(pos
, &jserver
.position
, sizeof(jack_position_t
));
97 return jserver
.playing
? JackTransportRolling
: JackTransportStopped
;
101 std::memset(pos
, 0, sizeof(jack_position_t
));
103 return JackTransportStopped
;
107 jack_nframes_t
jack_get_current_transport_frame(const jack_client_t
* client
)
109 if (const JackClientState
* const jclient
= (const JackClientState
*)client
)
110 return jclient
->server
.position
.frame
;
116 int jack_transport_reposition(jack_client_t
* client
, const jack_position_t
* pos
)
118 carla_stderr2("%s(%p, %p)", __FUNCTION__
, client
, pos
);
123 void jack_transport_start(jack_client_t
* client
)
125 carla_stderr2("%s(%p)", __FUNCTION__
, client
);
129 void jack_transport_stop(jack_client_t
* client
)
131 carla_stderr2("%s(%p)", __FUNCTION__
, client
);
134 // --------------------------------------------------------------------------------------------------------------------
137 void jack_get_transport_info(jack_client_t
* client
, void* tinfo
)
139 carla_stderr2("%s(%p, %p)", __FUNCTION__
, client
, tinfo
);
143 void jack_set_transport_info(jack_client_t
* client
, void* tinfo
)
145 carla_stderr2("%s(%p, %p)", __FUNCTION__
, client
, tinfo
);
148 // --------------------------------------------------------------------------------------------------------------------