1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
36
37
38
39
40
41
42
43
44
45
46
47
48
49
70
71
72
73
74
75
76
77
78
79
80
81
82
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
307
308
309
/* ... */
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "libjaylink.h"
#include "libjaylink-internal.h"
/* ... */
/* ... */
JAYLINK_PRIV int transport_open(struct jaylink_device_handle *devh)
{
int ret;
switch (devh->dev->iface) {
#ifdef HAVE_LIBUSB
case JAYLINK_HIF_USB:
ret = transport_usb_open(devh);
break;/* ... */
#endifcase JAYLINK_HIF_USB:
case JAYLINK_HIF_TCP:
ret = transport_tcp_open(devh);
break;case JAYLINK_HIF_TCP:
default:
log_err(devh->dev->ctx, "BUG: Invalid host interface: %u",
devh->dev->iface);
return JAYLINK_ERR;default
}switch (devh->dev->iface) { ... }
return ret;
}{ ... }
/* ... */
JAYLINK_PRIV int transport_close(struct jaylink_device_handle *devh)
{
int ret;
switch (devh->dev->iface) {
#ifdef HAVE_LIBUSB
case JAYLINK_HIF_USB:
ret = transport_usb_close(devh);
break;/* ... */
#endifcase JAYLINK_HIF_USB:
case JAYLINK_HIF_TCP:
ret = transport_tcp_close(devh);
break;case JAYLINK_HIF_TCP:
default:
log_err(devh->dev->ctx, "BUG: Invalid host interface: %u",
devh->dev->iface);
return JAYLINK_ERR;default
}switch (devh->dev->iface) { ... }
return ret;
}{ ... }
/* ... */
JAYLINK_PRIV int transport_start_write(struct jaylink_device_handle *devh,
size_t length, bool has_command)
{
int ret;
switch (devh->dev->iface) {
#ifdef HAVE_LIBUSB
case JAYLINK_HIF_USB:
ret = transport_usb_start_write(devh, length, has_command);
break;/* ... */
#endifcase JAYLINK_HIF_USB:
case JAYLINK_HIF_TCP:
ret = transport_tcp_start_write(devh, length, has_command);
break;case JAYLINK_HIF_TCP:
default:
log_err(devh->dev->ctx, "BUG: Invalid host interface: %u",
devh->dev->iface);
return JAYLINK_ERR;default
}switch (devh->dev->iface) { ... }
return ret;
}{ ... }
/* ... */
JAYLINK_PRIV int transport_start_read(struct jaylink_device_handle *devh,
size_t length)
{
int ret;
switch (devh->dev->iface) {
#ifdef HAVE_LIBUSB
case JAYLINK_HIF_USB:
ret = transport_usb_start_read(devh, length);
break;/* ... */
#endifcase JAYLINK_HIF_USB:
case JAYLINK_HIF_TCP:
ret = transport_tcp_start_read(devh, length);
break;case JAYLINK_HIF_TCP:
default:
log_err(devh->dev->ctx, "BUG: Invalid host interface: %u",
devh->dev->iface);
return JAYLINK_ERR;default
}switch (devh->dev->iface) { ... }
return ret;
}{ ... }
/* ... */
JAYLINK_PRIV int transport_start_write_read(struct jaylink_device_handle *devh,
size_t write_length, size_t read_length, bool has_command)
{
int ret;
switch (devh->dev->iface) {
#ifdef HAVE_LIBUSB
case JAYLINK_HIF_USB:
ret = transport_usb_start_write_read(devh, write_length,
read_length, has_command);
break;/* ... */
#endifcase JAYLINK_HIF_USB:
case JAYLINK_HIF_TCP:
ret = transport_tcp_start_write_read(devh, write_length,
read_length, has_command);
break;case JAYLINK_HIF_TCP:
default:
log_err(devh->dev->ctx, "BUG: Invalid host interface: %u",
devh->dev->iface);
return JAYLINK_ERR;default
}switch (devh->dev->iface) { ... }
return ret;
}{ ... }
/* ... */
JAYLINK_PRIV int transport_write(struct jaylink_device_handle *devh,
const uint8_t *buffer, size_t length)
{
int ret;
switch (devh->dev->iface) {
#ifdef HAVE_LIBUSB
case JAYLINK_HIF_USB:
ret = transport_usb_write(devh, buffer, length);
break;/* ... */
#endifcase JAYLINK_HIF_USB:
case JAYLINK_HIF_TCP:
ret = transport_tcp_write(devh, buffer, length);
break;case JAYLINK_HIF_TCP:
default:
log_err(devh->dev->ctx, "BUG: Invalid host interface: %u",
devh->dev->iface);
return JAYLINK_ERR;default
}switch (devh->dev->iface) { ... }
return ret;
}{ ... }
/* ... */
JAYLINK_PRIV int transport_read(struct jaylink_device_handle *devh,
uint8_t *buffer, size_t length)
{
int ret;
switch (devh->dev->iface) {
#ifdef HAVE_LIBUSB
case JAYLINK_HIF_USB:
ret = transport_usb_read(devh, buffer, length);
break;/* ... */
#endifcase JAYLINK_HIF_USB:
case JAYLINK_HIF_TCP:
ret = transport_tcp_read(devh, buffer, length);
break;case JAYLINK_HIF_TCP:
default:
log_err(devh->dev->ctx, "BUG: Invalid host interface: %u",
devh->dev->iface);
return JAYLINK_ERR;default
}switch (devh->dev->iface) { ... }
return ret;
}{ ... }