~hitmuri/vjpirate/trunk

« back to all changes in this revision

Viewing changes to os/mac/include/jack/types.h

  • Committer: Florent Berthaut
  • Date: 2014-07-26 18:53:16 UTC
  • mfrom: (5.1.12 mac)
  • Revision ID: flo@localhost.localdomain-20140726185316-c2ucnwmgm5kij4e2
Merged mac branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (C) 2001 Paul Davis
 
3
  Copyright (C) 2004 Jack O'Quin
 
4
 
 
5
  This program is free software; you can redistribute it and/or modify
 
6
  it under the terms of the GNU Lesser General Public License as published by
 
7
  the Free Software Foundation; either version 2.1 of the License, or
 
8
  (at your option) any later version.
 
9
 
 
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 Lesser General Public License for more details.
 
14
 
 
15
  You should have received a copy of the GNU Lesser General Public License
 
16
  along with this program; if not, write to the Free Software
 
17
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 
 
19
*/
 
20
 
 
21
#ifndef __jack_types_h__
 
22
#define __jack_types_h__
 
23
 
 
24
#include <jack/systemdeps.h>
 
25
 
 
26
typedef int32_t jack_shmsize_t;
 
27
 
 
28
/**
 
29
 * Type used to represent sample frame counts.
 
30
 */
 
31
typedef uint32_t        jack_nframes_t;
 
32
 
 
33
/**
 
34
 * Maximum value that can be stored in jack_nframes_t
 
35
 */
 
36
#define JACK_MAX_FRAMES (4294967295U)   /* This should be UINT32_MAX, but C++ has a problem with that. */
 
37
 
 
38
/**
 
39
 * Type used to represent the value of free running
 
40
 * monotonic clock with units of microseconds.
 
41
 */
 
42
typedef uint64_t jack_time_t;
 
43
 
 
44
/**
 
45
 *  Maximum size of @a load_init string passed to an internal client
 
46
 *  jack_initialize() function via jack_internal_client_load().
 
47
 */
 
48
#define JACK_LOAD_INIT_LIMIT 1024
 
49
 
 
50
/**
 
51
 *  jack_intclient_t is an opaque type representing a loaded internal
 
52
 *  client.  You may only access it using the API provided in @ref
 
53
 *  intclient.h "<jack/intclient.h>".
 
54
 */
 
55
typedef uint64_t jack_intclient_t;
 
56
 
 
57
/**
 
58
 *  jack_port_t is an opaque type.  You may only access it using the
 
59
 *  API provided.
 
60
 */
 
61
typedef struct _jack_port jack_port_t;
 
62
 
 
63
/**
 
64
 *  jack_client_t is an opaque type.  You may only access it using the
 
65
 *  API provided.
 
66
 */
 
67
typedef struct _jack_client jack_client_t;
 
68
 
 
69
/**
 
70
 *  Ports have unique ids. A port registration callback is the only
 
71
 *  place you ever need to know their value.
 
72
 */
 
73
typedef uint32_t jack_port_id_t;
 
74
 
 
75
typedef uint32_t jack_port_type_id_t;
 
76
 
 
77
/**
 
78
 *  @ref jack_options_t bits
 
79
 */
 
80
enum JackOptions {
 
81
 
 
82
    /**
 
83
     * Null value to use when no option bits are needed.
 
84
     */
 
85
    JackNullOption = 0x00,
 
86
 
 
87
    /**
 
88
     * Do not automatically start the JACK server when it is not
 
89
     * already running.  This option is always selected if
 
90
     * \$JACK_NO_START_SERVER is defined in the calling process
 
91
     * environment.
 
92
     */
 
93
    JackNoStartServer = 0x01,
 
94
 
 
95
    /**
 
96
     * Use the exact client name requested.  Otherwise, JACK
 
97
     * automatically generates a unique one, if needed.
 
98
     */
 
99
    JackUseExactName = 0x02,
 
100
 
 
101
    /**
 
102
     * Open with optional <em>(char *) server_name</em> parameter.
 
103
     */
 
104
    JackServerName = 0x04,
 
105
 
 
106
    /**
 
107
     * Load internal client from optional <em>(char *)
 
108
     * load_name</em>.  Otherwise use the @a client_name.
 
109
     */
 
110
    JackLoadName = 0x08,
 
111
 
 
112
    /**
 
113
     * Pass optional <em>(char *) load_init</em> string to the
 
114
     * jack_initialize() entry point of an internal client.
 
115
     */
 
116
    JackLoadInit = 0x10,
 
117
 
 
118
     /**
 
119
      * pass a SessionID Token this allows the sessionmanager to identify the client again.
 
120
      */
 
121
    JackSessionID = 0x20
 
122
};
 
123
 
 
124
/** Valid options for opening an external client. */
 
125
#define JackOpenOptions (JackSessionID|JackServerName|JackNoStartServer|JackUseExactName)
 
126
 
 
127
/** Valid options for loading an internal client. */
 
128
#define JackLoadOptions (JackLoadInit|JackLoadName|JackUseExactName)
 
129
 
 
130
/**
 
131
 *  Options for several JACK operations, formed by OR-ing together the
 
132
 *  relevant @ref JackOptions bits.
 
133
 */
 
134
typedef enum JackOptions jack_options_t;
 
135
 
 
136
/**
 
137
 *  @ref jack_status_t bits
 
138
 */
 
139
enum JackStatus {
 
140
 
 
141
    /**
 
142
     * Overall operation failed.
 
143
     */
 
144
    JackFailure = 0x01,
 
145
 
 
146
    /**
 
147
     * The operation contained an invalid or unsupported option.
 
148
     */
 
149
    JackInvalidOption = 0x02,
 
150
 
 
151
    /**
 
152
     * The desired client name was not unique.  With the @ref
 
153
     * JackUseExactName option this situation is fatal.  Otherwise,
 
154
     * the name was modified by appending a dash and a two-digit
 
155
     * number in the range "-01" to "-99".  The
 
156
     * jack_get_client_name() function will return the exact string
 
157
     * that was used.  If the specified @a client_name plus these
 
158
     * extra characters would be too long, the open fails instead.
 
159
     */
 
160
    JackNameNotUnique = 0x04,
 
161
 
 
162
    /**
 
163
     * The JACK server was started as a result of this operation.
 
164
     * Otherwise, it was running already.  In either case the caller
 
165
     * is now connected to jackd, so there is no race condition.
 
166
     * When the server shuts down, the client will find out.
 
167
     */
 
168
    JackServerStarted = 0x08,
 
169
 
 
170
    /**
 
171
     * Unable to connect to the JACK server.
 
172
     */
 
173
    JackServerFailed = 0x10,
 
174
 
 
175
    /**
 
176
     * Communication error with the JACK server.
 
177
     */
 
178
    JackServerError = 0x20,
 
179
 
 
180
    /**
 
181
     * Requested client does not exist.
 
182
     */
 
183
    JackNoSuchClient = 0x40,
 
184
 
 
185
    /**
 
186
     * Unable to load internal client
 
187
     */
 
188
    JackLoadFailure = 0x80,
 
189
 
 
190
    /**
 
191
     * Unable to initialize client
 
192
     */
 
193
    JackInitFailure = 0x100,
 
194
 
 
195
    /**
 
196
     * Unable to access shared memory
 
197
     */
 
198
    JackShmFailure = 0x200,
 
199
 
 
200
    /**
 
201
     * Client's protocol version does not match
 
202
     */
 
203
    JackVersionError = 0x400,
 
204
 
 
205
    /**
 
206
     * Backend error
 
207
     */
 
208
    JackBackendError = 0x800,
 
209
 
 
210
    /**
 
211
     * Client zombified failure
 
212
     */
 
213
    JackClientZombie = 0x1000
 
214
};
 
215
 
 
216
/**
 
217
 *  Status word returned from several JACK operations, formed by
 
218
 *  OR-ing together the relevant @ref JackStatus bits.
 
219
 */
 
220
typedef enum JackStatus jack_status_t;
 
221
 
 
222
/**
 
223
 *  @ref jack_latency_callback_mode_t
 
224
 */
 
225
enum JackLatencyCallbackMode {
 
226
 
 
227
     /**
 
228
      * Latency Callback for Capture Latency.
 
229
      * Input Ports have their latency value setup.
 
230
      * In the Callback the client needs to set the latency of the output ports
 
231
      */
 
232
     JackCaptureLatency,
 
233
 
 
234
     /**
 
235
      * Latency Callback for Playback Latency.
 
236
      * Output Ports have their latency value setup.
 
237
      * In the Callback the client needs to set the latency of the input ports
 
238
      */
 
239
     JackPlaybackLatency
 
240
 
 
241
};
 
242
 
 
243
/**
 
244
 *  Type of Latency Callback (Capture or Playback)
 
245
 */
 
246
typedef enum JackLatencyCallbackMode jack_latency_callback_mode_t;
 
247
 
 
248
/**
 
249
 * Prototype for the client supplied function that is called
 
250
 * by the engine when port latencies need to be recalculated
 
251
 *
 
252
 * @param mode playback or capture latency
 
253
 * @param arg pointer to a client supplied data
 
254
 *
 
255
 * @return zero on success, non-zero on error
 
256
 */
 
257
typedef void (*JackLatencyCallback)(jack_latency_callback_mode_t mode, void *arg);
 
258
 
 
259
/**
 
260
 * the new latency API operates on Ranges.
 
261
 */
 
262
struct _jack_latency_range
 
263
{
 
264
    /**
 
265
     * minimum latency
 
266
     */
 
267
    jack_nframes_t min;
 
268
    /**
 
269
     * maximum latency
 
270
     */
 
271
    jack_nframes_t max;
 
272
};
 
273
 
 
274
typedef struct _jack_latency_range jack_latency_range_t;
 
275
 
 
276
/**
 
277
 * Prototype for the client supplied function that is called
 
278
 * by the engine anytime there is work to be done.
 
279
 *
 
280
 * @pre nframes == jack_get_buffer_size()
 
281
 * @pre nframes == pow(2,x)
 
282
 *
 
283
 * @param nframes number of frames to process
 
284
 * @param arg pointer to a client supplied structure
 
285
 *
 
286
 * @return zero on success, non-zero on error
 
287
 */
 
288
typedef int (*JackProcessCallback)(jack_nframes_t nframes, void *arg);
 
289
 
 
290
/**
 
291
 * Prototype for the client thread routine called
 
292
 * by the engine when the client is inserted in the graph.
 
293
 *
 
294
 * @param arg pointer to a client supplied structure
 
295
 *
 
296
 */
 
297
typedef void *(*JackThreadCallback)(void* arg);
 
298
 
 
299
/**
 
300
 * Prototype for the client supplied function that is called
 
301
 * once after the creation of the thread in which other
 
302
 * callbacks will be made. Special thread characteristics
 
303
 * can be set from this callback, for example. This is a
 
304
 * highly specialized callback and most clients will not
 
305
 * and should not use it.
 
306
 *
 
307
 * @param arg pointer to a client supplied structure
 
308
 *
 
309
 * @return void
 
310
 */
 
311
typedef void (*JackThreadInitCallback)(void *arg);
 
312
 
 
313
/**
 
314
 * Prototype for the client supplied function that is called
 
315
 * whenever the processing graph is reordered.
 
316
 *
 
317
 * @param arg pointer to a client supplied structure
 
318
 *
 
319
 * @return zero on success, non-zero on error
 
320
 */
 
321
typedef int (*JackGraphOrderCallback)(void *arg);
 
322
 
 
323
/**
 
324
 * Prototype for the client-supplied function that is called whenever
 
325
 * an xrun has occured.
 
326
 *
 
327
 * @see jack_get_xrun_delayed_usecs()
 
328
 *
 
329
 * @param arg pointer to a client supplied structure
 
330
 *
 
331
 * @return zero on success, non-zero on error
 
332
 */
 
333
typedef int (*JackXRunCallback)(void *arg);
 
334
 
 
335
/**
 
336
 * Prototype for the @a bufsize_callback that is invoked whenever the
 
337
 * JACK engine buffer size changes.  Although this function is called
 
338
 * in the JACK process thread, the normal process cycle is suspended
 
339
 * during its operation, causing a gap in the audio flow.  So, the @a
 
340
 * bufsize_callback can allocate storage, touch memory not previously
 
341
 * referenced, and perform other operations that are not realtime
 
342
 * safe.
 
343
 *
 
344
 * @param nframes buffer size
 
345
 * @param arg pointer supplied by jack_set_buffer_size_callback().
 
346
 *
 
347
 * @return zero on success, non-zero on error
 
348
 */
 
349
typedef int (*JackBufferSizeCallback)(jack_nframes_t nframes, void *arg);
 
350
 
 
351
/**
 
352
 * Prototype for the client supplied function that is called
 
353
 * when the engine sample rate changes.
 
354
 *
 
355
 * @param nframes new engine sample rate
 
356
 * @param arg pointer to a client supplied structure
 
357
 *
 
358
 * @return zero on success, non-zero on error
 
359
 */
 
360
typedef int (*JackSampleRateCallback)(jack_nframes_t nframes, void *arg);
 
361
 
 
362
/**
 
363
 * Prototype for the client supplied function that is called
 
364
 * whenever a port is registered or unregistered.
 
365
 *
 
366
 * @param port the ID of the port
 
367
 * @param arg pointer to a client supplied data
 
368
 * @param register non-zero if the port is being registered,
 
369
 *                     zero if the port is being unregistered
 
370
 */
 
371
typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int register, void *arg);
 
372
 
 
373
/**
 
374
 * Prototype for the client supplied function that is called
 
375
 * whenever a client is registered or unregistered.
 
376
 *
 
377
 * @param name a null-terminated string containing the client name
 
378
 * @param register non-zero if the client is being registered,
 
379
 *                     zero if the client is being unregistered
 
380
 * @param arg pointer to a client supplied structure
 
381
 */
 
382
typedef void (*JackClientRegistrationCallback)(const char* name, int register, void *arg);
 
383
 
 
384
/**
 
385
 * Prototype for the client supplied function that is called
 
386
 * whenever a port is connected or disconnected.
 
387
 *
 
388
 * @param a one of two ports connected or disconnected
 
389
 * @param b one of two ports connected or disconnected
 
390
 * @param connect non-zero if ports were connected
 
391
 *                    zero if ports were disconnected
 
392
 * @param arg pointer to a client supplied data
 
393
 */
 
394
typedef void (*JackPortConnectCallback)(jack_port_id_t a, jack_port_id_t b, int connect, void* arg);
 
395
 
 
396
/**
 
397
 * Prototype for the client supplied function that is called
 
398
 * whenever the port name has been changed.
 
399
 *
 
400
 * @param port the port that has been renamed
 
401
 * @param new_name the new name
 
402
 * @param arg pointer to a client supplied structure
 
403
 *
 
404
 * @return zero on success, non-zero on error
 
405
 */
 
406
typedef int (*JackPortRenameCallback)(jack_port_id_t port, const char* old_name, const char* new_name, void *arg);
 
407
 
 
408
/**
 
409
 * Prototype for the client supplied function that is called
 
410
 * whenever jackd starts or stops freewheeling.
 
411
 *
 
412
 * @param starting non-zero if we start starting to freewheel, zero otherwise
 
413
 * @param arg pointer to a client supplied structure
 
414
 */
 
415
typedef void (*JackFreewheelCallback)(int starting, void *arg);
 
416
 
 
417
/**
 
418
 * Prototype for the client supplied function that is called
 
419
 * whenever jackd is shutdown. Note that after server shutdown,
 
420
 * the client pointer is *not* deallocated by libjack,
 
421
 * the application is responsible to properly use jack_client_close()
 
422
 * to release client ressources. Warning: jack_client_close() cannot be
 
423
 * safely used inside the shutdown callback and has to be called outside of
 
424
 * the callback context.
 
425
 *
 
426
 * @param arg pointer to a client supplied structure
 
427
 */
 
428
typedef void (*JackShutdownCallback)(void *arg);
 
429
 
 
430
/**
 
431
 * Prototype for the client supplied function that is called
 
432
 * whenever jackd is shutdown. Note that after server shutdown,
 
433
 * the client pointer is *not* deallocated by libjack,
 
434
 * the application is responsible to properly use jack_client_close()
 
435
 * to release client ressources. Warning: jack_client_close() cannot be
 
436
 * safely used inside the shutdown callback and has to be called outside of
 
437
 * the callback context.
 
438
 
 
439
 * @param code a status word, formed by OR-ing together the relevant @ref JackStatus bits.
 
440
 * @param reason a string describing the shutdown reason (backend failure, server crash... etc...)
 
441
 * @param arg pointer to a client supplied structure
 
442
 */
 
443
typedef void (*JackInfoShutdownCallback)(jack_status_t code, const char* reason, void *arg);
 
444
 
 
445
/**
 
446
 * Used for the type argument of jack_port_register() for default
 
447
 * audio ports and midi ports.
 
448
 */
 
449
#define JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio"
 
450
#define JACK_DEFAULT_MIDI_TYPE "8 bit raw midi"
 
451
 
 
452
/**
 
453
 * For convenience, use this typedef if you want to be able to change
 
454
 * between float and double. You may want to typedef sample_t to
 
455
 * jack_default_audio_sample_t in your application.
 
456
 */
 
457
typedef float jack_default_audio_sample_t;
 
458
 
 
459
/**
 
460
 *  A port has a set of flags that are formed by AND-ing together the
 
461
 *  desired values from the list below. The flags "JackPortIsInput" and
 
462
 *  "JackPortIsOutput" are mutually exclusive and it is an error to use
 
463
 *  them both.
 
464
 */
 
465
enum JackPortFlags {
 
466
 
 
467
    /**
 
468
     * if JackPortIsInput is set, then the port can receive
 
469
     * data.
 
470
     */
 
471
    JackPortIsInput = 0x1,
 
472
 
 
473
    /**
 
474
     * if JackPortIsOutput is set, then data can be read from
 
475
     * the port.
 
476
     */
 
477
    JackPortIsOutput = 0x2,
 
478
 
 
479
    /**
 
480
     * if JackPortIsPhysical is set, then the port corresponds
 
481
     * to some kind of physical I/O connector.
 
482
     */
 
483
    JackPortIsPhysical = 0x4,
 
484
 
 
485
    /**
 
486
     * if JackPortCanMonitor is set, then a call to
 
487
     * jack_port_request_monitor() makes sense.
 
488
     *
 
489
     * Precisely what this means is dependent on the client. A typical
 
490
     * result of it being called with TRUE as the second argument is
 
491
     * that data that would be available from an output port (with
 
492
     * JackPortIsPhysical set) is sent to a physical output connector
 
493
     * as well, so that it can be heard/seen/whatever.
 
494
     *
 
495
     * Clients that do not control physical interfaces
 
496
     * should never create ports with this bit set.
 
497
     */
 
498
    JackPortCanMonitor = 0x8,
 
499
 
 
500
    /**
 
501
     * JackPortIsTerminal means:
 
502
     *
 
503
     *  for an input port: the data received by the port
 
504
     *                    will not be passed on or made
 
505
     *                     available at any other port
 
506
     *
 
507
     * for an output port: the data available at the port
 
508
     *                    does not originate from any other port
 
509
     *
 
510
     * Audio synthesizers, I/O hardware interface clients, HDR
 
511
     * systems are examples of clients that would set this flag for
 
512
     * their ports.
 
513
     */
 
514
    JackPortIsTerminal = 0x10,
 
515
 
 
516
};
 
517
 
 
518
/**
 
519
 * Transport states.
 
520
 */
 
521
typedef enum {
 
522
 
 
523
    /* the order matters for binary compatibility */
 
524
    JackTransportStopped = 0,       /**< Transport halted */
 
525
    JackTransportRolling = 1,       /**< Transport playing */
 
526
    JackTransportLooping = 2,       /**< For OLD_TRANSPORT, now ignored */
 
527
    JackTransportStarting = 3,      /**< Waiting for sync ready */
 
528
    JackTransportNetStarting = 4,       /**< Waiting for sync ready on the network*/
 
529
 
 
530
} jack_transport_state_t;
 
531
 
 
532
typedef uint64_t jack_unique_t;         /**< Unique ID (opaque) */
 
533
 
 
534
/**
 
535
 * Optional struct jack_position_t fields.
 
536
 */
 
537
typedef enum {
 
538
 
 
539
    JackPositionBBT = 0x10,     /**< Bar, Beat, Tick */
 
540
    JackPositionTimecode = 0x20,        /**< External timecode */
 
541
    JackBBTFrameOffset =      0x40,     /**< Frame offset of BBT information */
 
542
    JackAudioVideoRatio =     0x80, /**< audio frames per video frame */
 
543
    JackVideoFrameOffset =   0x100  /**< frame offset of first video frame */
 
544
 
 
545
} jack_position_bits_t;
 
546
 
 
547
/** all valid position bits */
 
548
#define JACK_POSITION_MASK (JackPositionBBT|JackPositionTimecode)
 
549
#define EXTENDED_TIME_INFO
 
550
 
 
551
typedef struct {
 
552
 
 
553
    /* these four cannot be set from clients: the server sets them */
 
554
    jack_unique_t       unique_1;       /**< unique ID */
 
555
    jack_time_t         usecs;          /**< monotonic, free-rolling */
 
556
    jack_nframes_t      frame_rate;     /**< current frame rate (per second) */
 
557
    jack_nframes_t      frame;          /**< frame number, always present */
 
558
 
 
559
    jack_position_bits_t valid;         /**< which other fields are valid */
 
560
 
 
561
    /* JackPositionBBT fields: */
 
562
    int32_t             bar;            /**< current bar */
 
563
    int32_t             beat;           /**< current beat-within-bar */
 
564
    int32_t             tick;           /**< current tick-within-beat */
 
565
    double              bar_start_tick;
 
566
 
 
567
    float               beats_per_bar;  /**< time signature "numerator" */
 
568
    float               beat_type;      /**< time signature "denominator" */
 
569
    double              ticks_per_beat;
 
570
    double              beats_per_minute;
 
571
 
 
572
    /* JackPositionTimecode fields:     (EXPERIMENTAL: could change) */
 
573
    double              frame_time;     /**< current time in seconds */
 
574
    double              next_time;      /**< next sequential frame_time
 
575
                         (unless repositioned) */
 
576
 
 
577
    /* JackBBTFrameOffset fields: */
 
578
    jack_nframes_t      bbt_offset;     /**< frame offset for the BBT fields
 
579
                         (the given bar, beat, and tick
 
580
                         values actually refer to a time
 
581
                         frame_offset frames before the
 
582
                         start of the cycle), should
 
583
                         be assumed to be 0 if
 
584
                         JackBBTFrameOffset is not
 
585
                         set. If JackBBTFrameOffset is
 
586
                         set and this value is zero, the BBT
 
587
                         time refers to the first frame of this
 
588
                         cycle. If the value is positive,
 
589
                         the BBT time refers to a frame that
 
590
                         many frames before the start of the
 
591
                         cycle. */
 
592
 
 
593
    /* JACK video positional data (experimental) */
 
594
 
 
595
    float               audio_frames_per_video_frame; /**< number of audio frames
 
596
                         per video frame. Should be assumed
 
597
                         zero if JackAudioVideoRatio is not
 
598
                         set. If JackAudioVideoRatio is set
 
599
                         and the value is zero, no video
 
600
                         data exists within the JACK graph */
 
601
 
 
602
    jack_nframes_t      video_offset;   /**< audio frame at which the first video
 
603
                         frame in this cycle occurs. Should
 
604
                         be assumed to be 0 if JackVideoFrameOffset
 
605
                         is not set. If JackVideoFrameOffset is
 
606
                         set, but the value is zero, there is
 
607
                         no video frame within this cycle. */
 
608
 
 
609
    /* For binary compatibility, new fields should be allocated from
 
610
     * this padding area with new valid bits controlling access, so
 
611
     * the existing structure size and offsets are preserved. */
 
612
    int32_t             padding[7];
 
613
 
 
614
    /* When (unique_1 == unique_2) the contents are consistent. */
 
615
    jack_unique_t       unique_2;       /**< unique ID */
 
616
 
 
617
} jack_position_t;
 
618
 
 
619
/**
 
620
    * Prototype for the @a sync_callback defined by slow-sync clients.
 
621
    * When the client is active, this callback is invoked just before
 
622
    * process() in the same thread.  This occurs once after registration,
 
623
    * then subsequently whenever some client requests a new position, or
 
624
    * the transport enters the ::JackTransportStarting state.  This
 
625
    * realtime function must not wait.
 
626
    *
 
627
    * The transport @a state will be:
 
628
    *
 
629
    *   - ::JackTransportStopped when a new position is requested;
 
630
    *   - ::JackTransportStarting when the transport is waiting to start;
 
631
    *   - ::JackTransportRolling when the timeout has expired, and the
 
632
    *   position is now a moving target.
 
633
    *
 
634
    * @param state current transport state.
 
635
    * @param pos new transport position.
 
636
    * @param arg the argument supplied by jack_set_sync_callback().
 
637
    *
 
638
    * @return TRUE (non-zero) when ready to roll.
 
639
    */
 
640
typedef int (*JackSyncCallback)(jack_transport_state_t state,
 
641
                                jack_position_t *pos,
 
642
                                void *arg);
 
643
 
 
644
 
 
645
/**
 
646
  * Prototype for the @a timebase_callback used to provide extended
 
647
  * position information.  Its output affects all of the following
 
648
  * process cycle.  This realtime function must not wait.
 
649
  *
 
650
  * This function is called immediately after process() in the same
 
651
  * thread whenever the transport is rolling, or when any client has
 
652
  * requested a new position in the previous cycle.  The first cycle
 
653
  * after jack_set_timebase_callback() is also treated as a new
 
654
  * position, or the first cycle after jack_activate() if the client
 
655
  * had been inactive.
 
656
  *
 
657
  * The timebase master may not use its @a pos argument to set @a
 
658
  * pos->frame.  To change position, use jack_transport_reposition() or
 
659
  * jack_transport_locate().  These functions are realtime-safe, the @a
 
660
  * timebase_callback can call them directly.
 
661
  *
 
662
  * @param state current transport state.
 
663
  * @param nframes number of frames in current period.
 
664
  * @param pos address of the position structure for the next cycle; @a
 
665
  * pos->frame will be its frame number.  If @a new_pos is FALSE, this
 
666
  * structure contains extended position information from the current
 
667
  * cycle.  If TRUE, it contains whatever was set by the requester.
 
668
  * The @a timebase_callback's task is to update the extended
 
669
  * information here.
 
670
  * @param new_pos TRUE (non-zero) for a newly requested @a pos, or for
 
671
  * the first cycle after the @a timebase_callback is defined.
 
672
  * @param arg the argument supplied by jack_set_timebase_callback().
 
673
  */
 
674
typedef void (*JackTimebaseCallback)(jack_transport_state_t state,
 
675
                                     jack_nframes_t nframes,
 
676
                                     jack_position_t *pos,
 
677
                                     int new_pos,
 
678
                                     void *arg);
 
679
 
 
680
/*********************************************************************
 
681
    * The following interfaces are DEPRECATED.  They are only provided
 
682
    * for compatibility with the earlier JACK transport implementation.
 
683
    *********************************************************************/
 
684
 
 
685
/**
 
686
 * Optional struct jack_transport_info_t fields.
 
687
 *
 
688
 * @see jack_position_bits_t.
 
689
 */
 
690
typedef enum {
 
691
 
 
692
    JackTransportState = 0x1,   /**< Transport state */
 
693
    JackTransportPosition = 0x2,        /**< Frame number */
 
694
    JackTransportLoop = 0x4,    /**< Loop boundaries (ignored) */
 
695
    JackTransportSMPTE = 0x8,   /**< SMPTE (ignored) */
 
696
    JackTransportBBT = 0x10     /**< Bar, Beat, Tick */
 
697
 
 
698
} jack_transport_bits_t;
 
699
 
 
700
/**
 
701
 * Deprecated struct for transport position information.
 
702
 *
 
703
 * @deprecated This is for compatibility with the earlier transport
 
704
 * interface.  Use the jack_position_t struct, instead.
 
705
 */
 
706
typedef struct {
 
707
 
 
708
    /* these two cannot be set from clients: the server sets them */
 
709
 
 
710
    jack_nframes_t frame_rate;          /**< current frame rate (per second) */
 
711
    jack_time_t usecs;          /**< monotonic, free-rolling */
 
712
 
 
713
    jack_transport_bits_t valid;        /**< which fields are legal to read */
 
714
    jack_transport_state_t transport_state;
 
715
    jack_nframes_t frame;
 
716
    jack_nframes_t loop_start;
 
717
    jack_nframes_t loop_end;
 
718
 
 
719
    long smpte_offset;  /**< SMPTE offset (from frame 0) */
 
720
    float smpte_frame_rate;     /**< 29.97, 30, 24 etc. */
 
721
 
 
722
    int bar;
 
723
    int beat;
 
724
    int tick;
 
725
    double bar_start_tick;
 
726
 
 
727
    float beats_per_bar;
 
728
    float beat_type;
 
729
    double ticks_per_beat;
 
730
    double beats_per_minute;
 
731
 
 
732
} jack_transport_info_t;
 
733
 
 
734
 
 
735
#endif /* __jack_types_h__ */