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

namespace Jack
{

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

/*!
\brief Session API constants.
*/

enum JackSessionReply {

    kImmediateSessionReply = 1,
    kPendingSessionReply = 2

};
sletz's avatar
Cleanup    
sletz committed
49

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

struct JackRequest
{

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

    RequestType fType;

sletz's avatar
sletz committed
95
    JackRequest(): fType((RequestType)0)
sletz's avatar
sletz committed
96
97
98
99
100
    {}

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

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

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

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

};

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

struct JackResult
{

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

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

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

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

sletz's avatar
sletz committed
142
143
};

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

struct JackClientCheckRequest : public JackRequest
{

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

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

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

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

184
};
185
186
187
188
189
190
191
192

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

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

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

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

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

220
};
221

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

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

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

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

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

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

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

/*!
\brief NewClient result.
*/

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

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

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

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief Activate request.
*/

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

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

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

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

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

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

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief PortRegister request.
*/

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

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

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

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

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

/*!
\brief PortRegister result.
*/

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

434
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
435

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

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

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

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

/*!
\brief PortUnregister request.
*/

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

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

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

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

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

sletz's avatar
sletz committed
513
514
    }

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

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

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

/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

635
};
sletz's avatar
sletz committed
636

637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
/*!
\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);
    }

656
    int Read(detail::JackChannelTransactionInterface* trans)
657
658
659
    {
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fPort, sizeof(jack_port_id_t)));
660
        CheckRes(trans->Read(&fName, sizeof(fName)));
661
662
663
        return 0;
    }

664
    int Write(detail::JackChannelTransactionInterface* trans)
665
666
667
668
    {
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fPort, sizeof(jack_port_id_t)));
669
        CheckRes(trans->Write(&fName, sizeof(fName)));
670
671
672
        return 0;

    }
673

674
};
675

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

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

    jack_nframes_t fBufferSize;

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

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

724
    int Write(detail::JackChannelTransactionInterface* trans)
sletz's avatar
sletz committed
725
    {
sletz's avatar
sletz committed
726
727
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
728
    }
729
730
731
732
733
734
735
736
737
738
739
740
741
742

};

/*!
\brief ComputeTotalLatencies request.
*/

struct JackComputeTotalLatenciesRequest : public JackRequest
{

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

743
    int Read(detail::JackChannelTransactionInterface* trans)
744
745
746
747
    {
        return 0;
    }

748
    int Write(detail::JackChannelTransactionInterface* trans)
749
750
751
752
753
    {
        CheckRes(JackRequest::Write(trans));
        return 0;
    }

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

813
};
sletz's avatar
sletz committed
814

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

struct JackGetInternalClientNameRequest : public JackRequest
{

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

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

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

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

844
};
845
846
847
848
849

/*!
\brief GetInternalClient result.
*/

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

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

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

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

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

877
};
878
879
880
881
882
883
884
885

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

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

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

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

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

910
};
911
912
913
914
915
916
917
918

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

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

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

928
    int Read(detail::JackChannelTransactionInterface* trans)
929
    {
sletz's avatar
sletz committed
930
931
932
933
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes