JackRequest.h 17.4 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
58
59
        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,
60
61
62
63
64
		kClientCheck = 22,
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
sletz's avatar
sletz committed
65

66
        kNotification = 27
67
    };
sletz's avatar
sletz committed
68
69
70
71
72
73
74
75
76

    RequestType fType;

    JackRequest()
    {}

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

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

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

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

};

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

struct JackResult
{

    int	fResult;

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

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

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

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*!
\brief CheckClient request.
*/

struct JackClientCheckRequest : public JackRequest
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];
	int fOptions;

    JackClientCheckRequest()
    {}
    JackClientCheckRequest(const char* name, int options): JackRequest(JackRequest::kClientCheck),fOptions(options)
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

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

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


/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

	char fName[JACK_CLIENT_NAME_SIZE + 1];
	int fStatus;

    JackClientCheckResult():fStatus(0)
    {}
    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));
		CheckRes(trans->Read(&fName, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Read(&fStatus, sizeof(int)));
		return 0;
    }

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


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

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

    char fName[JACK_CLIENT_NAME_SIZE + 1];

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

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

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

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
219
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
220
221
222
223
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
224
    int fSharedGraph;
sletz's avatar
sletz committed
225
226
    uint32_t fProtocolVersion;

sletz's avatar
sletz committed
227
    JackClientOpenResult()
sletz's avatar
sletz committed
228
		:fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1), fProtocolVersion(0)
sletz's avatar
sletz committed
229
    {}
230
231
    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
232
233
    {}

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief PortRegister request.
*/

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

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

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

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

/*!
\brief PortRegister result.
*/

383
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
384
385
386
387
388
389
390
{

    jack_port_id_t fPortIndex;

    JackPortRegisterResult(): fPortIndex(NO_PORT)
    {}

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

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

/*!
\brief PortUnregister request.
*/

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

    int fRefNum;
    int fPortIndex;

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

sletz's avatar
sletz committed
461
462
463
464
    }

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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


/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

/*!
\brief SetBufferSize request.
*/

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

    jack_nframes_t fBufferSize;

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

/*!
\brief ClientNotification request.
*/

691
struct JackClientNotificationRequest : public JackRequest
sletz's avatar
sletz committed
692
{
sletz's avatar
sletz committed
693
	
sletz's avatar
sletz committed
694
695
696
697
698
699
700
    int fRefNum;
    int fNotify;
    int fValue;

    JackClientNotificationRequest()
    {}
    JackClientNotificationRequest(int refnum, int notify, int value)
701
            : JackRequest(JackRequest::kNotification), fRefNum(refnum), fNotify(notify), fValue(value)
sletz's avatar
sletz committed
702
703
704
705
    {}

    int Read(JackChannelTransaction* trans)
    {
706
707
708
709
		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
710
711
712
713
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
714
  		CheckRes(JackRequest::Write(trans));
715
716
717
718
		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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
    }

};

/*!
\brief ClientNotification.
*/

struct JackClientNotification
{
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fRefNum;
    int fNotify;
    int fValue;
    int fSync;

    JackClientNotification(): fNotify( -1), fValue( -1)
    {}
    JackClientNotification(const char* name, int refnum, int notify, int sync, int value)
            : fRefNum(refnum), fNotify(notify), fValue(value), fSync(sync)
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
Typo    
sletz committed
745
		CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
746
747
748
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
		CheckRes(trans->Read(&fNotify, sizeof(int)));
		CheckRes(trans->Read(&fValue, sizeof(int)));
sletz's avatar
Cleanup    
sletz committed
749
		CheckRes(trans->Read(&fSync, sizeof(int)));
750
		return 0;
sletz's avatar
sletz committed
751
752
753
754
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
755
  		CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
756
757
758
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
		CheckRes(trans->Write(&fNotify, sizeof(int)));
		CheckRes(trans->Write(&fValue, sizeof(int)));
sletz's avatar
Cleanup    
sletz committed
759
		CheckRes(trans->Write(&fSync, sizeof(int)));
760
		return 0;
sletz's avatar
sletz committed
761
762
763
764
765
766
767
    }

};

} // end of namespace

#endif