JackRequest.h 36.8 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>
29
#include <stdlib.h>
Torben Hohn's avatar
Torben Hohn committed
30
#include <list>
sletz's avatar
sletz committed
31
32
33
34

namespace Jack
{

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

/*!
\brief Session API constants.
*/

enum JackSessionReply {

    kImmediateSessionReply = 1,
    kPendingSessionReply = 2

};
sletz's avatar
Cleanup    
sletz committed
47

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

struct JackRequest
{

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

    RequestType fType;

    JackRequest()
    {}

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

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

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

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

};

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

struct JackResult
{

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

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

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

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

sletz's avatar
sletz committed
140
141
};

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

struct JackClientCheckRequest : public JackRequest
{

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

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

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

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

182
};
183
184
185
186
187
188
189
190

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

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

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

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

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

218
};
219

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

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

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

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

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

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

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

/*!
\brief NewClient result.
*/

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

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

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

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief Activate request.
*/

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

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

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

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

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

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

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief PortRegister request.
*/

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

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

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

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

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

/*!
\brief PortRegister result.
*/

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

432
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
433

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

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

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

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

/*!
\brief PortUnregister request.
*/

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

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

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

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

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

sletz's avatar
sletz committed
511
512
513
514
    }

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

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

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

/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

633
};
sletz's avatar
sletz committed
634

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

    }
671

672
};
673

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

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

    jack_nframes_t fBufferSize;

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

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
724
725
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
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
751

};

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

811
};
sletz's avatar
sletz committed
812

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

struct JackGetInternalClientNameRequest : public JackRequest
{

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

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

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

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

842
};
843
844
845
846
847

/*!
\brief GetInternalClient result.
*/

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

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

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

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

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

875
};
876
877
878
879
880
881
882
883

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

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

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

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

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

908
};
909
910
911
912
913
914
915
916

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

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

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

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

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

942
};
943
944
945
946
947
948
949
950

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

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

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

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

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

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

994
};
995
996
997
998
999
1000

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult