JackRequest.h 17.5 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
/*!
\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)
    {
sletz's avatar
sletz committed
138
		CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
139
140
141
142
143
144
		return trans->Read(&fOptions, sizeof(int));
    }

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

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

	char fName[JACK_CLIENT_NAME_SIZE + 1];
	int fStatus;

160
    JackClientCheckResult():JackResult(),fStatus(0)
161
162
163
164
165
166
167
168
169
170
    {}
    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
171
		CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
172
173
174
175
176
177
178
		CheckRes(trans->Read(&fStatus, sizeof(int)));
		return 0;
    }

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

sletz's avatar
sletz committed
185
186
187
188
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
189
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
190
191
192
193
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];

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

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

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

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
217
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
218
219
220
221
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
222
    int fSharedGraph;
sletz's avatar
sletz committed
223
224
    uint32_t fProtocolVersion;

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief PortRegister request.
*/

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

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

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

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

/*!
\brief PortRegister result.
*/

381
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
382
383
384
385
{

    jack_port_id_t fPortIndex;

386
    JackPortRegisterResult():JackResult(),fPortIndex(NO_PORT)
sletz's avatar
sletz committed
387
388
    {}

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

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

/*!
\brief PortUnregister request.
*/

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

    int fRefNum;
    int fPortIndex;

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

sletz's avatar
sletz committed
459
460
461
462
    }

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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


/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

/*!
\brief SetBufferSize request.
*/

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

    jack_nframes_t fBufferSize;

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

/*!
\brief ClientNotification request.
*/

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

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

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

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

};

/*!
\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
743
		CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
744
745
746
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
		CheckRes(trans->Read(&fNotify, sizeof(int)));
		CheckRes(trans->Read(&fValue, sizeof(int)));
sletz's avatar
Cleanup    
sletz committed
747
		CheckRes(trans->Read(&fSync, sizeof(int)));
748
		return 0;
sletz's avatar
sletz committed
749
750
751
752
    }

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

};

} // end of namespace

#endif