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 "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()
    {}
sletz's avatar
sletz committed
133
    JackClientCheckRequest(const char* name, int protocol, int options): JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options)
134
135
136
137
138
139
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

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

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

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

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

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

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

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

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

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

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

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

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

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

/*!
\brief NewClient result.
*/

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

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

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

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

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

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

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

};

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief PortRegister request.
*/

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

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

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

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

/*!
\brief PortRegister result.
*/

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

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

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

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

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

/*!
\brief PortUnregister request.
*/

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

    int fRefNum;
    int fPortIndex;

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

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

sletz's avatar
sletz committed
467
468
469
470
    }

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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


/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

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

/*!
\brief SetBufferSize request.
*/

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

    jack_nframes_t fBufferSize;

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

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

struct JackGetInternalClientNameRequest : public JackRequest
{

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

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

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

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

/*!
\brief GetInternalClient result.
*/

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

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

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

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

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

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

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

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

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

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

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

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

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

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

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

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

827
#ifndef MAX_PATH
sletz's avatar
sletz committed
828
#define MAX_PATH 256
829
#endif
sletz's avatar
sletz committed
830
831

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

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

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

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

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
874
875
    int fStatus;
    int fIntRefNum;
876

sletz's avatar
sletz committed
877
    JackInternalClientLoadResult(): JackResult()
878
879
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
880
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
881
882
    {}

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

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

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
907
    int fRefNum;
908
909
910
911
912
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
913
            : JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref)
914
915
916
917
    {}

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

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


/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientUnloadResult : public JackResult
{

sletz's avatar
sletz committed
938
    int fStatus;
939

sletz's avatar
sletz committed
940
    JackInternalClientUnloadResult(): JackResult()
941
942
    {}
    JackInternalClientUnloadResult(int32_t result, int status)
sletz's avatar
sletz committed
943
            : JackResult(result), fStatus(status)
944
945
    {}

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

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

sletz's avatar
sletz committed
961
962
963
964
/*!
\brief ClientNotification request.
*/

965
struct JackClientNotificationRequest : public JackRequest
sletz's avatar
sletz committed
966
{
sletz's avatar
sletz committed
967

sletz's avatar
sletz committed
968
969
970
971
972
973
974
    int fRefNum;
    int fNotify;
    int fValue;

    JackClientNotificationRequest()
    {}
    JackClientNotificationRequest(int refnum, int notify, int value)
975
            : JackRequest(JackRequest::kNotification), fRefNum(refnum), fNotify(notify), fValue(value)
sletz's avatar
sletz committed
976
977
978
979
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
980
981
982
983
        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
984
985
986
987
    }

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

};

/*!
\brief ClientNotification.
*/