JackRequest.h 35.7 KB
Newer Older
sletz's avatar
sletz committed
1
/*
sletz's avatar
sletz committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Copyright (C) 2001 Paul Davis
Copyright (C) 2004-2008 Grame

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
16
along with this program; if not, write to the Free Software
sletz's avatar
sletz committed
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
sletz's avatar
sletz committed
18

sletz's avatar
sletz committed
19
20
21
22
23
*/

#ifndef __JackRequest__
#define __JackRequest__

sletz's avatar
sletz committed
24
#include "JackConstants.h"
25
#include "JackPlatformPlug.h"
sletz's avatar
sletz committed
26
#include "types.h"
sletz's avatar
sletz committed
27
#include <string.h>
sletz's avatar
sletz committed
28
#include <stdio.h>
Torben Hohn's avatar
Torben Hohn committed
29
#include <list>
sletz's avatar
sletz committed
30
31
32
33

namespace Jack
{

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

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

struct JackRequest
{

43
    enum RequestType {
sletz's avatar
sletz committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        kRegisterPort = 1,
        kUnRegisterPort = 2,
        kConnectPorts = 3,
        kDisconnectPorts = 4,
        kSetTimeBaseClient = 5,
        kActivateClient = 6,
        kDeactivateClient = 7,
        kDisconnectPort = 8,
        kSetClientCapabilities = 9,
        kGetPortConnections = 10,
        kGetPortNConnections = 11,
        kReleaseTimebase = 12,
        kSetTimebaseCallback = 13,
        kSetBufferSize = 20,
        kSetFreeWheel = 21,
sletz's avatar
sletz committed
59
        kClientCheck = 22,
60
61
62
63
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
sletz's avatar
sletz committed
64
65
66
67
        kGetInternalClientName = 27,
        kInternalClientHandle = 28,
        kInternalClientLoad = 29,
        kInternalClientUnload = 30,
68
        kPortRename = 31,
69
        kNotification = 32,
70
71
72
73
        kSessionNotify = 33,
        kSessionReply  = 34,
        kGetClientByUUID = 35,
        kReserveClientName = 36,
74
        kGetUUIDByClient = 37,
75
76
        kClientHasSessionCallback = 38,
        kComputeTotalLatencies = 39
77
    };
sletz's avatar
sletz committed
78
79
80
81
82
83
84
85
86

    RequestType fType;

    JackRequest()
    {}

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

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

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

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

};

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

struct JackResult
{

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

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

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

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

sletz's avatar
sletz committed
128
129
};

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

struct JackClientCheckRequest : public JackRequest
{

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

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

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

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

167
};
168
169
170
171
172
173
174
175

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

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

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

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

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

203
};
204

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

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

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

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

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

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

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

/*!
\brief NewClient result.
*/

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

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

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

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
271
272
273
274
275
        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
276
    }
277

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief Activate request.
*/

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

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

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

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

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

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

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief PortRegister request.
*/

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

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

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

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

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

/*!
\brief PortRegister result.
*/

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

417
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
418

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

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

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

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

/*!
\brief PortUnregister request.
*/

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

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

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

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

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

sletz's avatar
sletz committed
496
497
498
499
    }

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

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

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

/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

618
};
sletz's avatar
sletz committed
619

620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
/*!
\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)));
643
        CheckRes(trans->Read(&fName, sizeof(fName)));
644
645
646
647
648
649
650
651
        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)));
652
        CheckRes(trans->Write(&fName, sizeof(fName)));
653
654
655
        return 0;

    }
656

657
};
658

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

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

    jack_nframes_t fBufferSize;

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

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

};

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

796
};
sletz's avatar
sletz committed
797

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

struct JackGetInternalClientNameRequest : public JackRequest
{

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

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

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

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

827
};
828
829
830
831
832

/*!
\brief GetInternalClient result.
*/

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

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

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

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

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

860
};
861
862
863
864
865
866
867
868

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

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

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

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

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

893
};
894
895
896
897
898
899
900
901

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

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

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

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

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

927
};
928
929
930
931
932
933
934
935

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

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

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

    JackInternalClientLoadRequest()
    {}
949
950
    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)
951
    {
sletz's avatar
sletz committed
952
953
954
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
955
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
sletz's avatar
sletz committed
956
    }
957
958
959

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

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

979
};
980
981
982
983
984
985
986
987

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

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

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

sletz's avatar
sletz committed
997
    int Read(JackChannelTransaction* trans)
998
    {
sletz's avatar
sletz committed
999
1000
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
For faster browsing, not all history is shown. View entire blame