JackRequest.h 36 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
{

Stephane Letz's avatar
Stephane Letz committed
34
35
36
37
38
39
40
41
42
43
44
45
#define CheckRes(exp) { if ((exp) < 0) return -1; }

/*!
\brief Session API constants.
*/

enum JackSessionReply {

    kImmediateSessionReply = 1,
    kPendingSessionReply = 2

};
sletz's avatar
Cleanup    
sletz committed
46

sletz's avatar
sletz committed
47
48
49
50
51
52
53
/*!
\brief Request from client to server.
*/

struct JackRequest
{

54
    enum RequestType {
sletz's avatar
sletz committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
        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
70
        kClientCheck = 22,
71
72
73
74
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
sletz's avatar
sletz committed
75
76
77
78
        kGetInternalClientName = 27,
        kInternalClientHandle = 28,
        kInternalClientLoad = 29,
        kInternalClientUnload = 30,
79
        kPortRename = 31,
80
        kNotification = 32,
81
82
83
84
        kSessionNotify = 33,
        kSessionReply  = 34,
        kGetClientByUUID = 35,
        kReserveClientName = 36,
85
        kGetUUIDByClient = 37,
86
87
        kClientHasSessionCallback = 38,
        kComputeTotalLatencies = 39
88
    };
sletz's avatar
sletz committed
89
90
91
92
93
94
95
96
97

    RequestType fType;

    JackRequest()
    {}

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

sletz's avatar
sletz committed
98
    virtual ~JackRequest()
sletz's avatar
sletz committed
99
100
    {}

sletz's avatar
sletz committed
101
    virtual int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
102
    {
sletz's avatar
sletz committed
103
        return trans->Read(&fType, sizeof(RequestType));
sletz's avatar
sletz committed
104
105
    }

sletz's avatar
sletz committed
106
    virtual int Write(JackChannelTransaction* trans)
sletz's avatar
sletz committed
107
    {
sletz's avatar
sletz committed
108
        return trans->Write(&fType, sizeof(RequestType));
sletz's avatar
sletz committed
109
110
111
112
113
114
115
116
117
118
119
    }

};

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

struct JackResult
{

120
    int fResult;
sletz's avatar
sletz committed
121
122
123

    JackResult(): fResult( -1)
    {}
124
    JackResult(int result): fResult(result)
sletz's avatar
sletz committed
125
126
127
128
129
130
    {}
    virtual ~JackResult()
    {}

    virtual int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
131
        return trans->Read(&fResult, sizeof(int));
sletz's avatar
sletz committed
132
133
134
135
    }

    virtual int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
136
        return trans->Write(&fResult, sizeof(int));
sletz's avatar
sletz committed
137
    }
138

sletz's avatar
sletz committed
139
140
};

141
142
143
144
145
146
147
148
/*!
\brief CheckClient request.
*/

struct JackClientCheckRequest : public JackRequest
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
149
    int fProtocol;
sletz's avatar
sletz committed
150
    int fOptions;
151
    int fUUID;
152
    int fOpen;
153
154
155

    JackClientCheckRequest()
    {}
156
157
    JackClientCheckRequest(const char* name, int protocol, int options, int uuid, int open = false)
        : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options), fUUID(uuid), fOpen(open)
158
159
160
161
162
163
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

    int Read(JackChannelTransaction* trans)
    {
164
        CheckRes(trans->Read(&fName, sizeof(fName)));
sletz's avatar
sletz committed
165
        CheckRes(trans->Read(&fProtocol, sizeof(int)));
166
        CheckRes(trans->Read(&fOptions, sizeof(int)));
167
168
        CheckRes(trans->Read(&fUUID, sizeof(int)));
        return trans->Read(&fOpen, sizeof(int));
169
170
171
172
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
173
        CheckRes(JackRequest::Write(trans));
174
        CheckRes(trans->Write(&fName,  sizeof(fName)));
sletz's avatar
sletz committed
175
        CheckRes(trans->Write(&fProtocol, sizeof(int)));
176
        CheckRes(trans->Write(&fOptions, sizeof(int)));
177
178
        CheckRes(trans->Write(&fUUID, sizeof(int)));
        return trans->Write(&fOpen, sizeof(int));
179
    }
180

181
};
182
183
184
185
186
187
188
189

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

sletz's avatar
sletz committed
190
191
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fStatus;
192

sletz's avatar
sletz committed
193
    JackClientCheckResult(): JackResult(), fStatus(0)
194
195
    {}
    JackClientCheckResult(int32_t result, const char* name, int status)
sletz's avatar
sletz committed
196
            : JackResult(result), fStatus(status)
197
    {
sletz's avatar
sletz committed
198
199
        snprintf(fName, sizeof(fName), "%s", name);
    }
200

sletz's avatar
sletz committed
201
    int Read(JackChannelTransaction* trans)
202
    {
sletz's avatar
sletz committed
203
        CheckRes(JackResult::Read(trans));
204
        CheckRes(trans->Read(&fName, sizeof(fName)));
sletz's avatar
sletz committed
205
206
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        return 0;
207
208
209
210
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
211
        CheckRes(JackResult::Write(trans));
212
        CheckRes(trans->Write(&fName, sizeof(fName)));
sletz's avatar
sletz committed
213
214
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        return 0;
215
    }
216

217
};
218

sletz's avatar
sletz committed
219
220
221
222
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
223
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
224
225
{

226
    int fPID;
227
    int fUUID;
sletz's avatar
sletz committed
228
    char fName[JACK_CLIENT_NAME_SIZE + 1];
229

sletz's avatar
sletz committed
230
    JackClientOpenRequest()
sletz's avatar
sletz committed
231
    {}
232
    JackClientOpenRequest(const char* name, int pid, int uuid): JackRequest(JackRequest::kClientOpen)
sletz's avatar
sletz committed
233
234
    {
        snprintf(fName, sizeof(fName), "%s", name);
235
        fPID = pid;
236
        fUUID = uuid;
sletz's avatar
sletz committed
237
238
239
240
    }

    int Read(JackChannelTransaction* trans)
    {
241
        CheckRes(trans->Read(&fPID, sizeof(int)));
242
        CheckRes(trans->Read(&fUUID, sizeof(int)));
243
        return trans->Read(&fName,  sizeof(fName));
sletz's avatar
sletz committed
244
245
246
247
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
248
        CheckRes(JackRequest::Write(trans));
249
        CheckRes(trans->Write(&fPID, sizeof(int)));
250
        CheckRes(trans->Write(&fUUID, sizeof(int)));
251
        return trans->Write(&fName,  sizeof(fName));
sletz's avatar
sletz committed
252
    }
253

254
};
sletz's avatar
sletz committed
255
256
257
258
259

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
260
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
261
262
263
264
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
265
    int fSharedGraph;
266

sletz's avatar
sletz committed
267
    JackClientOpenResult()
268
            : JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1)
sletz's avatar
sletz committed
269
    {}
270
    JackClientOpenResult(int32_t result, int index1, int index2, int index3)
271
            : JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3)
sletz's avatar
sletz committed
272
273
    {}

sletz's avatar
sletz committed
274
    int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
275
    {
sletz's avatar
sletz committed
276
277
278
279
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fSharedEngine, sizeof(int)));
        CheckRes(trans->Read(&fSharedClient, sizeof(int)));
        CheckRes(trans->Read(&fSharedGraph, sizeof(int)));
280
        return 0;
sletz's avatar
sletz committed
281
282
283
284
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
285
286
287
288
289
        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
290
    }
291

292
};
sletz's avatar
sletz committed
293
294
295
296
297

/*!
\brief CloseClient request.
*/

298
struct JackClientCloseRequest : public JackRequest
sletz's avatar
sletz committed
299
300
301
302
303
304
{

    int fRefNum;

    JackClientCloseRequest()
    {}
305
    JackClientCloseRequest(int refnum): JackRequest(JackRequest::kClientClose), fRefNum(refnum)
sletz's avatar
sletz committed
306
307
308
309
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
310
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
311
312
313
314
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
315
316
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
317
    }
318

319
};
sletz's avatar
sletz committed
320
321
322
323
324

/*!
\brief Activate request.
*/

325
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
326
327
328
{

    int fRefNum;
sletz's avatar
sletz committed
329
    int fIsRealTime;
sletz's avatar
sletz committed
330
331
332

    JackActivateRequest()
    {}
sletz's avatar
sletz committed
333
334
    JackActivateRequest(int refnum, int is_real_time)
        : JackRequest(JackRequest::kActivateClient), fRefNum(refnum), fIsRealTime(is_real_time)
sletz's avatar
sletz committed
335
336
337
338
    {}

    int Read(JackChannelTransaction* trans)
    {
339
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
340
        return trans->Read(&fIsRealTime, sizeof(int));
sletz's avatar
sletz committed
341
342
343
344
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
345
        CheckRes(JackRequest::Write(trans));
346
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
347
        return trans->Write(&fIsRealTime, sizeof(int));
sletz's avatar
sletz committed
348
349
    }

350
};
sletz's avatar
sletz committed
351
352
353
354
355

/*!
\brief Deactivate request.
*/

356
struct JackDeactivateRequest : public JackRequest
sletz's avatar
sletz committed
357
358
359
360
361
362
{

    int fRefNum;

    JackDeactivateRequest()
    {}
363
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
364
365
366
367
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
368
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
369
370
371
372
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
373
374
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
375
376
    }

377
};
sletz's avatar
sletz committed
378
379
380
381
382

/*!
\brief PortRegister request.
*/

383
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
384
385
386
387
388
389
390
391
392
393
394
{

    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)
395
            : JackRequest(JackRequest::kRegisterPort), fRefNum(refnum), fFlags(flags), fBufferSize(buffer_size)
sletz's avatar
sletz committed
396
397
398
399
400
401
402
    {
        strcpy(fName, name);
        strcpy(fPortType, port_type);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
403
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
404
405
        CheckRes(trans->Read(&fName, sizeof(fName)));
        CheckRes(trans->Read(&fPortType, sizeof(fPortType)));
sletz's avatar
sletz committed
406
407
408
        CheckRes(trans->Read(&fFlags, sizeof(unsigned int)));
        CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int)));
        return 0;
sletz's avatar
sletz committed
409
410
411
412
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
413
414
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
415
416
        CheckRes(trans->Write(&fName, sizeof(fName)));
        CheckRes(trans->Write(&fPortType, sizeof(fPortType)));
sletz's avatar
sletz committed
417
418
419
        CheckRes(trans->Write(&fFlags, sizeof(unsigned int)));
        CheckRes(trans->Write(&fBufferSize, sizeof(unsigned int)));
        return 0;
sletz's avatar
sletz committed
420
    }
421

422
};
sletz's avatar
sletz committed
423
424
425
426
427

/*!
\brief PortRegister result.
*/

428
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
429
430
{

431
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
432

sletz's avatar
sletz committed
433
    JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
sletz's avatar
sletz committed
434
435
    {}

sletz's avatar
sletz committed
436
    int Read(JackChannelTransaction* trans)
sletz's avatar
Cleanup    
sletz committed
437
    {
sletz's avatar
sletz committed
438
439
        CheckRes(JackResult::Read(trans));
        return trans->Read(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
440
441
442
443
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
444
445
        CheckRes(JackResult::Write(trans));
        return trans->Write(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
446
    }
447

448
};
sletz's avatar
sletz committed
449
450
451
452
453

/*!
\brief PortUnregister request.
*/

454
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
455
456
457
{

    int fRefNum;
458
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
459
460
461

    JackPortUnRegisterRequest()
    {}
462
    JackPortUnRegisterRequest(int refnum, jack_port_id_t index)
463
        : JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
464
465
466
467
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
468
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
469
        CheckRes(trans->Read(&fPortIndex, sizeof(jack_port_id_t)));
sletz's avatar
sletz committed
470
        return 0;
sletz's avatar
sletz committed
471
472
473
474
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
475
476
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
477
        CheckRes(trans->Write(&fPortIndex, sizeof(jack_port_id_t)));
sletz's avatar
sletz committed
478
        return 0;
sletz's avatar
sletz committed
479
    }
480

481
};
sletz's avatar
sletz committed
482
483
484
485
486

/*!
\brief PortConnectName request.
*/

487
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
488
{
sletz's avatar
sletz committed
489

sletz's avatar
sletz committed
490
491
492
493
494
495
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortConnectNameRequest()
    {}
496
497
    JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
498
499
500
501
502
503
504
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
505
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
506
507
        CheckRes(trans->Read(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Read(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
508
        return 0;
509

sletz's avatar
sletz committed
510
511
512
513
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
514
515
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
516
517
        CheckRes(trans->Write(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Write(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
518
        return 0;
sletz's avatar
sletz committed
519
    }
520

521
};
sletz's avatar
sletz committed
522
523
524
525
526

/*!
\brief PortDisconnectName request.
*/

527
struct JackPortDisconnectNameRequest : public JackRequest
sletz's avatar
sletz committed
528
529
530
531
532
533
534
535
{

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

    JackPortDisconnectNameRequest()
    {}
536
537
    JackPortDisconnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kDisconnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
538
539
540
541
542
543
544
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
545
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
546
547
        CheckRes(trans->Read(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Read(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
548
        return 0;
sletz's avatar
sletz committed
549
550
551
552
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
553
554
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
555
556
        CheckRes(trans->Write(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Write(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
557
        return 0;
sletz's avatar
sletz committed
558
    }
559

560
};
sletz's avatar
sletz committed
561
562
563
564
565

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
575
576
    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
577
578
579
580
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
581
582
583
584
        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
585
586
587
588
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
589
590
591
592
593
        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
594
    }
595

596
};
sletz's avatar
sletz committed
597
598
599
600
601

/*!
\brief PortDisconnect request.
*/

602
struct JackPortDisconnectRequest : public JackRequest
sletz's avatar
sletz committed
603
604
605
606
607
608
609
610
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
611
612
    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
613
614
615
616
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
617
618
619
620
        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
621
622
623
624
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
625
626
627
628
629
        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
630
    }
631

632
};
sletz's avatar
sletz committed
633

634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
/*!
\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)));
657
        CheckRes(trans->Read(&fName, sizeof(fName)));
658
659
660
661
662
663
664
665
        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)));
666
        CheckRes(trans->Write(&fName, sizeof(fName)));
667
668
669
        return 0;

    }
670

671
};
672

sletz's avatar
sletz committed
673
674
675
676
/*!
\brief SetBufferSize request.
*/

677
struct JackSetBufferSizeRequest : public JackRequest
sletz's avatar
sletz committed
678
679
680
681
682
683
{

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
684
685
    JackSetBufferSizeRequest(jack_nframes_t buffer_size)
        : JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
686
687
688
689
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
690
        return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
691
692
693
694
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
695
696
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
697
    }
698

699
};
sletz's avatar
sletz committed
700
701
702
703
704

/*!
\brief SetFreeWheel request.
*/

705
struct JackSetFreeWheelRequest : public JackRequest
sletz's avatar
sletz committed
706
707
708
709
710
711
{

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
712
713
    JackSetFreeWheelRequest(int onoff)
        : JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
714
715
716
717
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
718
        return trans->Read(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
719
720
721
722
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
723
724
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
725
    }
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750

};

/*!
\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;
    }

751
};
sletz's avatar
sletz committed
752
753
754
755
756

/*!
\brief ReleaseTimebase request.
*/

757
struct JackReleaseTimebaseRequest : public JackRequest
sletz's avatar
sletz committed
758
759
760
761
762
763
{

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
764
765
    JackReleaseTimebaseRequest(int refnum)
        : JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
766
767
768
769
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
775
776
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
777
    }
778

779
};
sletz's avatar
sletz committed
780
781
782
783
784

/*!
\brief SetTimebaseCallback request.
*/

785
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
786
787
788
789
790
791
792
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
793
794
    JackSetTimebaseCallbackRequest(int refnum, int conditional)
        : JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
795
796
797
798
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
799
800
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
801
802
803
804
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
805
806
807
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
808
    }
809

810
};
sletz's avatar
sletz committed
811

812
813
814
815
816
817
818
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
819
    int fRefNum;
820
821
822
823
824
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
825
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
826
827
828
829
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
830
831
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
832
833
834
835
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
836
837
838
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
839
    }
840

841
};
842
843
844
845
846

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
847
struct JackGetInternalClientNameResult : public JackResult
848
849
{

sletz's avatar
sletz committed
850
    char fName[JACK_CLIENT_NAME_SIZE + 1];
851

sletz's avatar
sletz committed
852
    JackGetInternalClientNameResult(): JackResult()
853
    {}
sletz's avatar
sletz committed
854
    JackGetInternalClientNameResult(int32_t result, const char* name)
sletz's avatar
sletz committed
855
            : JackResult(result)
856
    {
sletz's avatar
sletz committed
857
858
        snprintf(fName, sizeof(fName), "%s", name);
    }
859

sletz's avatar
sletz committed
860
    int Read(JackChannelTransaction* trans)
861
    {
sletz's avatar
sletz committed
862
        CheckRes(JackResult::Read(trans));
863
        CheckRes(trans->Read(&fName,  sizeof(fName)));
sletz's avatar
sletz committed
864
        return 0;
865
866
867
868
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
869
        CheckRes(JackResult::Write(trans));
870
        CheckRes(trans->Write(&fName,  sizeof(fName)));
sletz's avatar
sletz committed
871
        return 0;
872
    }
873

874
};
875
876
877
878
879
880
881
882

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
883
    int fRefNum;
884
885
886
887
888
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
sletz's avatar
sletz committed
889
            : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
890
    {
sletz's avatar
sletz committed
891
892
        snprintf(fName, sizeof(fName), "%s", client_name);
    }
893
894
895

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
896
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
897
        return trans->Read(&fName,  sizeof(fName));
898
899
900
901
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
902
903
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
904
        return trans->Write(&fName,  sizeof(fName));
905
    }
906

907
};
908
909
910
911
912
913
914
915

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
916
917
    int fStatus;
    int fIntRefNum;
918

sletz's avatar
sletz committed
919
    JackInternalClientHandleResult(): JackResult()
920
921
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
922
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
923
924
    {}

sletz's avatar
sletz committed
925
    int Read(JackChannelTransaction* trans)
926
    {
sletz's avatar
sletz committed
927
928
929
930
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
931
932
933
934
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
935
936
937
938
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
939
    }
940

941
};
942
943
944
945
946
947
948
949

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

950
#ifndef MAX_PATH
sletz's avatar
sletz committed
951
#define MAX_PATH 256
952
#endif
sletz's avatar
sletz committed
953
954

    int fRefNum;
955
    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
956
957
958
    char fDllName[MAX_PATH + 1];
    char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
    int fOptions;
959
    int fUUID;
960
961
962

    JackInternalClientLoadRequest()
    {}
963
964
    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)
965
    {
sletz's avatar
sletz committed
966
967
968
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
969
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
sletz's avatar
sletz committed
970
    }
971
972
973

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
974
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
975
976
977
        CheckRes(trans->Read(&fName,  sizeof(fName)));
        CheckRes(trans->Read(&fDllName, sizeof(fDllName)));
        CheckRes(trans->Read(&fLoadInitName, sizeof(fLoadInitName)));
978
        CheckRes(trans->Read(&fUUID, sizeof(int)));
sletz's avatar
sletz committed
979
        return trans->Read(&fOptions, sizeof(int));
980
981
982
983
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
984
985
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
986
987
988
        CheckRes(trans->Write(&fName,  sizeof(fName)));
        CheckRes(trans->Write(&fDllName, sizeof(fDllName)));
        CheckRes(trans->Write(&fLoadInitName, sizeof(fLoadInitName)));
989
        CheckRes(trans->Write(&fUUID, sizeof(int)));
sletz's avatar
sletz committed
990
        return trans->Write(&fOptions, sizeof(int));
991
    }
992

993
};
994
995
996
997
998
999
1000

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{