LiVES  3.0.2
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 #ifndef IS_DARWIN
33 #define JACK_DRIVER_NAME "alsa"
34 #else
35 #ifdef IS_SOLARIS
36 // use OSS on Solaris
37 #define JACK_DRIVER_NAME "oss"
38 #else
39 // use coreaudio on Darwin
40 #define JACK_DRIVER_NAME "coreaudio"
41 #endif
42 #endif
43 
44 #define JACK_MAX_OUTPUT_PORTS 10
45 #define JACK_MAX_INPUT_PORTS 10
46 
47 #define ERR_PORT_NOT_FOUND 10
48 
49 #define JACK_DEFAULT_SERVER_NAME "(default)"
50 
51 typedef jack_nframes_t nframes_t;
52 
53 
54 // let's hope these are well above the standard jack transport states...
55 #define JackTClosed 1024
56 #define JackTReset 1025
57 #define JackTStopped 1026
58 
59 typedef struct {
60  int dev_idx;
61  int sample_out_rate;
62  volatile int sample_in_rate;
63  uint64_t num_input_channels;
64  uint64_t num_output_channels;
65  uint64_t bytes_per_channel;
66 
67  uint64_t num_calls;
69  jack_port_t *output_port[JACK_MAX_OUTPUT_PORTS];
70  jack_port_t *input_port[JACK_MAX_INPUT_PORTS];
71  jack_client_t *client;
73  char **jack_port_name;
74  unsigned int jack_port_name_count;
75  uint64_t jack_port_flags;
77  lives_audio_loop_t loop;
78 
79  jack_transport_state_t state;
80 
81  float volume[JACK_MAX_OUTPUT_PORTS];
82 
83  boolean in_use;
84  boolean mute;
85 
86  volatile aserver_message_t *msgq;
88  off_t seek_pos;
89  volatile off_t real_seek_pos;
90  off_t seek_end;
91  boolean usigned;
92  boolean reverse_endian;
93 
94  lives_whentostop_t *whentostop;
95  volatile lives_cancel_t *cancelled;
96 
97  /* variables used for trying to restart the connection to jack */
98  boolean jackd_died;
100  boolean play_when_stopped;
101 
102  volatile jack_nframes_t nframes_start;
103  volatile uint64_t frames_written;
104 
105  int out_chans_available;
106  int in_chans_available;
107 
108  boolean is_paused;
109 
110  boolean is_output;
111 
112  boolean is_silent;
113 
114  boolean is_active;
115 
116  int playing_file;
117 
118  volatile float jack_pulse[1024];
119 
120  lives_audio_buf_t **abufs;
121  volatile int read_abuf;
122 
123  volatile int astream_fd;
124 
125  volatile float abs_maxvol_heard;
126 } jack_driver_t;
127 
128 #define JACK_MAX_OUTDEVICES 10
129 #define JACK_MAX_INDEVICES 10
130 
132 
133 jack_driver_t *jack_get_driver(int dev_idx, boolean is_output);
134 
135 int jack_audio_init(void);
136 int jack_audio_read_init(void);
137 
138 boolean jack_create_client_writer(jack_driver_t *);
139 boolean jack_create_client_reader(jack_driver_t *);
140 
141 boolean jack_write_driver_activate(jack_driver_t *);
142 boolean jack_read_driver_activate(jack_driver_t *, boolean autocon);
143 
144 void jack_close_device(jack_driver_t *);
145 
146 boolean jack_try_reconnect(void);
147 
148 void jack_aud_pb_ready(int fileno);
149 
150 size_t jack_flush_read_data(size_t rbytes, void *data);
151 
152 // utils
153 volatile aserver_message_t *jack_get_msgq(jack_driver_t *);
154 void jack_time_reset(jack_driver_t *jackd, int64_t offset);
155 uint64_t lives_jack_get_time(jack_driver_t *);
156 boolean jack_audio_seek_frame(jack_driver_t *, int frame);
157 int64_t jack_audio_seek_bytes(jack_driver_t *, int64_t bytes);
158 
159 void jack_get_rec_avals(jack_driver_t *);
160 
161 uint64_t jack_transport_get_time(void);
162 
163 double lives_jack_get_pos(jack_driver_t *);
164 
165 #endif
166 
167 #endif
lives_audio_loop_t
Definition: audio.h:141
Definition: audio.h:73
lives_whentostop_t
which stream end should cause playback to finish ?
Definition: main.h:408
Definition: audio.h:60
lives_cancel_t
cancel reason
Definition: main.h:415