JackRequest.h 16 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
33
34
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
    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
{

/*!
\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,
        kClientNew = 22,
        kClientClose = 23,
        kConnectNamePorts = 24,
        kDisconnectNamePorts = 25,

        kNotification = 26
    } RequestType;

    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
#define CheckRes(res) {if (res < 0) return res;}

sletz's avatar
sletz committed
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.
*/

124
struct JackClientNewRequest : public JackRequest
sletz's avatar
sletz committed
125
126
127
128
129
130
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackClientNewRequest()
    {}
131
    JackClientNewRequest(const char* name): JackRequest(JackRequest::kClientNew)
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.
*/

152
struct JackClientNewResult : 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
161
    JackClientNewResult()
		:fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1), fProtocolVersion(0)
sletz's avatar
sletz committed
162
163
    {}
    JackClientNewResult(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
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
sletz committed
183
184
		CheckRes(trans->Write(&fProtocolVersion, sizeof(uint32_t)));
		JackLog("JackClientNewResult::Write  result = %ld\n", fResult);
185
		return 0;
sletz's avatar
sletz committed
186
187
188
189
190
191
192
    }
};

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief PortRegister request.
*/

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

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

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

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

/*!
\brief PortRegister result.
*/

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

    jack_port_id_t fPortIndex;

    JackPortRegisterResult(): fPortIndex(NO_PORT)
    {}

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

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

/*!
\brief PortUnregister request.
*/

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

    int fRefNum;
    int fPortIndex;

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

sletz's avatar
sletz committed
395
396
397
398
    }

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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


/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

/*!
\brief SetBufferSize request.
*/

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

    jack_nframes_t fBufferSize;

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

/*!
\brief ClientNotification request.
*/

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

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

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
648
  		CheckRes(JackRequest::Write(trans));
649
650
651
652
		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
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
678
    }

};

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

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

};

} // end of namespace

#endif