2
* FireWire Backend for Jack
4
* FFADO = Firewire (pro-)audio for linux
7
* http://www.jackaudio.org
9
* Copyright (C) 2005-2007 Pieter Palmers
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
* Main Jack driver entry routines
31
#ifndef __JACK_FFADO_DRIVER_H__
32
#define __JACK_FFADO_DRIVER_H__
36
#include <libffado/ffado.h>
44
#include <netinet/in.h>
48
#include <semaphore.h>
50
#include <jack/driver.h>
51
#include <jack/engine.h>
52
#include <jack/types.h>
53
#include <jack/internal.h>
54
#include <jack/types.h>
55
#include <jack/ringbuffer.h>
56
#include <jack/thread.h>
58
#include <../alsa-midi/midi_pack.h>
59
#include <../alsa-midi/midi_unpack.h>
61
// debug print control flags
62
#define DEBUG_LEVEL_BUFFERS (1<<0)
63
#define DEBUG_LEVEL_HANDLERS (1<<1)
64
#define DEBUG_LEVEL_XRUN_RECOVERY (1<<2)
65
#define DEBUG_LEVEL_WAIT (1<<3)
67
#define DEBUG_LEVEL_RUN_CYCLE (1<<8)
69
#define DEBUG_LEVEL_PACKETCOUNTER (1<<16)
70
#define DEBUG_LEVEL_STARTUP (1<<17)
71
#define DEBUG_LEVEL_THREADS (1<<18)
73
//#define DEBUG_ENABLED
76
// default debug level
77
#define DEBUG_LEVEL ( DEBUG_LEVEL_RUN_CYCLE | \
78
(DEBUG_LEVEL_XRUN_RECOVERY)| DEBUG_LEVEL_STARTUP | DEBUG_LEVEL_WAIT | DEBUG_LEVEL_PACKETCOUNTER)
80
#warning Building debug build!
82
#define printMessage(format, args...) jack_error( "firewire MSG: %s:%d (%s): " format, __FILE__, __LINE__, __FUNCTION__, ##args )
83
#define printError(format, args...) jack_error( "firewire ERR: %s:%d (%s): " format, __FILE__, __LINE__, __FUNCTION__, ##args )
85
#define printEnter() jack_error( "FWDRV ENTERS: %s (%s)\n", __FUNCTION__, __FILE__)
86
#define printExit() jack_error( "FWDRV EXITS: %s (%s)\n", __FUNCTION__, __FILE__)
90
#define debugError(format, args...) jack_error( "firewire ERR: %s:%d (%s): " format, __FILE__, __LINE__, __FUNCTION__, ##args )
91
#define debugPrint(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error("DEBUG %s:%d (%s) :" format, __FILE__, __LINE__, __FUNCTION__, ##args );
92
#define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error( format,##args );
93
#define debugPrintWithTimeStamp(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error( "%16lu: "format, debugGetCurrentUTime(),##args );
94
#define SEGFAULT int *test=NULL; *test=1;
98
#define printMessage(format, args...) if(g_verbose) \
99
jack_error("firewire MSG: " format, ##args )
100
#define printError(format, args...) jack_error("firewire ERR: " format, ##args )
105
#define debugError(format, args...)
106
#define debugPrint(Level, format, args...)
107
#define debugPrintShort(Level, format, args...)
108
#define debugPrintWithTimeStamp(Level, format, args...)
111
typedef struct _ffado_driver ffado_driver_t;
114
* Jack Driver command line parameters
117
typedef struct _ffado_jack_settings ffado_jack_settings_t;
118
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
midi_unpack_t midi_unpack;
146
uint32_t *midi_buffer;
147
} ffado_capture_channel_t;
149
#define MIDI_OVERFLOW_BUFFER_SIZE 4
150
typedef struct _ffado_playback_channel
152
ffado_streaming_stream_type stream_type;
153
midi_pack_t midi_pack;
154
uint32_t *midi_buffer;
155
// to hold the midi bytes that couldn't be transferred
156
// during the previous period
157
char overflow_buffer[MIDI_OVERFLOW_BUFFER_SIZE];
158
unsigned int nb_overflow_bytes;
159
} ffado_playback_channel_t;
162
* JACK driver structure
168
jack_nframes_t sample_rate;
169
jack_nframes_t period_size;
170
unsigned long wait_time;
172
jack_time_t wait_last;
173
jack_time_t wait_next;
176
jack_client_t *client;
183
/* settings from the command line */
184
ffado_jack_settings_t settings;
186
/* the firewire virtual device */
189
ffado_sample_t *nullbuffer;
190
ffado_sample_t *scratchbuffer;
192
JSList *capture_ports;
193
JSList *playback_ports;
194
JSList *monitor_ports;
195
channel_t playback_nchannels;
196
channel_t capture_nchannels;
198
ffado_playback_channel_t *playback_channels;
199
ffado_capture_channel_t *capture_channels;
201
jack_nframes_t playback_frame_latency;
202
jack_nframes_t capture_frame_latency;
204
ffado_device_info_t device_info;
205
ffado_options_t device_options;
211
#endif /* __JACK_FFADO_DRIVER_H__ */