1 /* 2 * Copyright (C) 2018-2019 Alexandros Theodotou <alex at zrythm dot org> 3 * 4 * This file is part of Zrythm 5 * 6 * Zrythm is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * Zrythm is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with Zrythm. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 20 #include "zrythm-config.h" 21 22 #ifdef HAVE_JACK 23 24 #ifndef __AUDIO_ENGINE_JACK_H__ 25 #define __AUDIO_ENGINE_JACK_H__ 26 27 #include <stdlib.h> 28 29 #define JACK_PORT_T(exp) ((jack_port_t *) exp) 30 31 typedef struct AudioEngine AudioEngine; 32 typedef enum AudioEngineJackTransportType 33 AudioEngineJackTransportType; 34 35 /** 36 * Tests if JACK is working properly. 37 * 38 * Returns 0 if ok, non-null if has errors. 39 * 40 * If win is not null, it displays error messages 41 * to it. 42 */ 43 int 44 engine_jack_test ( 45 GtkWindow * win); 46 47 /** 48 * Refreshes the list of external ports. 49 */ 50 void 51 engine_jack_rescan_ports ( 52 AudioEngine * self); 53 54 /** 55 * Disconnects and reconnects the monitor output 56 * port to the selected devices. 57 */ 58 int 59 engine_jack_reconnect_monitor ( 60 AudioEngine * self, 61 bool left); 62 63 void 64 engine_jack_handle_position_change ( 65 AudioEngine * self); 66 67 void 68 engine_jack_handle_start ( 69 AudioEngine * self); 70 71 void 72 engine_jack_handle_stop ( 73 AudioEngine * self); 74 75 void 76 engine_jack_handle_buf_size_change ( 77 AudioEngine * self, 78 uint32_t frames); 79 80 void 81 engine_jack_handle_sample_rate_change ( 82 AudioEngine * self, 83 uint32_t samplerate); 84 85 /** 86 * Prepares for processing. 87 * 88 * Called at the start of each process cycle. 89 */ 90 void 91 engine_jack_prepare_process ( 92 AudioEngine * self); 93 94 /** 95 * Updates the JACK Transport type. 96 */ 97 void 98 engine_jack_set_transport_type ( 99 AudioEngine * self, 100 AudioEngineJackTransportType type); 101 102 /** 103 * Fills the external out bufs. 104 */ 105 void 106 engine_jack_fill_out_bufs ( 107 AudioEngine * self, 108 const nframes_t nframes); 109 110 /** 111 * Sets up the MIDI engine to use jack. 112 * 113 * @param loading Loading a Project or not. 114 */ 115 int 116 engine_jack_midi_setup ( 117 AudioEngine * self); 118 119 /** 120 * Sets up the audio engine to use jack. 121 * 122 * @param loading Loading a Project or not. 123 */ 124 int 125 engine_jack_setup ( 126 AudioEngine * self); 127 /** 128 * Copies the error message corresponding to \p 129 * status in \p msg. 130 */ 131 void 132 engine_jack_get_error_message ( 133 jack_status_t status, 134 char * msg); 135 136 void 137 engine_jack_tear_down ( 138 AudioEngine * self); 139 140 int 141 engine_jack_activate ( 142 AudioEngine * self, 143 bool activate); 144 145 /** 146 * Returns the JACK type string. 147 */ 148 const char * 149 engine_jack_get_jack_type ( 150 PortType type); 151 152 /** 153 * Returns if this is a pipewire session. 154 */ 155 bool 156 engine_jack_is_pipewire ( 157 AudioEngine * self); 158 159 #endif /* header guard */ 160 #endif /* HAVE_JACK */ 161