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