JackRequest.h 25.5 KB
Newer Older
sletz's avatar
sletz committed
1
/*
sletz's avatar
sletz committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Copyright (C) 2001 Paul Davis
Copyright (C) 2004-2008 Grame

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
sletz's avatar
sletz committed
18

sletz's avatar
sletz committed
19
20
21
22
23
*/

#ifndef __JackRequest__
#define __JackRequest__

sletz's avatar
sletz committed
24
#include "JackConstants.h"
sletz's avatar
sletz committed
25
26
27
28
29
30
31
#include "JackChannelTransaction.h"
#include "JackError.h"
#include <stdio.h>

namespace Jack
{

sletz's avatar
Cleanup    
sletz committed
32
33
#define CheckRes(res) {if (res < 0) return res;}

sletz's avatar
sletz committed
34
35
36
37
38
39
40
/*!
\brief Request from client to server.
*/

struct JackRequest
{

41
    enum RequestType {
sletz's avatar
sletz committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        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
57
        kClientCheck = 22,
58
59
60
61
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
sletz's avatar
sletz committed
62
63
64
65
        kGetInternalClientName = 27,
        kInternalClientHandle = 28,
        kInternalClientLoad = 29,
        kInternalClientUnload = 30,
66
        kNotification = 31
67
    };
sletz's avatar
sletz committed
68
69
70
71
72
73
74
75
76

    RequestType fType;

    JackRequest()
    {}

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

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

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

sletz's avatar
sletz committed
85
    virtual int Write(JackChannelTransaction* trans)
sletz's avatar
sletz committed
86
    {
sletz's avatar
sletz committed
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)
    {
sletz's avatar
sletz committed
110
        return trans->Read(&fResult, sizeof(int));
sletz's avatar
sletz committed
111
112
113
114
    }

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

119
120
121
122
123
124
125
126
/*!
\brief CheckClient request.
*/

struct JackClientCheckRequest : public JackRequest
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
127
    int fProtocol;
sletz's avatar
sletz committed
128
    int fOptions;
129
130
131

    JackClientCheckRequest()
    {}
sletz's avatar
sletz committed
132
    JackClientCheckRequest(const char* name, int protocol, int options): JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options)
133
134
135
136
137
138
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
139
140
141
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fProtocol, sizeof(int)));
        return trans->Read(&fOptions, sizeof(int));
142
143
144
145
    }

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

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

sletz's avatar
sletz committed
160
161
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fStatus;
162

sletz's avatar
sletz committed
163
    JackClientCheckResult(): JackResult(), fStatus(0)
164
165
    {}
    JackClientCheckResult(int32_t result, const char* name, int status)
sletz's avatar
sletz committed
166
            : JackResult(result), fStatus(status)
167
    {
sletz's avatar
sletz committed
168
169
        snprintf(fName, sizeof(fName), "%s", name);
    }
170

sletz's avatar
sletz committed
171
    int Read(JackChannelTransaction* trans)
172
    {
sletz's avatar
sletz committed
173
174
175
176
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        return 0;
177
178
179
180
    }

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

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

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

    char fName[JACK_CLIENT_NAME_SIZE + 1];

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

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

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

/*!
\brief NewClient result.
*/

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

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

sletz's avatar
sletz committed
228
    JackClientOpenResult()
sletz's avatar
sletz committed
229
            : JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1), fProtocolVersion(0)
sletz's avatar
sletz committed
230
    {}
231
    JackClientOpenResult(int32_t result, int index1, int index2, int index3)
sletz's avatar
sletz committed
232
            : JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3), fProtocolVersion(0)
sletz's avatar
sletz committed
233
234
    {}

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

};

/*!
\brief PortRegister request.
*/

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

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

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

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

/*!
\brief PortRegister result.
*/

384
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
385
386
{

sletz's avatar
sletz committed
387
    unsigned int fPortIndex;
sletz's avatar
sletz committed
388

sletz's avatar
sletz committed
389
    JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
sletz's avatar
sletz committed
390
391
    {}

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

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

/*!
\brief PortUnregister request.
*/

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

    int fRefNum;
    int fPortIndex;

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

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

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

/*!
\brief PortConnectName request.
*/

440
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
441
{
sletz's avatar
sletz committed
442

sletz's avatar
sletz committed
443
444
445
446
447
448
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

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

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

sletz's avatar
sletz committed
462
463
464
465
    }

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
529
530
531
532
        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
533
534
535
536
    }

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


/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
564
565
566
567
        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
568
569
570
571
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
572
573
574
575
576
        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;
577

sletz's avatar
sletz committed
578
579
580
581
582
583
584
    }
};

/*!
\brief SetBufferSize request.
*/

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

    jack_nframes_t fBufferSize;

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

688
689
690
691
692
693
694
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
695
    int fRefNum;
696
697
698
699
700
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
701
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
702
703
704
705
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
706
707
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
708
709
710
711
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
712
713
714
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
715
716
717
718
719
720
721
    }
};

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
722
struct JackGetInternalClientNameResult : public JackResult
723
724
{

sletz's avatar
sletz committed
725
    char fName[JACK_CLIENT_NAME_SIZE + 1];
726

sletz's avatar
sletz committed
727
    JackGetInternalClientNameResult(): JackResult()
728
    {}
sletz's avatar
sletz committed
729
    JackGetInternalClientNameResult(int32_t result, const char* name)
sletz's avatar
sletz committed
730
            : JackResult(result)
731
    {
sletz's avatar
sletz committed
732
733
        snprintf(fName, sizeof(fName), "%s", name);
    }
734

sletz's avatar
sletz committed
735
    int Read(JackChannelTransaction* trans)
736
    {
sletz's avatar
sletz committed
737
738
739
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
740
741
742
743
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
744
745
746
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
747
748
749
750
751
752
753
754
755
756
    }
};

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
757
    int fRefNum;
758
759
760
761
762
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
sletz's avatar
sletz committed
763
            : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
764
    {
sletz's avatar
sletz committed
765
766
        snprintf(fName, sizeof(fName), "%s", client_name);
    }
767
768
769

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
770
771
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
772
773
774
775
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
776
777
778
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
779
780
781
782
783
784
785
786
787
788
    }
};

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
789
790
    int fStatus;
    int fIntRefNum;
791

sletz's avatar
sletz committed
792
    JackInternalClientHandleResult(): JackResult()
793
794
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
795
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
796
797
    {}

sletz's avatar
sletz committed
798
    int Read(JackChannelTransaction* trans)
799
    {
sletz's avatar
sletz committed
800
801
802
803
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
804
805
806
807
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
808
809
810
811
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
812
813
814
815
816
817
818
819
820
821
    }
};

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

sletz's avatar
sletz committed
822
823
824
#define MAX_PATH 256

    int fRefNum;
825
    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
826
827
828
    char fDllName[MAX_PATH + 1];
    char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
    int fOptions;
829
830
831
832

    JackInternalClientLoadRequest()
    {}
    JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options)
sletz's avatar
sletz committed
833
            : JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options)
834
    {
sletz's avatar
sletz committed
835
836
837
838
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
    }
839
840
841

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
842
843
844
845
846
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fDllName, MAX_PATH + 1));
        CheckRes(trans->Read(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1));
        return trans->Read(&fOptions, sizeof(int));
847
848
849
850
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
851
852
853
854
855
856
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fDllName, MAX_PATH + 1));
        CheckRes(trans->Write(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1));
        return trans->Write(&fOptions, sizeof(int));
857
858
859
860
861
862
863
864
865
866
    }
};

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
867
868
    int fStatus;
    int fIntRefNum;
869

sletz's avatar
sletz committed
870
    JackInternalClientLoadResult(): JackResult()
871
872
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
873
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
874
875
    {}

sletz's avatar
sletz committed
876
    int Read(JackChannelTransaction* trans)
877
    {
sletz's avatar
sletz committed
878
879
880
881
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
882
883
884
885
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
886
887
888
889
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
890
891
892
893
894
895
896
897
898
899
    }
};

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
900
    int fRefNum;
901
902
903
904
905
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
906
            : JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref)
907
908
909
910
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
911
912
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
913
914
915
916
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
917
918
919
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
920
921
922
923
924
925
926
927
928
929
930
    }
};


/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientUnloadResult : public JackResult
{

sletz's avatar
sletz committed
931
    int fStatus;
932

sletz's avatar
sletz committed
933
    JackInternalClientUnloadResult(): JackResult()
934
935
    {}
    JackInternalClientUnloadResult(int32_t result, int status)
sletz's avatar
sletz committed
936
            : JackResult(result), fStatus(status)
937
938
    {}

sletz's avatar
sletz committed
939
    int Read(JackChannelTransaction* trans)
940
    {
sletz's avatar
sletz committed
941
942
943
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        return 0;
944
945
946
947
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
948
949
950
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        return 0;
951
952
953
    }
};

sletz's avatar
sletz committed
954
955
956
957
/*!
\brief ClientNotification request.
*/

958
struct JackClientNotificationRequest : public JackRequest
sletz's avatar
sletz committed
959
{
sletz's avatar
sletz committed
960

sletz's avatar
sletz committed
961
962
963
964
965
966
967
    int fRefNum;
    int fNotify;
    int fValue;

    JackClientNotificationRequest()
    {}
    JackClientNotificationRequest(int refnum, int notify, int value)
968
            : JackRequest(JackRequest::kNotification), fRefNum(refnum), fNotify(notify), fValue(value)
sletz's avatar
sletz committed
969
970
971
972
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
973
974
975
976
        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
977
978
979
980
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
981
982
983
984
985
        CheckRes(JackRequest::Write(trans));
        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
986
987
988
989
990
991
992
993
994
995
996
997
998
    }

};

/*!
\brief ClientNotification.
*/

struct JackClientNotification
{
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fRefNum;
    int fNotify;
sletz's avatar
sletz committed
999
    int fValue1;
sletz's avatar
sletz committed
1000
    int fValue2;
For faster browsing, not all history is shown. View entire blame