JackRequest.h 25.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 "JackPlatformChannelTransaction.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
        kNotification = 31
68
    };
sletz's avatar
sletz committed
69
70
71
72
73
74
75
76
77

    RequestType fType;

    JackRequest()
    {}

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

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

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

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

};

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

struct JackResult
{

    int	fResult;

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

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

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

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

struct JackClientCheckRequest : public JackRequest
{

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

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

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

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

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

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

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

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

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

sletz's avatar
sletz committed
190
191
192
193
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
194
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
195
196
{

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

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

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

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

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
226
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
227
228
229
230
{

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

289
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
290
291
292
{

    int fRefNum;
293
    int fState;
sletz's avatar
sletz committed
294
295
296

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

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

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

};

/*!
\brief Deactivate request.
*/

320
struct JackDeactivateRequest : public JackRequest
sletz's avatar
sletz committed
321
322
323
324
325
326
{

    int fRefNum;

    JackDeactivateRequest()
    {}
327
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
328
329
330
331
    {}

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

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

};

/*!
\brief PortRegister request.
*/

347
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
348
349
350
351
352
353
354
355
356
357
358
{

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

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

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

/*!
\brief PortRegister result.
*/

391
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
392
393
{

sletz's avatar
sletz committed
394
    unsigned int fPortIndex;
sletz's avatar
sletz committed
395

sletz's avatar
sletz committed
396
    JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
sletz's avatar
sletz committed
397
398
    {}

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

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

/*!
\brief PortUnregister request.
*/

416
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
417
418
419
420
421
422
423
{

    int fRefNum;
    int fPortIndex;

    JackPortUnRegisterRequest()
    {}
424
425
    JackPortUnRegisterRequest(int refnum, int index)
        : JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
426
427
428
429
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
430
431
432
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fPortIndex, sizeof(int)));
        return 0;
sletz's avatar
sletz committed
433
434
435
436
    }

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

/*!
\brief PortConnectName request.
*/

448
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
449
{
sletz's avatar
sletz committed
450

sletz's avatar
sletz committed
451
452
453
454
455
456
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortConnectNameRequest()
    {}
457
458
    JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
459
460
461
462
463
464
465
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
466
467
468
469
        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;
470

sletz's avatar
sletz committed
471
472
473
474
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
475
476
477
478
479
        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
480
481
482
483
484
485
486
    }
};

/*!
\brief PortDisconnectName request.
*/

487
struct JackPortDisconnectNameRequest : public JackRequest
sletz's avatar
sletz committed
488
489
490
491
492
493
494
495
{

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

    JackPortDisconnectNameRequest()
    {}
496
497
    JackPortDisconnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kDisconnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
498
499
500
501
502
503
504
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
505
506
507
508
        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
509
510
511
512
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
513
514
515
516
517
        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
518
519
520
521
522
523
524
    }
};

/*!
\brief PortConnect request.
*/

525
struct JackPortConnectRequest : public JackRequest
sletz's avatar
sletz committed
526
527
528
529
530
531
532
533
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
534
535
    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
536
537
538
539
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
540
541
542
543
        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
544
545
546
547
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
548
549
550
551
552
        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
553
554
555
556
557
558
559
560
    }
};


/*!
\brief PortDisconnect request.
*/

561
struct JackPortDisconnectRequest : public JackRequest
sletz's avatar
sletz committed
562
563
564
565
566
567
568
569
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
570
571
    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
572
573
574
575
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
584
585
586
587
588
        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;
589

sletz's avatar
sletz committed
590
591
592
593
594
595
596
    }
};

/*!
\brief SetBufferSize request.
*/

597
struct JackSetBufferSizeRequest : public JackRequest
sletz's avatar
sletz committed
598
599
600
601
602
603
{

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
604
605
    JackSetBufferSizeRequest(jack_nframes_t buffer_size)
        : JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
606
607
608
609
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
610
        return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
611
612
613
614
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
615
616
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
617
618
619
620
621
622
623
    }
};

/*!
\brief SetFreeWheel request.
*/

624
struct JackSetFreeWheelRequest : public JackRequest
sletz's avatar
sletz committed
625
626
627
628
629
630
{

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
631
632
    JackSetFreeWheelRequest(int onoff)
        : JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
633
634
635
636
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
637
        return trans->Read(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
638
639
640
641
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
642
643
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
644
645
646
647
648
649
650
    }
};

/*!
\brief ReleaseTimebase request.
*/

651
struct JackReleaseTimebaseRequest : public JackRequest
sletz's avatar
sletz committed
652
653
654
655
656
657
{

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
658
659
    JackReleaseTimebaseRequest(int refnum)
        : JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
660
661
662
663
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
664
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
665
666
667
668
    }

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

/*!
\brief SetTimebaseCallback request.
*/

678
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
679
680
681
682
683
684
685
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
686
687
    JackSetTimebaseCallbackRequest(int refnum, int conditional)
        : JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
688
689
690
691
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
692
693
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
694
695
696
697
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
698
699
700
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
701
702
703
    }
};

704
705
706
707
708
709
710
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
711
    int fRefNum;
712
713
714
715
716
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
717
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
718
719
720
721
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
722
723
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
724
725
726
727
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
728
729
730
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
731
732
733
734
735
736
737
    }
};

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
738
struct JackGetInternalClientNameResult : public JackResult
739
740
{

sletz's avatar
sletz committed
741
    char fName[JACK_CLIENT_NAME_SIZE + 1];
742

sletz's avatar
sletz committed
743
    JackGetInternalClientNameResult(): JackResult()
744
    {}
sletz's avatar
sletz committed
745
    JackGetInternalClientNameResult(int32_t result, const char* name)
sletz's avatar
sletz committed
746
            : JackResult(result)
747
    {
sletz's avatar
sletz committed
748
749
        snprintf(fName, sizeof(fName), "%s", name);
    }
750

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
760
761
762
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
763
764
765
766
767
768
769
770
771
772
    }
};

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
773
    int fRefNum;
774
775
776
777
778
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
sletz's avatar
sletz committed
779
            : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
780
    {
sletz's avatar
sletz committed
781
782
        snprintf(fName, sizeof(fName), "%s", client_name);
    }
783
784
785

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
786
787
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
788
789
790
791
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
792
793
794
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
795
796
797
798
799
800
801
802
803
804
    }
};

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
805
806
    int fStatus;
    int fIntRefNum;
807

sletz's avatar
sletz committed
808
    JackInternalClientHandleResult(): JackResult()
809
810
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
811
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
812
813
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
824
825
826
827
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
828
829
830
831
832
833
834
835
836
837
    }
};

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

838
#ifndef MAX_PATH
sletz's avatar
sletz committed
839
#define MAX_PATH 256
840
#endif
sletz's avatar
sletz committed
841
842

    int fRefNum;
843
    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
844
845
846
    char fDllName[MAX_PATH + 1];
    char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
    int fOptions;
847
848
849
850

    JackInternalClientLoadRequest()
    {}
    JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options)
sletz's avatar
sletz committed
851
            : JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options)
852
    {
sletz's avatar
sletz committed
853
854
855
856
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
    }
857
858
859

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
860
861
862
863
864
        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));
865
866
867
868
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
869
870
871
872
873
874
        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));
875
876
877
878
879
880
881
882
883
884
    }
};

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
885
886
    int fStatus;
    int fIntRefNum;
887

sletz's avatar
sletz committed
888
    JackInternalClientLoadResult(): JackResult()
889
890
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
891
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
892
893
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
904
905
906
907
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
908
909
910
911
912
913
914
915
916
917
    }
};

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
918
    int fRefNum;
919
920
921
922
923
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
924
            : JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref)
925
926
927
928
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
929
930
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
931
932
933
934
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
935
936
937
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
938
939
940
941
942
943
944
945
946
947
948
    }
};


/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientUnloadResult : public JackResult
{

sletz's avatar
sletz committed
949
    int fStatus;
950

sletz's avatar
sletz committed
951
    JackInternalClientUnloadResult(): JackResult()
952
953
    {}
    JackInternalClientUnloadResult(int32_t result, int status)
sletz's avatar
sletz committed
954
            : JackResult(result), fStatus(status)
955
956
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
966
967
968
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        return 0;
969
970
971
    }
};

sletz's avatar
sletz committed
972
973
974
975
/*!
\brief ClientNotification request.
*/

976
struct JackClientNotificationRequest : public JackRequest
sletz's avatar
sletz committed
977
{
sletz's avatar
sletz committed
978

sletz's avatar
sletz committed
979
980
981
982
983
984
985
    int fRefNum;
    int fNotify;
    int fValue;

    JackClientNotificationRequest()
    {}
    JackClientNotificationRequest(int refnum, int notify, int value)
986
            : JackRequest(JackRequest::kNotification), fRefNum(refnum), fNotify(notify), fValue(value)
sletz's avatar
sletz committed
987
988
989
990
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
991
992
993
994
        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
995
996
997
998
    }

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