JackRequest.h 24.1 KB
Newer Older
sletz's avatar
sletz committed
1

sletz's avatar
Typo    
sletz committed
2

sletz's avatar
sletz committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
    Copyright (C) 2001 Paul Davis 
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 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 General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
*/

#ifndef __JackRequest__
#define __JackRequest__

#include "JackPort.h"
#include "JackChannelTransaction.h"
#include "JackError.h"
#include <stdio.h>

namespace Jack
{

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

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,
58
59
60
61
62
		kClientCheck = 22,
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
63
64
65
66
67
		kGetInternalClientName = 27,
		kInternalClientHandle = 28,
		kInternalClientLoad = 29,
		kInternalClientUnload = 30,
        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)
    {}

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

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

86
 	virtual int Write(JackChannelTransaction* trans)
sletz's avatar
sletz committed
87
    {
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)
    {
111
		return trans->Read(&fResult, sizeof(int));
sletz's avatar
sletz committed
112
113
114
115
    }

    virtual int Write(JackChannelTransaction* trans)
    {
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];
128
	int fProtocol;
sletz's avatar
sletz committed
129
    int fOptions;
130
131
132

    JackClientCheckRequest()
    {}
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
		CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
141
		CheckRes(trans->Read(&fProtocol, sizeof(int)));
142
143
144
145
146
147
		return trans->Read(&fOptions, sizeof(int));
    }

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

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

	char fName[JACK_CLIENT_NAME_SIZE + 1];
	int fStatus;

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

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

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

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
197
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];

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

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

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

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
221
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
222
223
224
225
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
226
    int fSharedGraph;
sletz's avatar
sletz committed
227
228
    uint32_t fProtocolVersion;

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

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
248
 		CheckRes(JackResult::Write(trans));
249
250
251
		CheckRes(trans->Write(&fSharedEngine, sizeof(int)));
		CheckRes(trans->Write(&fSharedClient, sizeof(int)));
		CheckRes(trans->Write(&fSharedGraph, sizeof(int)));
sletz's avatar
Cleanup    
sletz committed
252
		CheckRes(trans->Write(&fProtocolVersion, sizeof(uint32_t)));
253
		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)
    {
273
		return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
274
275
276
277
    }

    int Write(JackChannelTransaction* trans)
    {
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
291
292
293
{

    int fRefNum;

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

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

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

};

/*!
\brief Deactivate request.
*/

314
struct JackDeactivateRequest : public JackRequest
sletz's avatar
sletz committed
315
316
317
318
319
320
{

    int fRefNum;

    JackDeactivateRequest()
    {}
321
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
322
323
324
325
    {}

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

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

};

/*!
\brief PortRegister request.
*/

341
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
342
343
344
345
346
347
348
349
350
351
352
{

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

    int Read(JackChannelTransaction* trans)
    {
361
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
362
363
		CheckRes(trans->Read(&fName, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Read(&fPortType, JACK_PORT_TYPE_SIZE + 1));
364
365
366
		CheckRes(trans->Read(&fFlags, sizeof(unsigned int)));
		CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int)));
		return 0;
sletz's avatar
sletz committed
367
368
369
370
    }

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

/*!
\brief PortRegister result.
*/

385
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
386
387
{

sletz's avatar
sletz committed
388
    unsigned int fPortIndex;
sletz's avatar
sletz committed
389

390
    JackPortRegisterResult():JackResult(),fPortIndex(NO_PORT)
sletz's avatar
sletz committed
391
392
    {}

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

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

/*!
\brief PortUnregister request.
*/

410
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
411
412
413
414
415
416
417
{

    int fRefNum;
    int fPortIndex;

    JackPortUnRegisterRequest()
    {}
418
    JackPortUnRegisterRequest(int refnum, int index): JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
419
420
421
422
    {}

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

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

/*!
\brief PortConnectName request.
*/

441
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
442
{
sletz's avatar
sletz committed
443
	
sletz's avatar
sletz committed
444
445
446
447
448
449
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

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

    int Read(JackChannelTransaction* trans)
    {
458
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
459
		CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1));
sletz's avatar
sletz committed
460
		CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1));
461
462
		return 0;

sletz's avatar
sletz committed
463
464
465
466
    }

    int Write(JackChannelTransaction* trans)
    {
467
468
		CheckRes(JackRequest::Write(trans));
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
469
470
		CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1));
471
		return 0;
sletz's avatar
sletz committed
472
473
474
475
476
477
478
    }
};

/*!
\brief PortDisconnectName request.
*/

479
struct JackPortDisconnectNameRequest : public JackRequest
sletz's avatar
sletz committed
480
481
482
483
484
485
486
487
{

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

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

    int Read(JackChannelTransaction* trans)
    {
496
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
497
498
		CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1));
499
		return 0;
sletz's avatar
sletz committed
500
501
502
503
    }

    int Write(JackChannelTransaction* trans)
    {
504
505
		CheckRes(JackRequest::Write(trans));
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
506
507
		CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1));
508
		return 0;
sletz's avatar
sletz committed
509
510
511
512
513
514
515
    }
};

/*!
\brief PortConnect request.
*/

516
struct JackPortConnectRequest : public JackRequest
sletz's avatar
sletz committed
517
518
519
520
521
522
523
524
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
525
    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
526
527
528
529
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
530
  		CheckRes(trans->Read(&fRefNum, sizeof(int)));
531
532
533
		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
534
535
536
537
    }

    int Write(JackChannelTransaction* trans)
    {
538
539
540
541
542
		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
543
544
545
546
547
548
549
550
    }
};


/*!
\brief PortDisconnect request.
*/

551
struct JackPortDisconnectRequest : public JackRequest
sletz's avatar
sletz committed
552
553
554
555
556
557
558
559
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
560
    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
561
562
563
564
    {}

    int Read(JackChannelTransaction* trans)
    {
565
566
567
568
		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
569
570
571
572
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
573
 		CheckRes(JackRequest::Write(trans));
574
575
576
577
578
		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
579
580
581
582
583
584
585
    }
};

/*!
\brief SetBufferSize request.
*/

586
struct JackSetBufferSizeRequest : public JackRequest
sletz's avatar
sletz committed
587
588
589
590
591
592
{

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
593
    JackSetBufferSizeRequest(jack_nframes_t buffer_size): JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
594
595
596
597
    {}

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

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

/*!
\brief SetFreeWheel request.
*/

612
struct JackSetFreeWheelRequest : public JackRequest
sletz's avatar
sletz committed
613
614
615
616
617
618
{

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
619
    JackSetFreeWheelRequest(int onoff): JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
620
621
622
623
    {}

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

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

/*!
\brief ReleaseTimebase request.
*/

638
struct JackReleaseTimebaseRequest : public JackRequest
sletz's avatar
sletz committed
639
640
641
642
643
644
{

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
645
    JackReleaseTimebaseRequest(int refnum): JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
646
647
648
649
    {}

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

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

/*!
\brief SetTimebaseCallback request.
*/

664
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
665
666
667
668
669
670
671
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
672
    JackSetTimebaseCallbackRequest(int refnum, int conditional): JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
673
674
675
676
    {}

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

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

689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

 	int fRefNum;
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
		: JackRequest(JackRequest::kGetInternalClientName),fRefNum(refnum),fIntRefNum(int_ref)
    {}

    int Read(JackChannelTransaction* trans)
    {
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
		return trans->Read(&fIntRefNum, sizeof(int));
    }

    int Write(JackChannelTransaction* trans)
    {
		CheckRes(JackRequest::Write(trans));
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
		return trans->Write(&fIntRefNum, sizeof(int));
    }
};

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
723
struct JackGetInternalClientNameResult : public JackResult
724
725
726
727
{

	char fName[JACK_CLIENT_NAME_SIZE + 1];

sletz's avatar
sletz committed
728
    JackGetInternalClientNameResult():JackResult()
729
    {}
sletz's avatar
sletz committed
730
    JackGetInternalClientNameResult(int32_t result, const char* name)
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
         : JackResult(result)
    {
		  snprintf(fName, sizeof(fName), "%s", name);
	}

	int Read(JackChannelTransaction* trans)
    {
 		CheckRes(JackResult::Read(trans));
		CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
		return 0;
    }

    int Write(JackChannelTransaction* trans)
    {
 		CheckRes(JackResult::Write(trans));
		CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
		return 0;
    }
};

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

 	int fRefNum;
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
		: JackRequest(JackRequest::kInternalClientHandle),fRefNum(refnum)
    {
		snprintf(fName, sizeof(fName), "%s", client_name);
	}

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

    int Write(JackChannelTransaction* trans)
    {
		CheckRes(JackRequest::Write(trans));
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
		return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
    }
};

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

	int fStatus;
	int fIntRefNum;

    JackInternalClientHandleResult():JackResult()
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
         : JackResult(result),fStatus(status),fIntRefNum(int_ref)
    {}

	int Read(JackChannelTransaction* trans)
    {
 		CheckRes(JackResult::Read(trans));
		CheckRes(trans->Read(&fStatus, sizeof(int)));
		CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
		return 0;
    }

    int Write(JackChannelTransaction* trans)
    {
 		CheckRes(JackResult::Write(trans));
		CheckRes(trans->Write(&fStatus, sizeof(int)));
		CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
		return 0;
    }
};

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

	#define MAX_PATH 256
	
 	int fRefNum;
    char fName[JACK_CLIENT_NAME_SIZE + 1];
	char fDllName[MAX_PATH + 1];
	char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
	int fOptions;

    JackInternalClientLoadRequest()
    {}
    JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options)
		: JackRequest(JackRequest::kInternalClientLoad),fRefNum(refnum),fOptions(options)
    {
		snprintf(fName, sizeof(fName), "%s", client_name);
		snprintf(fDllName, sizeof(fDllName), "%s", so_name);
		snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
	}

    int Read(JackChannelTransaction* trans)
    {
		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));
    }

    int Write(JackChannelTransaction* trans)
    {
		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));
    }
};

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

	int fStatus;
	int fIntRefNum;

    JackInternalClientLoadResult():JackResult()
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
         : JackResult(result),fStatus(status),fIntRefNum(int_ref)
    {}

	int Read(JackChannelTransaction* trans)
    {
 		CheckRes(JackResult::Read(trans));
		CheckRes(trans->Read(&fStatus, sizeof(int)));
		CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
		return 0;
    }

    int Write(JackChannelTransaction* trans)
    {
 		CheckRes(JackResult::Write(trans));
		CheckRes(trans->Write(&fStatus, sizeof(int)));
		CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
		return 0;
    }
};

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

 	int fRefNum;
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
		: JackRequest(JackRequest::kInternalClientUnload),fRefNum(refnum),fIntRefNum(int_ref)
    {}

    int Read(JackChannelTransaction* trans)
    {
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
		return trans->Read(&fIntRefNum, sizeof(int));
    }

    int Write(JackChannelTransaction* trans)
    {
		CheckRes(JackRequest::Write(trans));
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
		return trans->Write(&fIntRefNum, sizeof(int));
    }
};


/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientUnloadResult : public JackResult
{

	int fStatus;

    JackInternalClientUnloadResult():JackResult()
    {}
    JackInternalClientUnloadResult(int32_t result, int status)
         : JackResult(result),fStatus(status)
    {}

	int Read(JackChannelTransaction* trans)
    {
 		CheckRes(JackResult::Read(trans));
		CheckRes(trans->Read(&fStatus, sizeof(int)));
		return 0;
    }

    int Write(JackChannelTransaction* trans)
    {
 		CheckRes(JackResult::Write(trans));
		CheckRes(trans->Write(&fStatus, sizeof(int)));
		return 0;
    }
};

sletz's avatar
sletz committed
955
956
957
958
/*!
\brief ClientNotification request.
*/

959
struct JackClientNotificationRequest : public JackRequest
sletz's avatar
sletz committed
960
{
sletz's avatar
sletz committed
961
	
sletz's avatar
sletz committed
962
963
964
965
966
967
968
    int fRefNum;
    int fNotify;
    int fValue;

    JackClientNotificationRequest()
    {}
    JackClientNotificationRequest(int refnum, int notify, int value)
969
            : JackRequest(JackRequest::kNotification), fRefNum(refnum), fNotify(notify), fValue(value)
sletz's avatar
sletz committed
970
971
972
973
    {}

    int Read(JackChannelTransaction* trans)
    {
974
975
976
977
		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
978
979
980
981
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
982
  		CheckRes(JackRequest::Write(trans));
983
984
985
986
		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
987
988
989
990
991
992
993
994
995
996
997
998
999
    }

};

/*!
\brief ClientNotification.
*/

struct JackClientNotification
{
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fRefNum;
    int fNotify;
sletz's avatar
sletz committed
1000
    int fValue1;
For faster browsing, not all history is shown. View entire blame