LiVES  2.8.9
jack.h
Go to the documentation of this file.
1 // jack.h
2 // LiVES (lives-exe)
3 // (c) G. Finch 2005 - 2017
4 // Released under the GPL 3 or later
5 // see file ../COPYING for licensing details
6 
7 #ifndef HAS_LIVES_JACK_H
8 #define HAS_LIVES_JACK_H
9 
10 #ifdef ENABLE_JACK
11 
13 // Transport
14 
15 #include <jack/jack.h>
16 #include <jack/transport.h>
17 
18 boolean lives_jack_init(void);
19 boolean lives_jack_poll(void);
20 void lives_jack_end(void);
21 
22 int lives_start_ready_callback(jack_transport_state_t state, jack_position_t *pos, void *arg);
23 
24 void jack_pb_start(void);
25 void jack_pb_stop(void);
27 // Audio
29 
30 #include "audio.h"
31 
32 #define JACK_MAX_OUTPUT_PORTS 10
33 #define JACK_MAX_INPUT_PORTS 10
34 
35 #define ERR_PORT_NOT_FOUND 10
36 
37 typedef jack_nframes_t nframes_t;
38 
39 
40 // let's hope these are well above the standard jack transport states...
41 #define JackTClosed 1024
42 #define JackTReset 1025
43 #define JackTStopped 1026
44 
45 typedef struct {
46  int dev_idx;
47  int64_t sample_out_rate;
48  int64_t sample_in_rate;
49  uint64_t num_input_channels;
50  uint64_t num_output_channels;
51  uint64_t bytes_per_channel;
52 
53  uint64_t num_calls;
55  jack_port_t *output_port[JACK_MAX_OUTPUT_PORTS];
56  jack_port_t *input_port[JACK_MAX_INPUT_PORTS];
57  jack_client_t *client;
59  char **jack_port_name;
60  unsigned int jack_port_name_count;
61  uint64_t jack_port_flags;
63  lives_audio_loop_t loop;
64 
65  jack_transport_state_t state;
66 
67  float volume[JACK_MAX_OUTPUT_PORTS];
68 
69  boolean in_use;
70  boolean mute;
71 
72  volatile aserver_message_t *msgq;
74  off_t seek_pos;
75  off_t seek_end;
76  boolean usigned;
77  boolean reverse_endian;
78 
79  lives_whentostop_t *whentostop;
80  volatile lives_cancel_t *cancelled;
81 
82  /* variables used for trying to restart the connection to jack */
83  boolean jackd_died;
85  boolean play_when_stopped;
86  uint64_t audio_ticks;
87  uint64_t frames_written;
88 
89  int out_chans_available;
90  int in_chans_available;
91 
92  boolean is_paused;
93 
94  boolean is_output;
95 
96  boolean is_silent;
97 
98  boolean is_active;
99 
100  int playing_file;
101 
102  volatile float jack_pulse[1024];
103 
104  lives_audio_buf_t **abufs;
105  volatile int read_abuf;
106 
107  volatile int astream_fd;
108 
109  volatile float abs_maxvol_heard;
110 } jack_driver_t;
111 
112 #define JACK_MAX_OUTDEVICES 10
113 #define JACK_MAX_INDEVICES 10
114 
116 
117 jack_driver_t *jack_get_driver(int dev_idx, boolean is_output);
118 
119 int jack_audio_init(void);
120 int jack_audio_read_init(void);
121 
122 int jack_open_device(jack_driver_t *);
123 int jack_open_device_read(jack_driver_t *);
124 
125 int jack_driver_activate(jack_driver_t *);
126 int jack_read_driver_activate(jack_driver_t *, boolean autocon);
127 
128 void jack_close_device(jack_driver_t *);
129 
130 boolean jack_try_reconnect(void);
131 
132 void jack_aud_pb_ready(int fileno);
133 
134 // utils
135 volatile aserver_message_t *jack_get_msgq(jack_driver_t *);
136 uint64_t lives_jack_get_time(jack_driver_t *, boolean absolute);
137 boolean jack_audio_seek_frame(jack_driver_t *, int frame);
138 int64_t jack_audio_seek_bytes(jack_driver_t *, int64_t bytes);
139 
140 void jack_get_rec_avals(jack_driver_t *);
141 
142 uint64_t jack_transport_get_time(void);
143 
144 double lives_jack_get_pos(jack_driver_t *);
145 
146 #endif
147 
148 #endif
lives_audio_loop_t
Definition: audio.h:140
Definition: audio.h:73
lives_whentostop_t
which stream end should cause playback to finish ?
Definition: main.h:418
Definition: audio.h:60
lives_cancel_t
cancel reason
Definition: main.h:425