JackRequest.h 15.9 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*!
\brief Request from client to server.
*/

struct JackRequest
{

public:

    typedef enum {
        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
62
        kClientOpen = 22,
sletz's avatar
sletz committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
        kClientClose = 23,
        kConnectNamePorts = 24,
        kDisconnectNamePorts = 25,

        kNotification = 26
    } RequestType;

    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
104
105
106
107
108
109
110
    }

};

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

struct JackResult
{

    int	fResult;

    JackResult(): fResult( -1)
    {}
    JackResult(int status): fResult(status)
    {}
    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
    }
};

/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
124
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
125
126
127
128
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];

sletz's avatar
sletz committed
129
    JackClientOpenRequest()
sletz's avatar
sletz committed
130
    {}
sletz's avatar
sletz committed
131
    JackClientOpenRequest(const char* name): JackRequest(JackRequest::kClientOpen)
sletz's avatar
sletz committed
132
133
134
135
136
137
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

    int Read(JackChannelTransaction* trans)
    {
138
		return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
sletz's avatar
sletz committed
139
140
141
142
    }

    int Write(JackChannelTransaction* trans)
    {
143
144
		CheckRes(JackRequest::Write(trans));
		return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
sletz's avatar
sletz committed
145
146
147
148
149
150
151
    }
};

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
152
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
153
154
155
156
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
157
    int fSharedGraph;
sletz's avatar
sletz committed
158
159
    uint32_t fProtocolVersion;

sletz's avatar
sletz committed
160
    JackClientOpenResult()
sletz's avatar
sletz committed
161
		:fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1), fProtocolVersion(0)
sletz's avatar
sletz committed
162
    {}
sletz's avatar
sletz committed
163
    JackClientOpenResult(int32_t status, int index1, int index2, int index3)
164
         : JackResult(status), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3), fProtocolVersion(0)
sletz's avatar
sletz committed
165
166
    {}

167
   int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
168
    {
sletz's avatar
sletz committed
169
 		CheckRes(JackResult::Read(trans));
170
171
172
		CheckRes(trans->Read(&fSharedEngine, sizeof(int)));
		CheckRes(trans->Read(&fSharedClient, sizeof(int)));
		CheckRes(trans->Read(&fSharedGraph, sizeof(int)));
sletz's avatar
Cleanup    
sletz committed
173
		CheckRes(trans->Read(&fProtocolVersion, sizeof(uint32_t)));
174
		return 0;
sletz's avatar
sletz committed
175
176
177
178
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
179
 		CheckRes(JackResult::Write(trans));
180
181
182
		CheckRes(trans->Write(&fSharedEngine, sizeof(int)));
		CheckRes(trans->Write(&fSharedClient, sizeof(int)));
		CheckRes(trans->Write(&fSharedGraph, sizeof(int)));
sletz's avatar
Cleanup    
sletz committed
183
		CheckRes(trans->Write(&fProtocolVersion, sizeof(uint32_t)));
184
		return 0;
sletz's avatar
sletz committed
185
186
187
188
189
190
191
    }
};

/*!
\brief CloseClient request.
*/

192
struct JackClientCloseRequest : public JackRequest
sletz's avatar
sletz committed
193
194
195
196
197
198
{

    int fRefNum;

    JackClientCloseRequest()
    {}
199
    JackClientCloseRequest(int refnum): JackRequest(JackRequest::kClientClose), fRefNum(refnum)
sletz's avatar
sletz committed
200
201
202
203
    {}

    int Read(JackChannelTransaction* trans)
    {
204
		return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
205
206
207
208
    }

    int Write(JackChannelTransaction* trans)
    {
209
210
		CheckRes(JackRequest::Write(trans));
		return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
211
212
213
214
215
216
217
    }
};

/*!
\brief Activate request.
*/

218
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
219
220
221
222
223
224
{

    int fRefNum;

    JackActivateRequest()
    {}
225
    JackActivateRequest(int refnum): JackRequest(JackRequest::kActivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
226
227
228
229
    {}

    int Read(JackChannelTransaction* trans)
    {
230
		return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
231
232
233
234
    }

    int Write(JackChannelTransaction* trans)
    {
235
236
		CheckRes(JackRequest::Write(trans));
		return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
237
238
239
240
241
242
243
244
    }

};

/*!
\brief Deactivate request.
*/

245
struct JackDeactivateRequest : public JackRequest
sletz's avatar
sletz committed
246
247
248
249
250
251
{

    int fRefNum;

    JackDeactivateRequest()
    {}
252
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
253
254
255
256
    {}

    int Read(JackChannelTransaction* trans)
    {
257
		return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
258
259
260
261
    }

    int Write(JackChannelTransaction* trans)
    {
262
263
		CheckRes(JackRequest::Write(trans));
		return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
264
265
266
267
268
269
270
271
    }

};

/*!
\brief PortRegister request.
*/

272
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
273
274
275
276
277
278
279
280
281
282
283
{

    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)
284
            : JackRequest(JackRequest::kRegisterPort), fRefNum(refnum), fFlags(flags), fBufferSize(buffer_size)
sletz's avatar
sletz committed
285
286
287
288
289
290
291
    {
        strcpy(fName, name);
        strcpy(fPortType, port_type);
    }

    int Read(JackChannelTransaction* trans)
    {
292
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
293
294
		CheckRes(trans->Read(&fName, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Read(&fPortType, JACK_PORT_TYPE_SIZE + 1));
295
296
297
		CheckRes(trans->Read(&fFlags, sizeof(unsigned int)));
		CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int)));
		return 0;
sletz's avatar
sletz committed
298
299
300
301
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
302
 		CheckRes(JackRequest::Write(trans));
303
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
304
305
		CheckRes(trans->Write(&fName, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Write(&fPortType, JACK_PORT_TYPE_SIZE + 1));
306
307
308
		CheckRes(trans->Write(&fFlags, sizeof(unsigned int)));
		CheckRes(trans->Write(&fBufferSize, sizeof(unsigned int)));
		return 0;
sletz's avatar
sletz committed
309
310
311
312
313
314
315
    }
};

/*!
\brief PortRegister result.
*/

316
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
317
318
319
320
321
322
323
{

    jack_port_id_t fPortIndex;

    JackPortRegisterResult(): fPortIndex(NO_PORT)
    {}

sletz's avatar
sletz committed
324
    int Read(JackChannelTransaction* trans)
sletz's avatar
Cleanup    
sletz committed
325
326
327
    {
		CheckRes(JackResult::Read(trans));
		return trans->Read(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
328
329
330
331
    }

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

/*!
\brief PortUnregister request.
*/

341
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
342
343
344
345
346
347
348
{

    int fRefNum;
    int fPortIndex;

    JackPortUnRegisterRequest()
    {}
349
    JackPortUnRegisterRequest(int refnum, int index): JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
350
351
352
353
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
354
  		CheckRes(trans->Read(&fRefNum, sizeof(int)));
355
356
		CheckRes(trans->Read(&fPortIndex, sizeof(int)));
		return 0;
sletz's avatar
sletz committed
357
358
359
360
    }

    int Write(JackChannelTransaction* trans)
    {
361
362
363
364
		CheckRes(JackRequest::Write(trans));
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
		CheckRes(trans->Write(&fPortIndex, sizeof(int)));
		return 0;
sletz's avatar
sletz committed
365
366
367
368
369
370
371
    }
};

/*!
\brief PortConnectName request.
*/

372
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
373
{
sletz's avatar
sletz committed
374
	
sletz's avatar
sletz committed
375
376
377
378
379
380
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortConnectNameRequest()
    {}
381
    JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name): JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
382
383
384
385
386
387
388
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
389
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
390
391
		CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Read(&fDst,JACK_PORT_NAME_SIZE + 1));
392
393
		return 0;

sletz's avatar
sletz committed
394
395
396
397
    }

    int Write(JackChannelTransaction* trans)
    {
398
399
		CheckRes(JackRequest::Write(trans));
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
400
401
		CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1));
402
		return 0;
sletz's avatar
sletz committed
403
404
405
406
407
408
409
    }
};

/*!
\brief PortDisconnectName request.
*/

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

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

    JackPortDisconnectNameRequest()
    {}
419
    JackPortDisconnectNameRequest(int refnum, const char* src_name, const char* dst_name): JackRequest(JackRequest::kDisconnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
420
421
422
423
424
425
426
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
427
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
428
429
		CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1));
430
		return 0;
sletz's avatar
sletz committed
431
432
433
434
    }

    int Write(JackChannelTransaction* trans)
    {
435
436
		CheckRes(JackRequest::Write(trans));
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
Typo    
sletz committed
437
438
		CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1));
		CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1));
439
		return 0;
sletz's avatar
sletz committed
440
441
442
443
444
445
446
    }
};

/*!
\brief PortConnect request.
*/

447
struct JackPortConnectRequest : public JackRequest
sletz's avatar
sletz committed
448
449
450
451
452
453
454
455
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
456
    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
457
458
459
460
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
461
  		CheckRes(trans->Read(&fRefNum, sizeof(int)));
462
463
464
		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
465
466
467
468
    }

    int Write(JackChannelTransaction* trans)
    {
469
470
471
472
473
		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
474
475
476
477
478
479
480
481
    }
};


/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
491
    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
492
493
494
495
    {}

    int Read(JackChannelTransaction* trans)
    {
496
497
498
499
		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
500
501
502
503
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
504
 		CheckRes(JackRequest::Write(trans));
505
506
507
508
509
		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
510
511
512
513
514
515
516
    }
};

/*!
\brief SetBufferSize request.
*/

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

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
524
    JackSetBufferSizeRequest(jack_nframes_t buffer_size): JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
525
526
527
528
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
529
 		return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
530
531
532
533
    }

    int Write(JackChannelTransaction* trans)
    {
534
535
		CheckRes(JackRequest::Write(trans));
		return trans->Write(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
536
537
538
539
540
541
542
    }
};

/*!
\brief SetFreeWheel request.
*/

543
struct JackSetFreeWheelRequest : public JackRequest
sletz's avatar
sletz committed
544
545
546
547
548
549
{

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
550
    JackSetFreeWheelRequest(int onoff): JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
551
552
553
554
    {}

    int Read(JackChannelTransaction* trans)
    {
555
		return trans->Read(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
556
557
558
559
    }

    int Write(JackChannelTransaction* trans)
    {
560
561
		CheckRes(JackRequest::Write(trans));
		return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
562
563
564
565
566
567
568
    }
};

/*!
\brief ReleaseTimebase request.
*/

569
struct JackReleaseTimebaseRequest : public JackRequest
sletz's avatar
sletz committed
570
571
572
573
574
575
{

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
576
    JackReleaseTimebaseRequest(int refnum): JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
577
578
579
580
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
581
 		return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
582
583
584
585
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
586
 		CheckRes(JackRequest::Write(trans));
587
		return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
588
589
590
591
592
593
594
    }
};

/*!
\brief SetTimebaseCallback request.
*/

595
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
596
597
598
599
600
601
602
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
603
    JackSetTimebaseCallbackRequest(int refnum, int conditional): JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
604
605
606
607
    {}

    int Read(JackChannelTransaction* trans)
    {
608
609
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
		return trans->Read(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
610
611
612
613
    }

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

/*!
\brief ClientNotification request.
*/

624
struct JackClientNotificationRequest : public JackRequest
sletz's avatar
sletz committed
625
{
sletz's avatar
sletz committed
626
	
sletz's avatar
sletz committed
627
628
629
630
631
632
633
    int fRefNum;
    int fNotify;
    int fValue;

    JackClientNotificationRequest()
    {}
    JackClientNotificationRequest(int refnum, int notify, int value)
634
            : JackRequest(JackRequest::kNotification), fRefNum(refnum), fNotify(notify), fValue(value)
sletz's avatar
sletz committed
635
636
637
638
    {}

    int Read(JackChannelTransaction* trans)
    {
639
640
641
642
		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
643
644
645
646
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
647
  		CheckRes(JackRequest::Write(trans));
648
649
650
651
		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
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
    }

};

/*!
\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
678
		CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
679
680
681
		CheckRes(trans->Read(&fRefNum, sizeof(int)));
		CheckRes(trans->Read(&fNotify, sizeof(int)));
		CheckRes(trans->Read(&fValue, sizeof(int)));
sletz's avatar
Cleanup    
sletz committed
682
		CheckRes(trans->Read(&fSync, sizeof(int)));
683
		return 0;
sletz's avatar
sletz committed
684
685
686
687
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
688
  		CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
689
690
691
		CheckRes(trans->Write(&fRefNum, sizeof(int)));
		CheckRes(trans->Write(&fNotify, sizeof(int)));
		CheckRes(trans->Write(&fValue, sizeof(int)));
sletz's avatar
Cleanup    
sletz committed
692
		CheckRes(trans->Write(&fSync, sizeof(int)));
693
		return 0;
sletz's avatar
sletz committed
694
695
696
697
698
699
700
    }

};

} // end of namespace

#endif