JackRequest.h 27.7 KB
Newer Older
sletz's avatar
sletz committed
1
/*
sletz's avatar
sletz committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Copyright (C) 2001 Paul Davis
Copyright (C) 2004-2008 Grame

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
sletz's avatar
sletz committed
18

sletz's avatar
sletz committed
19
20
21
22
23
*/

#ifndef __JackRequest__
#define __JackRequest__

sletz's avatar
sletz committed
24
#include "JackConstants.h"
25
#include "JackPlatformPlug.h"
sletz's avatar
sletz committed
26
#include "types.h"
sletz's avatar
sletz committed
27
#include <string.h>
sletz's avatar
sletz committed
28
#include <stdio.h>
sletz's avatar
sletz committed
29
30
31
32

namespace Jack
{

33
#define CheckRes(exp) { if ((exp) < 0) return -1;}
sletz's avatar
Cleanup    
sletz committed
34

sletz's avatar
sletz committed
35
36
37
38
39
40
41
/*!
\brief Request from client to server.
*/

struct JackRequest
{

42
    enum RequestType {
sletz's avatar
sletz committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
        kRegisterPort = 1,
        kUnRegisterPort = 2,
        kConnectPorts = 3,
        kDisconnectPorts = 4,
        kSetTimeBaseClient = 5,
        kActivateClient = 6,
        kDeactivateClient = 7,
        kDisconnectPort = 8,
        kSetClientCapabilities = 9,
        kGetPortConnections = 10,
        kGetPortNConnections = 11,
        kReleaseTimebase = 12,
        kSetTimebaseCallback = 13,
        kSetBufferSize = 20,
        kSetFreeWheel = 21,
sletz's avatar
sletz committed
58
        kClientCheck = 22,
59
60
61
62
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
sletz's avatar
sletz committed
63
64
65
66
        kGetInternalClientName = 27,
        kInternalClientHandle = 28,
        kInternalClientLoad = 29,
        kInternalClientUnload = 30,
67
68
        kPortRename = 31,
        kNotification = 32
69
    };
sletz's avatar
sletz committed
70
71
72
73
74
75
76
77
78

    RequestType fType;

    JackRequest()
    {}

    JackRequest(RequestType type): fType(type)
    {}

sletz's avatar
sletz committed
79
    virtual ~JackRequest()
sletz's avatar
sletz committed
80
81
    {}

sletz's avatar
sletz committed
82
    virtual int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
83
    {
sletz's avatar
sletz committed
84
        return trans->Read(&fType, sizeof(RequestType));
sletz's avatar
sletz committed
85
86
    }

sletz's avatar
sletz committed
87
    virtual int Write(JackChannelTransaction* trans)
sletz's avatar
sletz committed
88
    {
sletz's avatar
sletz committed
89
        return trans->Write(&fType, sizeof(RequestType));
sletz's avatar
sletz committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
    }

};

/*!
\brief Result from the server.
*/

struct JackResult
{

    int	fResult;

    JackResult(): fResult( -1)
    {}
105
    JackResult(int result): fResult(result)
sletz's avatar
sletz committed
106
107
108
109
110
111
    {}
    virtual ~JackResult()
    {}

    virtual int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
112
        return trans->Read(&fResult, sizeof(int));
sletz's avatar
sletz committed
113
114
115
116
    }

    virtual int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
117
        return trans->Write(&fResult, sizeof(int));
sletz's avatar
sletz committed
118
    }
sletz's avatar
sletz committed
119
    
sletz's avatar
sletz committed
120
121
};

122
123
124
125
126
127
128
129
/*!
\brief CheckClient request.
*/

struct JackClientCheckRequest : public JackRequest
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
130
    int fProtocol;
sletz's avatar
sletz committed
131
    int fOptions;
132
133
134

    JackClientCheckRequest()
    {}
135
136
    JackClientCheckRequest(const char* name, int protocol, int options)
        : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options)
137
138
139
140
141
142
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
143
144
145
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fProtocol, sizeof(int)));
        return trans->Read(&fOptions, sizeof(int));
146
147
148
149
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
150
151
152
153
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fProtocol, sizeof(int)));
        return trans->Write(&fOptions, sizeof(int));
154
    }
sletz's avatar
sletz committed
155
156
    
} POST_PACKED_STRUCTURE;
157
158
159
160
161
162
163
164

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

sletz's avatar
sletz committed
165
166
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fStatus;
167

sletz's avatar
sletz committed
168
    JackClientCheckResult(): JackResult(), fStatus(0)
169
170
    {}
    JackClientCheckResult(int32_t result, const char* name, int status)
sletz's avatar
sletz committed
171
            : JackResult(result), fStatus(status)
172
    {
sletz's avatar
sletz committed
173
174
        snprintf(fName, sizeof(fName), "%s", name);
    }
175

sletz's avatar
sletz committed
176
    int Read(JackChannelTransaction* trans)
177
    {
sletz's avatar
sletz committed
178
179
180
181
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        return 0;
182
183
184
185
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
186
187
188
189
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        return 0;
190
    }
sletz's avatar
sletz committed
191
192
    
} POST_PACKED_STRUCTURE;
193

sletz's avatar
sletz committed
194
195
196
197
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
198
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
199
200
{

201
    int fPID;
sletz's avatar
sletz committed
202
203
    char fName[JACK_CLIENT_NAME_SIZE + 1];

sletz's avatar
sletz committed
204
    JackClientOpenRequest()
sletz's avatar
sletz committed
205
    {}
206
    JackClientOpenRequest(const char* name, int pid): JackRequest(JackRequest::kClientOpen)
sletz's avatar
sletz committed
207
208
    {
        snprintf(fName, sizeof(fName), "%s", name);
209
        fPID = pid;
sletz's avatar
sletz committed
210
211
212
213
    }

    int Read(JackChannelTransaction* trans)
    {
214
        CheckRes(trans->Read(&fPID, sizeof(int)));
sletz's avatar
sletz committed
215
        return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
sletz's avatar
sletz committed
216
217
218
219
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
220
        CheckRes(JackRequest::Write(trans));
221
        CheckRes(trans->Write(&fPID, sizeof(int)));
sletz's avatar
sletz committed
222
        return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
sletz's avatar
sletz committed
223
    }
sletz's avatar
sletz committed
224
225
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
226
227
228
229
230

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
231
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
232
233
234
235
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
236
    int fSharedGraph;
237
   
sletz's avatar
sletz committed
238
    JackClientOpenResult()
239
            : JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1)
sletz's avatar
sletz committed
240
    {}
241
    JackClientOpenResult(int32_t result, int index1, int index2, int index3)
242
            : JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3)
sletz's avatar
sletz committed
243
244
    {}

sletz's avatar
sletz committed
245
    int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
246
    {
sletz's avatar
sletz committed
247
248
249
250
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fSharedEngine, sizeof(int)));
        CheckRes(trans->Read(&fSharedClient, sizeof(int)));
        CheckRes(trans->Read(&fSharedGraph, sizeof(int)));
251
        return 0;
sletz's avatar
sletz committed
252
253
254
255
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
256
257
258
259
260
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fSharedEngine, sizeof(int)));
        CheckRes(trans->Write(&fSharedClient, sizeof(int)));
        CheckRes(trans->Write(&fSharedGraph, sizeof(int)));
        return 0;
sletz's avatar
sletz committed
261
    }
sletz's avatar
sletz committed
262
263
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
264
265
266
267
268

/*!
\brief CloseClient request.
*/

269
struct JackClientCloseRequest : public JackRequest
sletz's avatar
sletz committed
270
271
272
273
274
275
{

    int fRefNum;

    JackClientCloseRequest()
    {}
276
    JackClientCloseRequest(int refnum): JackRequest(JackRequest::kClientClose), fRefNum(refnum)
sletz's avatar
sletz committed
277
278
279
280
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
281
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
282
283
284
285
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
286
287
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
288
    }
sletz's avatar
sletz committed
289
290
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
291
292
293
294
295

/*!
\brief Activate request.
*/

296
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
297
298
299
{

    int fRefNum;
300
    int fState;
sletz's avatar
sletz committed
301
302
303

    JackActivateRequest()
    {}
304
305
    JackActivateRequest(int refnum, int state)
        : JackRequest(JackRequest::kActivateClient), fRefNum(refnum), fState(state)
sletz's avatar
sletz committed
306
307
308
309
    {}

    int Read(JackChannelTransaction* trans)
    {
310
311
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fState, sizeof(int));
sletz's avatar
sletz committed
312
313
314
315
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
316
        CheckRes(JackRequest::Write(trans));
317
318
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fState, sizeof(int));
sletz's avatar
sletz committed
319
320
    }

sletz's avatar
sletz committed
321
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
322
323
324
325
326

/*!
\brief Deactivate request.
*/

327
struct JackDeactivateRequest : public JackRequest
sletz's avatar
sletz committed
328
329
330
331
332
333
{

    int fRefNum;

    JackDeactivateRequest()
    {}
334
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
335
336
337
338
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
339
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
340
341
342
343
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
344
345
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
346
347
    }

sletz's avatar
sletz committed
348
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
349
350
351
352
353

/*!
\brief PortRegister request.
*/

354
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
355
356
357
358
359
360
361
362
363
364
365
{

    int fRefNum;
    char fName[JACK_PORT_NAME_SIZE + 1];
    char fPortType[JACK_PORT_TYPE_SIZE + 1];
    unsigned int fFlags;
    unsigned int fBufferSize;

    JackPortRegisterRequest()
    {}
    JackPortRegisterRequest(int refnum, const char* name, const char* port_type, unsigned int flags, unsigned int buffer_size)
366
            : JackRequest(JackRequest::kRegisterPort), fRefNum(refnum), fFlags(flags), fBufferSize(buffer_size)
sletz's avatar
sletz committed
367
368
369
370
371
372
373
    {
        strcpy(fName, name);
        strcpy(fPortType, port_type);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
374
375
376
377
378
379
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fName, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fPortType, JACK_PORT_TYPE_SIZE + 1));
        CheckRes(trans->Read(&fFlags, sizeof(unsigned int)));
        CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int)));
        return 0;
sletz's avatar
sletz committed
380
381
382
383
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
384
385
386
387
388
389
390
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fName, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fPortType, JACK_PORT_TYPE_SIZE + 1));
        CheckRes(trans->Write(&fFlags, sizeof(unsigned int)));
        CheckRes(trans->Write(&fBufferSize, sizeof(unsigned int)));
        return 0;
sletz's avatar
sletz committed
391
    }
sletz's avatar
sletz committed
392
393
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
394
395
396
397
398

/*!
\brief PortRegister result.
*/

399
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
400
401
{

402
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
403

sletz's avatar
sletz committed
404
    JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
sletz's avatar
sletz committed
405
406
    {}

sletz's avatar
sletz committed
407
    int Read(JackChannelTransaction* trans)
sletz's avatar
Cleanup    
sletz committed
408
    {
sletz's avatar
sletz committed
409
410
        CheckRes(JackResult::Read(trans));
        return trans->Read(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
411
412
413
414
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
415
416
        CheckRes(JackResult::Write(trans));
        return trans->Write(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
417
    }
sletz's avatar
sletz committed
418
419
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
420
421
422
423
424

/*!
\brief PortUnregister request.
*/

425
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
426
427
428
{

    int fRefNum;
429
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
430
431
432

    JackPortUnRegisterRequest()
    {}
433
    JackPortUnRegisterRequest(int refnum, jack_port_id_t index)
434
        : JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
435
436
437
438
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
439
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
440
        CheckRes(trans->Read(&fPortIndex, sizeof(jack_port_id_t)));
sletz's avatar
sletz committed
441
        return 0;
sletz's avatar
sletz committed
442
443
444
445
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
446
447
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
448
        CheckRes(trans->Write(&fPortIndex, sizeof(jack_port_id_t)));
sletz's avatar
sletz committed
449
        return 0;
sletz's avatar
sletz committed
450
    }
sletz's avatar
sletz committed
451
452
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
453
454
455
456
457

/*!
\brief PortConnectName request.
*/

458
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
459
{
sletz's avatar
sletz committed
460

sletz's avatar
sletz committed
461
462
463
464
465
466
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortConnectNameRequest()
    {}
467
468
    JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
469
470
471
472
473
474
475
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
476
477
478
479
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1));
        return 0;
480

sletz's avatar
sletz committed
481
482
483
484
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
485
486
487
488
489
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1));
        return 0;
sletz's avatar
sletz committed
490
    }
sletz's avatar
sletz committed
491
492
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
493
494
495
496
497

/*!
\brief PortDisconnectName request.
*/

498
struct JackPortDisconnectNameRequest : public JackRequest
sletz's avatar
sletz committed
499
500
501
502
503
504
505
506
{

    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortDisconnectNameRequest()
    {}
507
508
    JackPortDisconnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kDisconnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
509
510
511
512
513
514
515
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
516
517
518
519
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1));
        return 0;
sletz's avatar
sletz committed
520
521
522
523
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
524
525
526
527
528
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1));
        return 0;
sletz's avatar
sletz committed
529
    }
sletz's avatar
sletz committed
530
531
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
532
533
534
535
536

/*!
\brief PortConnect request.
*/

537
struct JackPortConnectRequest : public JackRequest
sletz's avatar
sletz committed
538
539
540
541
542
543
544
545
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
546
547
    JackPortConnectRequest(int refnum, jack_port_id_t src, jack_port_id_t dst)
        : JackRequest(JackRequest::kConnectPorts), fRefNum(refnum), fSrc(src), fDst(dst)
sletz's avatar
sletz committed
548
549
550
551
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
552
553
554
555
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fSrc, sizeof(jack_port_id_t)));
        CheckRes(trans->Read(&fDst, sizeof(jack_port_id_t)));
        return 0;
sletz's avatar
sletz committed
556
557
558
559
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
560
561
562
563
564
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fSrc, sizeof(jack_port_id_t)));
        CheckRes(trans->Write(&fDst, sizeof(jack_port_id_t)));
        return 0;
sletz's avatar
sletz committed
565
    }
sletz's avatar
sletz committed
566
567
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
568
569
570
571
572

/*!
\brief PortDisconnect request.
*/

573
struct JackPortDisconnectRequest : public JackRequest
sletz's avatar
sletz committed
574
575
576
577
578
579
580
581
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
582
583
    JackPortDisconnectRequest(int refnum, jack_port_id_t src, jack_port_id_t dst)
        : JackRequest(JackRequest::kDisconnectPorts), fRefNum(refnum), fSrc(src), fDst(dst)
sletz's avatar
sletz committed
584
585
586
587
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
588
589
590
591
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fSrc, sizeof(jack_port_id_t)));
        CheckRes(trans->Read(&fDst, sizeof(jack_port_id_t)));
        return 0;
sletz's avatar
sletz committed
592
593
594
595
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
596
597
598
599
600
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fSrc, sizeof(jack_port_id_t)));
        CheckRes(trans->Write(&fDst, sizeof(jack_port_id_t)));
        return 0;
601

sletz's avatar
sletz committed
602
    }
sletz's avatar
sletz committed
603
604
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
605

606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
/*!
\brief PortRename request.
*/

struct JackPortRenameRequest : public JackRequest
{

    int fRefNum;
    jack_port_id_t fPort;
    char fName[JACK_PORT_NAME_SIZE + 1];

    JackPortRenameRequest()
    {}
    JackPortRenameRequest(int refnum, jack_port_id_t port, const char* name)
        : JackRequest(JackRequest::kPortRename), fRefNum(refnum), fPort(port)
    {
        strcpy(fName, name);
    }

    int Read(JackChannelTransaction* trans)
    {
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fPort, sizeof(jack_port_id_t)));
        CheckRes(trans->Read(&fName, JACK_PORT_NAME_SIZE + 1));
        return 0;
    }

    int Write(JackChannelTransaction* trans)
    {
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fPort, sizeof(jack_port_id_t)));
        CheckRes(trans->Write(&fName, JACK_PORT_NAME_SIZE + 1));
        return 0;

    }
sletz's avatar
sletz committed
642
643
    
} POST_PACKED_STRUCTURE;
644

sletz's avatar
sletz committed
645
646
647
648
/*!
\brief SetBufferSize request.
*/

649
struct JackSetBufferSizeRequest : public JackRequest
sletz's avatar
sletz committed
650
651
652
653
654
655
{

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
656
657
    JackSetBufferSizeRequest(jack_nframes_t buffer_size)
        : JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
658
659
660
661
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
662
        return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
663
664
665
666
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
667
668
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
669
    }
sletz's avatar
sletz committed
670
671
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
672
673
674
675
676

/*!
\brief SetFreeWheel request.
*/

677
struct JackSetFreeWheelRequest : public JackRequest
sletz's avatar
sletz committed
678
679
680
681
682
683
{

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
684
685
    JackSetFreeWheelRequest(int onoff)
        : JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
686
687
688
689
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
690
        return trans->Read(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
691
692
693
694
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
695
696
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
697
    }
sletz's avatar
sletz committed
698
699
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
700
701
702
703
704

/*!
\brief ReleaseTimebase request.
*/

705
struct JackReleaseTimebaseRequest : public JackRequest
sletz's avatar
sletz committed
706
707
708
709
710
711
{

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
712
713
    JackReleaseTimebaseRequest(int refnum)
        : JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
714
715
716
717
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
718
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
719
720
721
722
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
723
724
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
725
    }
sletz's avatar
sletz committed
726
727
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
728
729
730
731
732

/*!
\brief SetTimebaseCallback request.
*/

733
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
734
735
736
737
738
739
740
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
741
742
    JackSetTimebaseCallbackRequest(int refnum, int conditional)
        : JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
743
744
745
746
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
747
748
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
749
750
751
752
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
753
754
755
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
756
    }
sletz's avatar
sletz committed
757
758
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
759

760
761
762
763
764
765
766
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
767
    int fRefNum;
768
769
770
771
772
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
773
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
774
775
776
777
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
778
779
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
780
781
782
783
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
784
785
786
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
787
    }
sletz's avatar
sletz committed
788
789
    
} POST_PACKED_STRUCTURE;
790
791
792
793
794

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
795
struct JackGetInternalClientNameResult : public JackResult
796
797
{

sletz's avatar
sletz committed
798
    char fName[JACK_CLIENT_NAME_SIZE + 1];
799

sletz's avatar
sletz committed
800
    JackGetInternalClientNameResult(): JackResult()
801
    {}
sletz's avatar
sletz committed
802
    JackGetInternalClientNameResult(int32_t result, const char* name)
sletz's avatar
sletz committed
803
            : JackResult(result)
804
    {
sletz's avatar
sletz committed
805
806
        snprintf(fName, sizeof(fName), "%s", name);
    }
807

sletz's avatar
sletz committed
808
    int Read(JackChannelTransaction* trans)
809
    {
sletz's avatar
sletz committed
810
811
812
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
813
814
815
816
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
817
818
819
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
820
    }
sletz's avatar
sletz committed
821
822
    
} POST_PACKED_STRUCTURE;
823
824
825
826
827
828
829
830

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
831
    int fRefNum;
832
833
834
835
836
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
sletz's avatar
sletz committed
837
            : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
838
    {
sletz's avatar
sletz committed
839
840
        snprintf(fName, sizeof(fName), "%s", client_name);
    }
841
842
843

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
844
845
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
846
847
848
849
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
850
851
852
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
853
    }
sletz's avatar
sletz committed
854
855
    
} POST_PACKED_STRUCTURE;
856
857
858
859
860
861
862
863

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
864
865
    int fStatus;
    int fIntRefNum;
866

sletz's avatar
sletz committed
867
    JackInternalClientHandleResult(): JackResult()
868
869
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
870
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
871
872
    {}

sletz's avatar
sletz committed
873
    int Read(JackChannelTransaction* trans)
874
    {
sletz's avatar
sletz committed
875
876
877
878
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
879
880
881
882
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
883
884
885
886
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
887
    }
sletz's avatar
sletz committed
888
889
    
} POST_PACKED_STRUCTURE;
890
891
892
893
894
895
896
897

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

898
#ifndef MAX_PATH
sletz's avatar
sletz committed
899
#define MAX_PATH 256
900
#endif
sletz's avatar
sletz committed
901
902

    int fRefNum;
903
    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
904
905
906
    char fDllName[MAX_PATH + 1];
    char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
    int fOptions;
907
908
909
910

    JackInternalClientLoadRequest()
    {}
    JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options)
sletz's avatar
sletz committed
911
            : JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options)
912
    {
sletz's avatar
sletz committed
913
914
915
916
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
    }
917
918
919

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
920
921
922
923
924
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fDllName, MAX_PATH + 1));
        CheckRes(trans->Read(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1));
        return trans->Read(&fOptions, sizeof(int));
925
926
927
928
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
929
930
931
932
933
934
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fDllName, MAX_PATH + 1));
        CheckRes(trans->Write(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1));
        return trans->Write(&fOptions, sizeof(int));
935
    }
sletz's avatar
sletz committed
936
937
    
} POST_PACKED_STRUCTURE;
938
939
940
941
942
943
944
945

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
946
947
    int fStatus;
    int fIntRefNum;
948

sletz's avatar
sletz committed
949
    JackInternalClientLoadResult(): JackResult()
950
951
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
952
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
953
954
    {}

sletz's avatar
sletz committed
955
    int Read(JackChannelTransaction* trans)
956
    {
sletz's avatar
sletz committed
957
958
959
960
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
961
962
963
964
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
965
966
967
968
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
969
    }
sletz's avatar
sletz committed
970
971
    
} POST_PACKED_STRUCTURE;
972
973
974
975
976
977
978
979

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
980
    int fRefNum;
981
982
983
984
985
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
986
            : JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref)
987
988
989
990
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
991
992
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
993
994
995
996
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
997
998
999
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
1000
    }