JackRequest.h 25.6 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 "JackPlatformChannelTransaction.h"
sletz's avatar
sletz committed
26
#include <stdio.h>
sletz's avatar
sletz committed
27
#include <string.h>
sletz's avatar
sletz committed
28
29
30
31

namespace Jack
{

sletz's avatar
Cleanup    
sletz committed
32
33
#define CheckRes(res) {if (res < 0) return res;}

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

struct JackRequest
{

41
    enum RequestType {
sletz's avatar
sletz committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        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
57
        kClientCheck = 22,
58
59
60
61
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
sletz's avatar
sletz committed
62
63
64
65
        kGetInternalClientName = 27,
        kInternalClientHandle = 28,
        kInternalClientLoad = 29,
        kInternalClientUnload = 30,
66
        kNotification = 31
67
    };
sletz's avatar
sletz committed
68
69
70
71
72
73
74
75
76

    RequestType fType;

    JackRequest()
    {}

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

sletz's avatar
sletz committed
77
    virtual ~JackRequest()
sletz's avatar
sletz committed
78
79
    {}

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

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

};

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

struct JackResult
{

    int	fResult;

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

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

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

119
120
121
122
123
124
125
126
/*!
\brief CheckClient request.
*/

struct JackClientCheckRequest : public JackRequest
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
127
    int fProtocol;
sletz's avatar
sletz committed
128
    int fOptions;
129
130
131

    JackClientCheckRequest()
    {}
sletz's avatar
sletz committed
132
    JackClientCheckRequest(const char* name, int protocol, int options): JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options)
133
134
135
136
137
138
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
139
140
141
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fProtocol, sizeof(int)));
        return trans->Read(&fOptions, sizeof(int));
142
143
144
145
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
146
147
148
149
        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));
150
151
152
153
154
155
156
157
158
159
    }
};

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

sletz's avatar
sletz committed
160
161
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fStatus;
162

sletz's avatar
sletz committed
163
    JackClientCheckResult(): JackResult(), fStatus(0)
164
165
    {}
    JackClientCheckResult(int32_t result, const char* name, int status)
sletz's avatar
sletz committed
166
            : JackResult(result), fStatus(status)
167
    {
sletz's avatar
sletz committed
168
169
        snprintf(fName, sizeof(fName), "%s", name);
    }
170

sletz's avatar
sletz committed
171
    int Read(JackChannelTransaction* trans)
172
    {
sletz's avatar
sletz committed
173
174
175
176
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        return 0;
177
178
179
180
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
181
182
183
184
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        return 0;
185
186
187
    }
};

sletz's avatar
sletz committed
188
189
190
191
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
192
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
193
194
{

195
    int fPID;
sletz's avatar
sletz committed
196
197
    char fName[JACK_CLIENT_NAME_SIZE + 1];

sletz's avatar
sletz committed
198
    JackClientOpenRequest()
sletz's avatar
sletz committed
199
    {}
200
    JackClientOpenRequest(const char* name, int pid): JackRequest(JackRequest::kClientOpen)
sletz's avatar
sletz committed
201
202
    {
        snprintf(fName, sizeof(fName), "%s", name);
203
        fPID = pid;
sletz's avatar
sletz committed
204
205
206
207
    }

    int Read(JackChannelTransaction* trans)
    {
208
        CheckRes(trans->Read(&fPID, sizeof(int)));
sletz's avatar
sletz committed
209
        return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
sletz's avatar
sletz committed
210
211
212
213
    }

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

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
224
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
225
226
227
228
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
229
    int fSharedGraph;
230
   
sletz's avatar
sletz committed
231
    JackClientOpenResult()
232
            : JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1)
sletz's avatar
sletz committed
233
    {}
234
    JackClientOpenResult(int32_t result, int index1, int index2, int index3)
235
            : JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3)
sletz's avatar
sletz committed
236
237
    {}

sletz's avatar
sletz committed
238
    int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
239
    {
sletz's avatar
sletz committed
240
241
242
243
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fSharedEngine, sizeof(int)));
        CheckRes(trans->Read(&fSharedClient, sizeof(int)));
        CheckRes(trans->Read(&fSharedGraph, sizeof(int)));
244
         return 0;
sletz's avatar
sletz committed
245
246
247
248
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
249
250
251
252
253
        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
254
255
256
257
258
259
260
    }
};

/*!
\brief CloseClient request.
*/

261
struct JackClientCloseRequest : public JackRequest
sletz's avatar
sletz committed
262
263
264
265
266
267
{

    int fRefNum;

    JackClientCloseRequest()
    {}
268
    JackClientCloseRequest(int refnum): JackRequest(JackRequest::kClientClose), fRefNum(refnum)
sletz's avatar
sletz committed
269
270
271
272
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
273
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
274
275
276
277
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
278
279
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
280
281
282
283
284
285
286
    }
};

/*!
\brief Activate request.
*/

287
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
288
289
290
{

    int fRefNum;
291
    int fState;
sletz's avatar
sletz committed
292
293
294

    JackActivateRequest()
    {}
295
    JackActivateRequest(int refnum, int state): JackRequest(JackRequest::kActivateClient), fRefNum(refnum), fState(state)
sletz's avatar
sletz committed
296
297
298
299
    {}

    int Read(JackChannelTransaction* trans)
    {
300
301
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fState, sizeof(int));
sletz's avatar
sletz committed
302
303
304
305
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
306
        CheckRes(JackRequest::Write(trans));
307
308
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fState, sizeof(int));
sletz's avatar
sletz committed
309
310
311
312
313
314
315
316
    }

};

/*!
\brief Deactivate request.
*/

317
struct JackDeactivateRequest : public JackRequest
sletz's avatar
sletz committed
318
319
320
321
322
323
{

    int fRefNum;

    JackDeactivateRequest()
    {}
324
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
325
326
327
328
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
329
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
330
331
332
333
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
334
335
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
336
337
338
339
340
341
342
343
    }

};

/*!
\brief PortRegister request.
*/

344
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
345
346
347
348
349
350
351
352
353
354
355
{

    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)
356
            : JackRequest(JackRequest::kRegisterPort), fRefNum(refnum), fFlags(flags), fBufferSize(buffer_size)
sletz's avatar
sletz committed
357
358
359
360
361
362
363
    {
        strcpy(fName, name);
        strcpy(fPortType, port_type);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
364
365
366
367
368
369
        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
370
371
372
373
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
374
375
376
377
378
379
380
        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
381
382
383
384
385
386
387
    }
};

/*!
\brief PortRegister result.
*/

388
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
389
390
{

sletz's avatar
sletz committed
391
    unsigned int fPortIndex;
sletz's avatar
sletz committed
392

sletz's avatar
sletz committed
393
    JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
sletz's avatar
sletz committed
394
395
    {}

sletz's avatar
sletz committed
396
    int Read(JackChannelTransaction* trans)
sletz's avatar
Cleanup    
sletz committed
397
    {
sletz's avatar
sletz committed
398
399
        CheckRes(JackResult::Read(trans));
        return trans->Read(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
400
401
402
403
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
404
405
        CheckRes(JackResult::Write(trans));
        return trans->Write(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
406
407
408
409
410
411
412
    }
};

/*!
\brief PortUnregister request.
*/

413
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
414
415
416
417
418
419
420
{

    int fRefNum;
    int fPortIndex;

    JackPortUnRegisterRequest()
    {}
421
    JackPortUnRegisterRequest(int refnum, int index): JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
422
423
424
425
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
426
427
428
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fPortIndex, sizeof(int)));
        return 0;
sletz's avatar
sletz committed
429
430
431
432
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
433
434
435
436
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fPortIndex, sizeof(int)));
        return 0;
sletz's avatar
sletz committed
437
438
439
440
441
442
443
    }
};

/*!
\brief PortConnectName request.
*/

444
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
445
{
sletz's avatar
sletz committed
446

sletz's avatar
sletz committed
447
448
449
450
451
452
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortConnectNameRequest()
    {}
453
    JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name): JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
454
455
456
457
458
459
460
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
461
462
463
464
        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;
465

sletz's avatar
sletz committed
466
467
468
469
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
470
471
472
473
474
        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
475
476
477
478
479
480
481
    }
};

/*!
\brief PortDisconnectName request.
*/

482
struct JackPortDisconnectNameRequest : public JackRequest
sletz's avatar
sletz committed
483
484
485
486
487
488
489
490
{

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

    JackPortDisconnectNameRequest()
    {}
491
    JackPortDisconnectNameRequest(int refnum, const char* src_name, const char* dst_name): JackRequest(JackRequest::kDisconnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
492
493
494
495
496
497
498
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
499
500
501
502
        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
503
504
505
506
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
507
508
509
510
511
        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
512
513
514
515
516
517
518
    }
};

/*!
\brief PortConnect request.
*/

519
struct JackPortConnectRequest : public JackRequest
sletz's avatar
sletz committed
520
521
522
523
524
525
526
527
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
528
    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
529
530
531
532
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
533
534
535
536
        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
537
538
539
540
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
541
542
543
544
545
        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
546
547
548
549
550
551
552
553
    }
};


/*!
\brief PortDisconnect request.
*/

554
struct JackPortDisconnectRequest : public JackRequest
sletz's avatar
sletz committed
555
556
557
558
559
560
561
562
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
563
    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
564
565
566
567
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
568
569
570
571
        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
572
573
574
575
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
576
577
578
579
580
        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;
581

sletz's avatar
sletz committed
582
583
584
585
586
587
588
    }
};

/*!
\brief SetBufferSize request.
*/

589
struct JackSetBufferSizeRequest : public JackRequest
sletz's avatar
sletz committed
590
591
592
593
594
595
{

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
596
    JackSetBufferSizeRequest(jack_nframes_t buffer_size): JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
597
598
599
600
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
601
        return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
602
603
604
605
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
606
607
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
608
609
610
611
612
613
614
    }
};

/*!
\brief SetFreeWheel request.
*/

615
struct JackSetFreeWheelRequest : public JackRequest
sletz's avatar
sletz committed
616
617
618
619
620
621
{

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
622
    JackSetFreeWheelRequest(int onoff): JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
623
624
625
626
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
627
        return trans->Read(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
628
629
630
631
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
632
633
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
634
635
636
637
638
639
640
    }
};

/*!
\brief ReleaseTimebase request.
*/

641
struct JackReleaseTimebaseRequest : public JackRequest
sletz's avatar
sletz committed
642
643
644
645
646
647
{

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
648
    JackReleaseTimebaseRequest(int refnum): JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
649
650
651
652
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
653
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
654
655
656
657
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
658
659
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
660
661
662
663
664
665
666
    }
};

/*!
\brief SetTimebaseCallback request.
*/

667
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
668
669
670
671
672
673
674
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
675
    JackSetTimebaseCallbackRequest(int refnum, int conditional): JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
676
677
678
679
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
680
681
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
682
683
684
685
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
686
687
688
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
689
690
691
    }
};

692
693
694
695
696
697
698
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
699
    int fRefNum;
700
701
702
703
704
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
705
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
706
707
708
709
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
710
711
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
712
713
714
715
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
716
717
718
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
719
720
721
722
723
724
725
    }
};

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
726
struct JackGetInternalClientNameResult : public JackResult
727
728
{

sletz's avatar
sletz committed
729
    char fName[JACK_CLIENT_NAME_SIZE + 1];
730

sletz's avatar
sletz committed
731
    JackGetInternalClientNameResult(): JackResult()
732
    {}
sletz's avatar
sletz committed
733
    JackGetInternalClientNameResult(int32_t result, const char* name)
sletz's avatar
sletz committed
734
            : JackResult(result)
735
    {
sletz's avatar
sletz committed
736
737
        snprintf(fName, sizeof(fName), "%s", name);
    }
738

sletz's avatar
sletz committed
739
    int Read(JackChannelTransaction* trans)
740
    {
sletz's avatar
sletz committed
741
742
743
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
744
745
746
747
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
748
749
750
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
751
752
753
754
755
756
757
758
759
760
    }
};

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
761
    int fRefNum;
762
763
764
765
766
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
sletz's avatar
sletz committed
767
            : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
768
    {
sletz's avatar
sletz committed
769
770
        snprintf(fName, sizeof(fName), "%s", client_name);
    }
771
772
773

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
774
775
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
776
777
778
779
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
780
781
782
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
783
784
785
786
787
788
789
790
791
792
    }
};

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
793
794
    int fStatus;
    int fIntRefNum;
795

sletz's avatar
sletz committed
796
    JackInternalClientHandleResult(): JackResult()
797
798
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
799
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
800
801
    {}

sletz's avatar
sletz committed
802
    int Read(JackChannelTransaction* trans)
803
    {
sletz's avatar
sletz committed
804
805
806
807
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
808
809
810
811
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
812
813
814
815
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
816
817
818
819
820
821
822
823
824
825
    }
};

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

sletz's avatar
sletz committed
826
827
828
#define MAX_PATH 256

    int fRefNum;
829
    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
830
831
832
    char fDllName[MAX_PATH + 1];
    char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
    int fOptions;
833
834
835
836

    JackInternalClientLoadRequest()
    {}
    JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options)
sletz's avatar
sletz committed
837
            : JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options)
838
    {
sletz's avatar
sletz committed
839
840
841
842
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
    }
843
844
845

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
846
847
848
849
850
        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));
851
852
853
854
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
855
856
857
858
859
860
        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));
861
862
863
864
865
866
867
868
869
870
    }
};

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
871
872
    int fStatus;
    int fIntRefNum;
873

sletz's avatar
sletz committed
874
    JackInternalClientLoadResult(): JackResult()
875
876
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
877
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
878
879
    {}

sletz's avatar
sletz committed
880
    int Read(JackChannelTransaction* trans)
881
    {
sletz's avatar
sletz committed
882
883
884
885
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
886
887
888
889
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
890
891
892
893
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
894
895
896
897
898
899
900
901
902
903
    }
};

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
904
    int fRefNum;
905
906
907
908
909
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
910
            : JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref)
911
912
913
914
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
915
916
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
917
918
919
920
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
921
922
923
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
924
925
926
927
928
929
930
931
932
933
934
    }
};


/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientUnloadResult : public JackResult
{

sletz's avatar
sletz committed
935
    int fStatus;
936

sletz's avatar
sletz committed
937
    JackInternalClientUnloadResult(): JackResult()
938
939
    {}
    JackInternalClientUnloadResult(int32_t result, int status)
sletz's avatar
sletz committed
940
            : JackResult(result), fStatus(status)
941
942
    {}

sletz's avatar
sletz committed
943
    int Read(JackChannelTransaction* trans)
944
    {
sletz's avatar
sletz committed
945
946
947
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        return 0;
948
949
950
951
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
952
953
954
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        return 0;
955
956
957
    }
};

sletz's avatar
sletz committed
958
959
960
961
/*!
\brief ClientNotification request.
*/

962
struct JackClientNotificationRequest : public JackRequest
sletz's avatar
sletz committed
963
{
sletz's avatar
sletz committed
964

sletz's avatar
sletz committed
965
966
967
968
969
970
971
    int fRefNum;
    int fNotify;
    int fValue;

    JackClientNotificationRequest()
    {}
    JackClientNotificationRequest(int refnum, int notify, int value)
972
            : JackRequest(JackRequest::kNotification), fRefNum(refnum), fNotify(notify), fValue(value)
sletz's avatar
sletz committed
973
974
975
976
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
977
978
979
980
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fNotify, sizeof(int)));
        CheckRes(trans->Read(&fValue, sizeof(int)));
        return 0;
sletz's avatar
sletz committed
981
982
983
984
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
985
986
987
988
989
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fNotify, sizeof(int)));
        CheckRes(trans->Write(&fValue, sizeof(int)));
        return 0;
sletz's avatar
sletz committed
990
991
992
993
994
995
996
997
998
999
1000
    }

};

/*!
\brief ClientNotification.
*/

struct JackClientNotification
{
    char fName[JACK_CLIENT_NAME_SIZE + 1];
For faster browsing, not all history is shown. View entire blame