2 * FireWire Backend for Jack
4 * FFADO = Firewire (pro-)audio for linux
7 * http://www.jackaudio.org
9 * Copyright (C) 2005-2007 Pieter Palmers
10 * Copyright (C) 2009 Devin Anderson
12 * adapted for JackMP by Pieter Palmers
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 * Main Jack driver entry routines
34 #ifndef __JACK_FFADO_DRIVER_H__
35 #define __JACK_FFADO_DRIVER_H__
37 #include <libffado/ffado.h>
45 #include <netinet/in.h>
49 #include <semaphore.h>
55 //#include <jack/midiport.h>
57 // debug print control flags
58 #define DEBUG_LEVEL_BUFFERS (1<<0)
59 #define DEBUG_LEVEL_HANDLERS (1<<1)
60 #define DEBUG_LEVEL_XRUN_RECOVERY (1<<2)
61 #define DEBUG_LEVEL_WAIT (1<<3)
63 #define DEBUG_LEVEL_RUN_CYCLE (1<<8)
65 #define DEBUG_LEVEL_PACKETCOUNTER (1<<16)
66 #define DEBUG_LEVEL_STARTUP (1<<17)
67 #define DEBUG_LEVEL_THREADS (1<<18)
69 //#define DEBUG_ENABLED
72 // default debug level
73 #define DEBUG_LEVEL ( DEBUG_LEVEL_RUN_CYCLE | \
74 (DEBUG_LEVEL_XRUN_RECOVERY)| DEBUG_LEVEL_STARTUP | DEBUG_LEVEL_WAIT | DEBUG_LEVEL_PACKETCOUNTER)
76 #warning Building debug build!
78 #define printMessage(format, args...) jack_error( "firewire MSG: %s:%d (%s): " format, __FILE__, __LINE__, __FUNCTION__, ##args )
79 #define printError(format, args...) jack_error( "firewire ERR: %s:%d (%s): " format, __FILE__, __LINE__, __FUNCTION__, ##args )
81 #define printEnter() jack_error( "FWDRV ENTERS: %s (%s)\n", __FUNCTION__, __FILE__)
82 #define printExit() jack_error( "FWDRV EXITS: %s (%s)\n", __FUNCTION__, __FILE__)
86 #define debugError(format, args...) jack_error( "firewire ERR: %s:%d (%s): " format, __FILE__, __LINE__, __FUNCTION__, ##args )
87 #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error("DEBUG %s:%d (%s) :" format, __FILE__, __LINE__, __FUNCTION__, ##args );
88 #define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error( format,##args );
89 #define debugPrintWithTimeStamp(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error( "%16lu: " format, debugGetCurrentUTime(), ##args );
90 #define SEGFAULT int *test=NULL; *test=1;
94 #define printMessage(format, args...) if(g_verbose) \
95 jack_error("firewire MSG: " format, ##args )
96 #define printError(format, args...) jack_error("firewire ERR: " format, ##args )
101 #define debugError(format, args...)
102 #define debugPrint(Level, format, args...)
103 #define debugPrintShort(Level, format, args...)
104 #define debugPrintWithTimeStamp(Level, format, args...)
107 // thread priority setup
108 #define FFADO_RT_PRIORITY_PACKETIZER_RELATIVE 5
110 typedef struct _ffado_driver ffado_driver_t
;
113 * Jack Driver command line parameters
116 typedef struct _ffado_jack_settings ffado_jack_settings_t
;
117 struct _ffado_jack_settings
122 jack_nframes_t period_size
;
128 jack_nframes_t buffer_size
;
133 jack_nframes_t capture_frame_latency
;
134 jack_nframes_t playback_frame_latency
;
142 typedef struct _ffado_capture_channel
144 ffado_streaming_stream_type stream_type
;
145 uint32_t *midi_buffer
;
148 ffado_capture_channel_t
;
150 typedef struct _ffado_playback_channel
152 ffado_streaming_stream_type stream_type
;
153 uint32_t *midi_buffer
;
156 ffado_playback_channel_t
;
159 * JACK driver structure
165 jack_nframes_t sample_rate
;
166 jack_nframes_t period_size
;
167 unsigned long wait_time
;
169 jack_time_t wait_last
;
170 jack_time_t wait_next
;
173 jack_client_t
*client
;
180 /* settings from the command line */
181 ffado_jack_settings_t settings
;
183 /* the firewire virtual device */
186 channel_t playback_nchannels
;
187 channel_t capture_nchannels
;
189 ffado_playback_channel_t
*playback_channels
;
190 ffado_capture_channel_t
*capture_channels
;
191 ffado_sample_t
*nullbuffer
;
192 ffado_sample_t
*scratchbuffer
;
194 jack_nframes_t playback_frame_latency
;
195 jack_nframes_t capture_frame_latency
;
197 ffado_device_info_t device_info
;
198 ffado_options_t device_options
;
202 #endif /* __JACK_FFADO_DRIVER_H__ */