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
/*!
\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,
sletz's avatar
sletz committed
60
        kClientOpen = 22,
sletz's avatar
sletz committed
61
62
63
64
65
        kClientClose = 23,
        kConnectNamePorts = 24,
        kDisconnectNamePorts = 25,

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

    RequestType fType;

    JackRequest()
    {}

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

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

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

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

};

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

struct JackResult
{

    int	fResult;

    JackResult(): fResult( -1)
    {}
    JackResult(int status): fResult(status)
    {}
    virtual ~JackResult()
    {}

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

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

/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
122
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
123
124
125
126
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];

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

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

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

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
150
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
151
152
153
154
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
155
    int fSharedGraph;
sletz's avatar
sletz committed
156
157
    uint32_t fProtocolVersion;

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief PortRegister request.
*/

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

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

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

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

/*!
\brief PortRegister result.
*/

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

    jack_port_id_t fPortIndex;

    JackPortRegisterResult(): fPortIndex(NO_PORT)
    {}

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

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

/*!
\brief PortUnregister request.
*/

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

    int fRefNum;
    int fPortIndex;

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

sletz's avatar
sletz committed
392
393
394
395
    }

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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


/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

/*!
\brief SetBufferSize request.
*/

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

    jack_nframes_t fBufferSize;

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

/*!
\brief ClientNotification request.
*/

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

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

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

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

};

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

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

};

} // end of namespace

#endif