@@ -540,11 +540,9 @@ def transport_reposition_struct(self, position):
540
540
effect in two process cycles. If there are slow-sync clients
541
541
and the transport is already rolling, it will enter the
542
542
`STARTING` state and begin invoking their sync callbacks
543
- (see `jack_set_sync_callback ()`__ ) until ready.
543
+ (see `set_sync_callback ()`) until ready.
544
544
This function is realtime-safe.
545
545
546
- __ http://jackaudio.org/files/docs/html/group__TransportControl.html
547
-
548
546
Parameters
549
547
----------
550
548
position : jack_position_t
@@ -559,6 +557,29 @@ def transport_reposition_struct(self, position):
559
557
_check (_lib .jack_transport_reposition (self ._ptr , position ),
560
558
'Error re-positioning transport' )
561
559
560
+ def set_sync_timeout (self , timeout ):
561
+ """Set the timeout value for slow-sync clients.
562
+
563
+ This timeout prevents unresponsive slow-sync clients from
564
+ completely halting the transport mechanism. The default is two
565
+ seconds. When the timeout expires, the transport starts
566
+ rolling, even if some slow-sync clients are still unready.
567
+ The *sync callbacks* of these clients continue being invoked,
568
+ giving them a chance to catch up.
569
+
570
+ Parameters
571
+ ----------
572
+ timeout : int
573
+ Delay (in microseconds) before the timeout expires.
574
+
575
+ See Also
576
+ --------
577
+ set_sync_callback
578
+
579
+ """
580
+ _check (_lib .jack_set_sync_timeout (self ._ptr , timeout ),
581
+ 'Error setting sync timeout' )
582
+
562
583
def set_freewheel (self , onoff ):
563
584
"""Start/Stop JACK's "freewheel" mode.
564
585
@@ -1175,6 +1196,67 @@ def callback_wrapper(_):
1175
1196
self ._ptr , callback_wrapper , _ffi .NULL ),
1176
1197
'Error setting xrun callback' )
1177
1198
1199
+ def set_sync_callback (self , callback ):
1200
+ """Register (or unregister) as a slow-sync client.
1201
+
1202
+ A slow-sync client is one that cannot respond immediately to
1203
+ transport position changes.
1204
+
1205
+ The *callback* will be invoked at the first available
1206
+ opportunity after its registration is complete. If the client
1207
+ is currently active this will be the following process cycle,
1208
+ otherwise it will be the first cycle after calling `activate()`.
1209
+ After that, it runs whenever some client requests a new
1210
+ position, or the transport enters the `STARTING` state.
1211
+ While the client is active, this callback is invoked just before
1212
+ the *process callback* (see `set_process_callback()`) in the
1213
+ same thread.
1214
+
1215
+ Clients that don't set a *sync callback* are assumed to be ready
1216
+ immediately any time the transport wants to start.
1217
+
1218
+ Parameters
1219
+ ----------
1220
+ callback : callable or None
1221
+
1222
+ User-supplied function that returns ``True`` when the
1223
+ slow-sync client is ready. This realtime function must not
1224
+ wait. It must have this signature::
1225
+
1226
+ callback(state: int, pos: jack_position_t) -> bool
1227
+
1228
+ The *state* argument will be:
1229
+
1230
+ - `STOPPED` when a new position is requested;
1231
+ - `STARTING` when the transport is waiting to start;
1232
+ - `ROLLING` when the timeout has expired, and the position
1233
+ is now a moving target.
1234
+
1235
+ The *pos* argument holds the new transport position using
1236
+ the same structure as returned by
1237
+ `transport_query_struct()`.
1238
+
1239
+ Setting *callback* to ``None`` declares that this
1240
+ client no longer requires slow-sync processing.
1241
+
1242
+ See Also
1243
+ --------
1244
+ set_sync_timeout
1245
+
1246
+ """
1247
+ if callback is None :
1248
+ callback_wrapper = _ffi .NULL
1249
+ else :
1250
+
1251
+ @self ._callback ('JackSyncCallback' , error = False )
1252
+ def callback_wrapper (state , pos , _ ):
1253
+ return callback (state , pos )
1254
+
1255
+ _check (
1256
+ _lib .jack_set_sync_callback (
1257
+ self ._ptr , callback_wrapper , _ffi .NULL ),
1258
+ 'Error setting sync callback' )
1259
+
1178
1260
def set_timebase_callback (self , callback = None , conditional = False ):
1179
1261
"""Register as timebase master for the JACK subsystem.
1180
1262
0 commit comments