JackRequest.h 35 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
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
16
along with this program; if not, write to the Free Software
sletz's avatar
sletz committed
17
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"
25
#include "JackPlatformPlug.h"
sletz's avatar
sletz committed
26
#include "types.h"
sletz's avatar
sletz committed
27
#include <string.h>
sletz's avatar
sletz committed
28
#include <stdio.h>
Torben Hohn's avatar
Torben Hohn committed
29
#include <list>
sletz's avatar
sletz committed
30
31
32
33

namespace Jack
{

34
#define CheckRes(exp) { if ((exp) < 0) return -1;}
sletz's avatar
Cleanup    
sletz committed
35

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

struct JackRequest
{

43
    enum RequestType {
sletz's avatar
sletz committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        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
59
        kClientCheck = 22,
60
61
62
63
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
sletz's avatar
sletz committed
64
65
66
67
        kGetInternalClientName = 27,
        kInternalClientHandle = 28,
        kInternalClientLoad = 29,
        kInternalClientUnload = 30,
68
        kPortRename = 31,
69
        kNotification = 32,
70
71
72
73
        kSessionNotify = 33,
        kSessionReply  = 34,
        kGetClientByUUID = 35,
        kReserveClientName = 36,
74
75
        kGetUUIDByClient = 37,
        kComputeTotalLatencies = 38
76
    };
sletz's avatar
sletz committed
77
78
79
80
81
82
83
84
85

    RequestType fType;

    JackRequest()
    {}

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

sletz's avatar
sletz committed
86
    virtual ~JackRequest()
sletz's avatar
sletz committed
87
88
    {}

sletz's avatar
sletz committed
89
    virtual int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
90
    {
sletz's avatar
sletz committed
91
        return trans->Read(&fType, sizeof(RequestType));
sletz's avatar
sletz committed
92
93
    }

sletz's avatar
sletz committed
94
    virtual int Write(JackChannelTransaction* trans)
sletz's avatar
sletz committed
95
    {
sletz's avatar
sletz committed
96
        return trans->Write(&fType, sizeof(RequestType));
sletz's avatar
sletz committed
97
98
99
100
101
102
103
104
105
106
107
    }

};

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

struct JackResult
{

108
    int fResult;
sletz's avatar
sletz committed
109
110
111

    JackResult(): fResult( -1)
    {}
112
    JackResult(int result): fResult(result)
sletz's avatar
sletz committed
113
114
115
116
117
118
    {}
    virtual ~JackResult()
    {}

    virtual int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
119
        return trans->Read(&fResult, sizeof(int));
sletz's avatar
sletz committed
120
121
122
123
    }

    virtual int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
124
        return trans->Write(&fResult, sizeof(int));
sletz's avatar
sletz committed
125
    }
126

sletz's avatar
sletz committed
127
128
};

129
130
131
132
133
134
135
136
/*!
\brief CheckClient request.
*/

struct JackClientCheckRequest : public JackRequest
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
137
    int fProtocol;
sletz's avatar
sletz committed
138
    int fOptions;
139
    int fUUID;
140
141
142

    JackClientCheckRequest()
    {}
143
144
    JackClientCheckRequest(const char* name, int protocol, int options, int uuid)
        : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options), fUUID(uuid)
145
146
147
148
149
150
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

    int Read(JackChannelTransaction* trans)
    {
151
        CheckRes(trans->Read(&fName, sizeof(fName)));
sletz's avatar
sletz committed
152
        CheckRes(trans->Read(&fProtocol, sizeof(int)));
153
154
        CheckRes(trans->Read(&fOptions, sizeof(int)));
        return trans->Read(&fUUID, sizeof(int));
155
156
157
158
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
159
        CheckRes(JackRequest::Write(trans));
160
        CheckRes(trans->Write(&fName,  sizeof(fName)));
sletz's avatar
sletz committed
161
        CheckRes(trans->Write(&fProtocol, sizeof(int)));
162
163
        CheckRes(trans->Write(&fOptions, sizeof(int)));
        return trans->Write(&fUUID, sizeof(int));
164
    }
165

166
};
167
168
169
170
171
172
173
174

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

sletz's avatar
sletz committed
175
176
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fStatus;
177

sletz's avatar
sletz committed
178
    JackClientCheckResult(): JackResult(), fStatus(0)
179
180
    {}
    JackClientCheckResult(int32_t result, const char* name, int status)
sletz's avatar
sletz committed
181
            : JackResult(result), fStatus(status)
182
    {
sletz's avatar
sletz committed
183
184
        snprintf(fName, sizeof(fName), "%s", name);
    }
185

sletz's avatar
sletz committed
186
    int Read(JackChannelTransaction* trans)
187
    {
sletz's avatar
sletz committed
188
        CheckRes(JackResult::Read(trans));
189
        CheckRes(trans->Read(&fName, sizeof(fName)));
sletz's avatar
sletz committed
190
191
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        return 0;
192
193
194
195
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
196
        CheckRes(JackResult::Write(trans));
197
        CheckRes(trans->Write(&fName, sizeof(fName)));
sletz's avatar
sletz committed
198
199
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        return 0;
200
    }
201

202
};
203

sletz's avatar
sletz committed
204
205
206
207
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
208
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
209
210
{

211
    int fPID;
212
    int fUUID;
sletz's avatar
sletz committed
213
    char fName[JACK_CLIENT_NAME_SIZE + 1];
214

sletz's avatar
sletz committed
215
    JackClientOpenRequest()
sletz's avatar
sletz committed
216
    {}
217
    JackClientOpenRequest(const char* name, int pid, int uuid): JackRequest(JackRequest::kClientOpen)
sletz's avatar
sletz committed
218
219
    {
        snprintf(fName, sizeof(fName), "%s", name);
220
        fPID = pid;
221
        fUUID = uuid;
sletz's avatar
sletz committed
222
223
224
225
    }

    int Read(JackChannelTransaction* trans)
    {
226
        CheckRes(trans->Read(&fPID, sizeof(int)));
227
        CheckRes(trans->Read(&fUUID, sizeof(int)));
228
        return trans->Read(&fName,  sizeof(fName));
sletz's avatar
sletz committed
229
230
231
232
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
233
        CheckRes(JackRequest::Write(trans));
234
        CheckRes(trans->Write(&fPID, sizeof(int)));
235
        CheckRes(trans->Write(&fUUID, sizeof(int)));
236
        return trans->Write(&fName,  sizeof(fName));
sletz's avatar
sletz committed
237
    }
238

239
};
sletz's avatar
sletz committed
240
241
242
243
244

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
245
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
246
247
248
249
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
250
    int fSharedGraph;
251

sletz's avatar
sletz committed
252
    JackClientOpenResult()
253
            : JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1)
sletz's avatar
sletz committed
254
    {}
255
    JackClientOpenResult(int32_t result, int index1, int index2, int index3)
256
            : JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3)
sletz's avatar
sletz committed
257
258
    {}

sletz's avatar
sletz committed
259
    int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
260
    {
sletz's avatar
sletz committed
261
262
263
264
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fSharedEngine, sizeof(int)));
        CheckRes(trans->Read(&fSharedClient, sizeof(int)));
        CheckRes(trans->Read(&fSharedGraph, sizeof(int)));
265
        return 0;
sletz's avatar
sletz committed
266
267
268
269
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
270
271
272
273
274
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fSharedEngine, sizeof(int)));
        CheckRes(trans->Write(&fSharedClient, sizeof(int)));
        CheckRes(trans->Write(&fSharedGraph, sizeof(int)));
        return 0;
sletz's avatar
sletz committed
275
    }
276

277
};
sletz's avatar
sletz committed
278
279
280
281
282

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

304
};
sletz's avatar
sletz committed
305
306
307
308
309

/*!
\brief Activate request.
*/

310
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
311
312
313
{

    int fRefNum;
sletz's avatar
sletz committed
314
    int fIsRealTime;
sletz's avatar
sletz committed
315
316
317

    JackActivateRequest()
    {}
sletz's avatar
sletz committed
318
319
    JackActivateRequest(int refnum, int is_real_time)
        : JackRequest(JackRequest::kActivateClient), fRefNum(refnum), fIsRealTime(is_real_time)
sletz's avatar
sletz committed
320
321
322
323
    {}

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

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

335
};
sletz's avatar
sletz committed
336
337
338
339
340

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

    JackDeactivateRequest()
    {}
348
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
349
350
351
352
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
358
359
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
360
361
    }

362
};
sletz's avatar
sletz committed
363
364
365
366
367

/*!
\brief PortRegister request.
*/

368
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
369
370
371
372
373
374
375
376
377
378
379
{

    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)
380
            : JackRequest(JackRequest::kRegisterPort), fRefNum(refnum), fFlags(flags), fBufferSize(buffer_size)
sletz's avatar
sletz committed
381
382
383
384
385
386
387
    {
        strcpy(fName, name);
        strcpy(fPortType, port_type);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
388
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
389
390
        CheckRes(trans->Read(&fName, sizeof(fName)));
        CheckRes(trans->Read(&fPortType, sizeof(fPortType)));
sletz's avatar
sletz committed
391
392
393
        CheckRes(trans->Read(&fFlags, sizeof(unsigned int)));
        CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int)));
        return 0;
sletz's avatar
sletz committed
394
395
396
397
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
398
399
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
400
401
        CheckRes(trans->Write(&fName, sizeof(fName)));
        CheckRes(trans->Write(&fPortType, sizeof(fPortType)));
sletz's avatar
sletz committed
402
403
404
        CheckRes(trans->Write(&fFlags, sizeof(unsigned int)));
        CheckRes(trans->Write(&fBufferSize, sizeof(unsigned int)));
        return 0;
sletz's avatar
sletz committed
405
    }
406

407
};
sletz's avatar
sletz committed
408
409
410
411
412

/*!
\brief PortRegister result.
*/

413
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
414
415
{

416
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
417

sletz's avatar
sletz committed
418
    JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
sletz's avatar
sletz committed
419
420
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
429
430
        CheckRes(JackResult::Write(trans));
        return trans->Write(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
431
    }
432

433
};
sletz's avatar
sletz committed
434
435
436
437
438

/*!
\brief PortUnregister request.
*/

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

    int fRefNum;
443
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
444
445
446

    JackPortUnRegisterRequest()
    {}
447
    JackPortUnRegisterRequest(int refnum, jack_port_id_t index)
448
        : JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
449
450
451
452
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
453
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
454
        CheckRes(trans->Read(&fPortIndex, sizeof(jack_port_id_t)));
sletz's avatar
sletz committed
455
        return 0;
sletz's avatar
sletz committed
456
457
458
459
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
460
461
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
462
        CheckRes(trans->Write(&fPortIndex, sizeof(jack_port_id_t)));
sletz's avatar
sletz committed
463
        return 0;
sletz's avatar
sletz committed
464
    }
465

466
};
sletz's avatar
sletz committed
467
468
469
470
471

/*!
\brief PortConnectName request.
*/

472
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
473
{
sletz's avatar
sletz committed
474

sletz's avatar
sletz committed
475
476
477
478
479
480
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortConnectNameRequest()
    {}
481
482
    JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
483
484
485
486
487
488
489
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
490
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
491
492
        CheckRes(trans->Read(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Read(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
493
        return 0;
494

sletz's avatar
sletz committed
495
496
497
498
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
499
500
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
501
502
        CheckRes(trans->Write(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Write(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
503
        return 0;
sletz's avatar
sletz committed
504
    }
505

506
};
sletz's avatar
sletz committed
507
508
509
510
511

/*!
\brief PortDisconnectName request.
*/

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

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

    JackPortDisconnectNameRequest()
    {}
521
522
    JackPortDisconnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kDisconnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
523
524
525
526
527
528
529
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
530
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
531
532
        CheckRes(trans->Read(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Read(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
533
        return 0;
sletz's avatar
sletz committed
534
535
536
537
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
538
539
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
540
541
        CheckRes(trans->Write(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Write(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
542
        return 0;
sletz's avatar
sletz committed
543
    }
544

545
};
sletz's avatar
sletz committed
546
547
548
549
550

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
560
561
    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
562
563
564
565
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
574
575
576
577
578
        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
579
    }
580

581
};
sletz's avatar
sletz committed
582
583
584
585
586

/*!
\brief PortDisconnect request.
*/

587
struct JackPortDisconnectRequest : public JackRequest
sletz's avatar
sletz committed
588
589
590
591
592
593
594
595
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
596
597
    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
598
599
600
601
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
602
603
604
605
        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
606
607
608
609
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
610
611
612
613
614
        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
615
    }
616

617
};
sletz's avatar
sletz committed
618

619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
/*!
\brief PortRename request.
*/

struct JackPortRenameRequest : public JackRequest
{

    int fRefNum;
    jack_port_id_t fPort;
    char fName[JACK_PORT_NAME_SIZE + 1];

    JackPortRenameRequest()
    {}
    JackPortRenameRequest(int refnum, jack_port_id_t port, const char* name)
        : JackRequest(JackRequest::kPortRename), fRefNum(refnum), fPort(port)
    {
        strcpy(fName, name);
    }

    int Read(JackChannelTransaction* trans)
    {
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fPort, sizeof(jack_port_id_t)));
642
        CheckRes(trans->Read(&fName, sizeof(fName)));
643
644
645
646
647
648
649
650
        return 0;
    }

    int Write(JackChannelTransaction* trans)
    {
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fPort, sizeof(jack_port_id_t)));
651
        CheckRes(trans->Write(&fName, sizeof(fName)));
652
653
654
        return 0;

    }
655

656
};
657

sletz's avatar
sletz committed
658
659
660
661
/*!
\brief SetBufferSize request.
*/

662
struct JackSetBufferSizeRequest : public JackRequest
sletz's avatar
sletz committed
663
664
665
666
667
668
{

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
669
670
    JackSetBufferSizeRequest(jack_nframes_t buffer_size)
        : JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
671
672
673
674
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
675
        return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
676
677
678
679
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
680
681
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
682
    }
683

684
};
sletz's avatar
sletz committed
685
686
687
688
689

/*!
\brief SetFreeWheel request.
*/

690
struct JackSetFreeWheelRequest : public JackRequest
sletz's avatar
sletz committed
691
692
693
694
695
696
{

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
697
698
    JackSetFreeWheelRequest(int onoff)
        : JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
699
700
701
702
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
703
        return trans->Read(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
704
705
706
707
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
708
709
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
710
    }
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735

};

/*!
\brief ComputeTotalLatencies request.
*/

struct JackComputeTotalLatenciesRequest : public JackRequest
{

    JackComputeTotalLatenciesRequest()
        : JackRequest(JackRequest::kComputeTotalLatencies)
    {}

    int Read(JackChannelTransaction* trans)
    {
        return 0;
    }

    int Write(JackChannelTransaction* trans)
    {
        CheckRes(JackRequest::Write(trans));
        return 0;
    }

736
};
sletz's avatar
sletz committed
737
738
739
740
741

/*!
\brief ReleaseTimebase request.
*/

742
struct JackReleaseTimebaseRequest : public JackRequest
sletz's avatar
sletz committed
743
744
745
746
747
748
{

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
749
750
    JackReleaseTimebaseRequest(int refnum)
        : JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
751
752
753
754
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
755
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
756
757
758
759
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
760
761
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
762
    }
763

764
};
sletz's avatar
sletz committed
765
766
767
768
769

/*!
\brief SetTimebaseCallback request.
*/

770
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
771
772
773
774
775
776
777
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
778
779
    JackSetTimebaseCallbackRequest(int refnum, int conditional)
        : JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
780
781
782
783
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
784
785
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
786
787
788
789
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
790
791
792
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
793
    }
794

795
};
sletz's avatar
sletz committed
796

797
798
799
800
801
802
803
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
804
    int fRefNum;
805
806
807
808
809
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
810
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
811
812
813
814
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
815
816
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
817
818
819
820
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
821
822
823
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
824
    }
825

826
};
827
828
829
830
831

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
832
struct JackGetInternalClientNameResult : public JackResult
833
834
{

sletz's avatar
sletz committed
835
    char fName[JACK_CLIENT_NAME_SIZE + 1];
836

sletz's avatar
sletz committed
837
    JackGetInternalClientNameResult(): JackResult()
838
    {}
sletz's avatar
sletz committed
839
    JackGetInternalClientNameResult(int32_t result, const char* name)
sletz's avatar
sletz committed
840
            : JackResult(result)
841
    {
sletz's avatar
sletz committed
842
843
        snprintf(fName, sizeof(fName), "%s", name);
    }
844

sletz's avatar
sletz committed
845
    int Read(JackChannelTransaction* trans)
846
    {
sletz's avatar
sletz committed
847
        CheckRes(JackResult::Read(trans));
848
        CheckRes(trans->Read(&fName,  sizeof(fName)));
sletz's avatar
sletz committed
849
        return 0;
850
851
852
853
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
854
        CheckRes(JackResult::Write(trans));
855
        CheckRes(trans->Write(&fName,  sizeof(fName)));
sletz's avatar
sletz committed
856
        return 0;
857
    }
858

859
};
860
861
862
863
864
865
866
867

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
868
    int fRefNum;
869
870
871
872
873
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
sletz's avatar
sletz committed
874
            : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
875
    {
sletz's avatar
sletz committed
876
877
        snprintf(fName, sizeof(fName), "%s", client_name);
    }
878
879
880

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
881
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
882
        return trans->Read(&fName,  sizeof(fName));
883
884
885
886
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
887
888
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
889
        return trans->Write(&fName,  sizeof(fName));
890
    }
891

892
};
893
894
895
896
897
898
899
900

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
901
902
    int fStatus;
    int fIntRefNum;
903

sletz's avatar
sletz committed
904
    JackInternalClientHandleResult(): JackResult()
905
906
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
907
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
908
909
    {}

sletz's avatar
sletz committed
910
    int Read(JackChannelTransaction* trans)
911
    {
sletz's avatar
sletz committed
912
913
914
915
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
916
917
918
919
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
920
921
922
923
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
924
    }
925

926
};
927
928
929
930
931
932
933
934

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

935
#ifndef MAX_PATH
sletz's avatar
sletz committed
936
#define MAX_PATH 256
937
#endif
sletz's avatar
sletz committed
938
939

    int fRefNum;
940
    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
941
942
943
    char fDllName[MAX_PATH + 1];
    char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
    int fOptions;
944
    int fUUID;
945
946
947

    JackInternalClientLoadRequest()
    {}
948
949
    JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int uuid )
            : JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options), fUUID(uuid)
950
    {
sletz's avatar
sletz committed
951
952
953
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
954
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
sletz's avatar
sletz committed
955
    }
956
957
958

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
959
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
960
961
962
        CheckRes(trans->Read(&fName,  sizeof(fName)));
        CheckRes(trans->Read(&fDllName, sizeof(fDllName)));
        CheckRes(trans->Read(&fLoadInitName, sizeof(fLoadInitName)));
963
        CheckRes(trans->Read(&fUUID, sizeof(int)));
sletz's avatar
sletz committed
964
        return trans->Read(&fOptions, sizeof(int));
965
966
967
968
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
969
970
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
971
972
973
        CheckRes(trans->Write(&fName,  sizeof(fName)));
        CheckRes(trans->Write(&fDllName, sizeof(fDllName)));
        CheckRes(trans->Write(&fLoadInitName, sizeof(fLoadInitName)));
974
        CheckRes(trans->Write(&fUUID, sizeof(int)));
sletz's avatar
sletz committed
975
        return trans->Write(&fOptions, sizeof(int));
976
    }
977

978
};
979
980
981
982
983
984
985
986

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
987
988
    int fStatus;
    int fIntRefNum;
989

sletz's avatar
sletz committed
990
    JackInternalClientLoadResult(): JackResult()
991
992
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
993
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
994
995
    {}

sletz's avatar
sletz committed
996
    int Read(JackChannelTransaction* trans)
997
    {
sletz's avatar
sletz committed
998
999
1000
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));