JackRequest.h 37.2 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"
26
#include "JackTime.h"
sletz's avatar
sletz committed
27
#include "types.h"
sletz's avatar
sletz committed
28
#include <string.h>
sletz's avatar
sletz committed
29
#include <stdio.h>
30
#include <stdlib.h>
Torben Hohn's avatar
Torben Hohn committed
31
#include <list>
sletz's avatar
sletz committed
32
33
34
35

namespace Jack
{

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

/*!
\brief Session API constants.
*/

enum JackSessionReply {

    kImmediateSessionReply = 1,
    kPendingSessionReply = 2

};
sletz's avatar
Cleanup    
sletz committed
48

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

struct JackRequest
{

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

    RequestType fType;

    JackRequest()
    {}

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

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

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

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

};

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

struct JackResult
{

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

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

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

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

sletz's avatar
sletz committed
141
142
};

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

struct JackClientCheckRequest : public JackRequest
{

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

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

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

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

183
};
184
185
186
187
188
189
190
191

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

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

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

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

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

219
};
220

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

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

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

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

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

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

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

/*!
\brief NewClient result.
*/

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

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

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

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief Activate request.
*/

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

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

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

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

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

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

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief PortRegister request.
*/

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

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

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

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

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

/*!
\brief PortRegister result.
*/

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

433
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
434

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

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

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

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

/*!
\brief PortUnregister request.
*/

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

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

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

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

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

sletz's avatar
sletz committed
512
513
514
515
    }

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

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

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

/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

634
};
sletz's avatar
sletz committed
635

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

    }
672

673
};
674

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

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

    jack_nframes_t fBufferSize;

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

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

};

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

812
};
sletz's avatar
sletz committed
813

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

struct JackGetInternalClientNameRequest : public JackRequest
{

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

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

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

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

843
};
844
845
846
847
848

/*!
\brief GetInternalClient result.
*/

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

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

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

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

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

876
};
877
878
879
880
881
882
883
884

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

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

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

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

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

909
};
910
911
912
913
914
915
916
917

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

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

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

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

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

943
};
944
945
946
947
948
949
950
951

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

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

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

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

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

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

995
};
996
997
998
999
1000

/*!
\brief InternalClientLoad result.
*/

For faster browsing, not all history is shown. View entire blame