JackRequest.h 34.5 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
16
17
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
along with this program; if not, write to the Free Software 
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
74
        kSessionNotify = 33,
        kSessionReply  = 34,
        kGetClientByUUID = 35,
        kReserveClientName = 36,
        kGetUUIDByClient = 37
75
    };
sletz's avatar
sletz committed
76
77
78
79
80
81
82
83
84

    RequestType fType;

    JackRequest()
    {}

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

sletz's avatar
sletz committed
85
    virtual ~JackRequest()
sletz's avatar
sletz committed
86
87
    {}

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

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

};

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

struct JackResult
{

107
    int fResult;
sletz's avatar
sletz committed
108
109
110

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

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

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

128
129
130
131
132
133
134
135
/*!
\brief CheckClient request.
*/

struct JackClientCheckRequest : public JackRequest
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
136
    int fProtocol;
sletz's avatar
sletz committed
137
    int fOptions;
138
139
140

    JackClientCheckRequest()
    {}
141
142
    JackClientCheckRequest(const char* name, int protocol, int options)
        : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options)
143
144
145
146
147
148
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

    int Read(JackChannelTransaction* trans)
    {
149
        CheckRes(trans->Read(&fName, sizeof(fName)));
sletz's avatar
sletz committed
150
151
        CheckRes(trans->Read(&fProtocol, sizeof(int)));
        return trans->Read(&fOptions, sizeof(int));
152
153
154
155
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
156
        CheckRes(JackRequest::Write(trans));
157
        CheckRes(trans->Write(&fName,  sizeof(fName)));
sletz's avatar
sletz committed
158
159
        CheckRes(trans->Write(&fProtocol, sizeof(int)));
        return trans->Write(&fOptions, sizeof(int));
160
    }
sletz's avatar
sletz committed
161
    
162
};
163
164
165
166
167
168
169
170

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

sletz's avatar
sletz committed
171
172
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fStatus;
173

sletz's avatar
sletz committed
174
    JackClientCheckResult(): JackResult(), fStatus(0)
175
176
    {}
    JackClientCheckResult(int32_t result, const char* name, int status)
sletz's avatar
sletz committed
177
            : JackResult(result), fStatus(status)
178
    {
sletz's avatar
sletz committed
179
180
        snprintf(fName, sizeof(fName), "%s", name);
    }
181

sletz's avatar
sletz committed
182
    int Read(JackChannelTransaction* trans)
183
    {
sletz's avatar
sletz committed
184
        CheckRes(JackResult::Read(trans));
185
        CheckRes(trans->Read(&fName, sizeof(fName)));
sletz's avatar
sletz committed
186
187
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        return 0;
188
189
190
191
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
192
        CheckRes(JackResult::Write(trans));
193
        CheckRes(trans->Write(&fName, sizeof(fName)));
sletz's avatar
sletz committed
194
195
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        return 0;
196
    }
sletz's avatar
sletz committed
197
    
198
};
199

sletz's avatar
sletz committed
200
201
202
203
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
204
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
205
206
{

207
    int fPID;
208
    int fUUID;
sletz's avatar
sletz committed
209
    char fName[JACK_CLIENT_NAME_SIZE + 1];
210
 
sletz's avatar
sletz committed
211
    JackClientOpenRequest()
sletz's avatar
sletz committed
212
    {}
213
    JackClientOpenRequest(const char* name, int pid, int uuid): JackRequest(JackRequest::kClientOpen)
sletz's avatar
sletz committed
214
215
    {
        snprintf(fName, sizeof(fName), "%s", name);
216
        fPID = pid;
217
        fUUID = uuid;
sletz's avatar
sletz committed
218
219
220
221
    }

    int Read(JackChannelTransaction* trans)
    {
222
        CheckRes(trans->Read(&fPID, sizeof(int)));
223
        CheckRes(trans->Read(&fUUID, sizeof(int)));
224
        return trans->Read(&fName,  sizeof(fName));
sletz's avatar
sletz committed
225
226
227
228
    }

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

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
241
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
242
243
244
245
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
246
    int fSharedGraph;
247
   
sletz's avatar
sletz committed
248
    JackClientOpenResult()
249
            : JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1)
sletz's avatar
sletz committed
250
    {}
251
    JackClientOpenResult(int32_t result, int index1, int index2, int index3)
252
            : JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3)
sletz's avatar
sletz committed
253
254
    {}

sletz's avatar
sletz committed
255
    int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
256
    {
sletz's avatar
sletz committed
257
258
259
260
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fSharedEngine, sizeof(int)));
        CheckRes(trans->Read(&fSharedClient, sizeof(int)));
        CheckRes(trans->Read(&fSharedGraph, sizeof(int)));
261
        return 0;
sletz's avatar
sletz committed
262
263
264
265
    }

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

/*!
\brief CloseClient request.
*/

279
struct JackClientCloseRequest : public JackRequest
sletz's avatar
sletz committed
280
281
282
283
284
285
{

    int fRefNum;

    JackClientCloseRequest()
    {}
286
    JackClientCloseRequest(int refnum): JackRequest(JackRequest::kClientClose), fRefNum(refnum)
sletz's avatar
sletz committed
287
288
289
290
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
291
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
292
293
294
295
    }

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

/*!
\brief Activate request.
*/

306
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
307
308
309
{

    int fRefNum;
sletz's avatar
sletz committed
310
    int fIsRealTime;
sletz's avatar
sletz committed
311
312
313

    JackActivateRequest()
    {}
sletz's avatar
sletz committed
314
315
    JackActivateRequest(int refnum, int is_real_time)
        : JackRequest(JackRequest::kActivateClient), fRefNum(refnum), fIsRealTime(is_real_time)
sletz's avatar
sletz committed
316
317
318
319
    {}

    int Read(JackChannelTransaction* trans)
    {
320
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
321
        return trans->Read(&fIsRealTime, sizeof(int));
sletz's avatar
sletz committed
322
323
324
325
    }

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

331
};
sletz's avatar
sletz committed
332
333
334
335
336

/*!
\brief Deactivate request.
*/

337
struct JackDeactivateRequest : public JackRequest
sletz's avatar
sletz committed
338
339
340
341
342
343
{

    int fRefNum;

    JackDeactivateRequest()
    {}
344
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
345
346
347
348
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
349
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
350
351
352
353
    }

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

358
};
sletz's avatar
sletz committed
359
360
361
362
363

/*!
\brief PortRegister request.
*/

364
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
365
366
367
368
369
370
371
372
373
374
375
{

    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)
376
            : JackRequest(JackRequest::kRegisterPort), fRefNum(refnum), fFlags(flags), fBufferSize(buffer_size)
sletz's avatar
sletz committed
377
378
379
380
381
382
383
    {
        strcpy(fName, name);
        strcpy(fPortType, port_type);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
384
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
385
386
        CheckRes(trans->Read(&fName, sizeof(fName)));
        CheckRes(trans->Read(&fPortType, sizeof(fPortType)));
sletz's avatar
sletz committed
387
388
389
        CheckRes(trans->Read(&fFlags, sizeof(unsigned int)));
        CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int)));
        return 0;
sletz's avatar
sletz committed
390
391
392
393
    }

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

/*!
\brief PortRegister result.
*/

409
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
410
411
{

412
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
413

sletz's avatar
sletz committed
414
    JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
sletz's avatar
sletz committed
415
416
    {}

sletz's avatar
sletz committed
417
    int Read(JackChannelTransaction* trans)
sletz's avatar
Cleanup    
sletz committed
418
    {
sletz's avatar
sletz committed
419
420
        CheckRes(JackResult::Read(trans));
        return trans->Read(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
421
422
423
424
    }

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

/*!
\brief PortUnregister request.
*/

435
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
436
437
438
{

    int fRefNum;
439
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
440
441
442

    JackPortUnRegisterRequest()
    {}
443
    JackPortUnRegisterRequest(int refnum, jack_port_id_t index)
444
        : JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
445
446
447
448
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
449
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
450
        CheckRes(trans->Read(&fPortIndex, sizeof(jack_port_id_t)));
sletz's avatar
sletz committed
451
        return 0;
sletz's avatar
sletz committed
452
453
454
455
    }

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

/*!
\brief PortConnectName request.
*/

468
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
469
{
sletz's avatar
sletz committed
470

sletz's avatar
sletz committed
471
472
473
474
475
476
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortConnectNameRequest()
    {}
477
478
    JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
479
480
481
482
483
484
485
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
486
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
487
488
        CheckRes(trans->Read(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Read(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
489
        return 0;
490

sletz's avatar
sletz committed
491
492
493
494
    }

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

/*!
\brief PortDisconnectName request.
*/

508
struct JackPortDisconnectNameRequest : public JackRequest
sletz's avatar
sletz committed
509
510
511
512
513
514
515
516
{

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

    JackPortDisconnectNameRequest()
    {}
517
518
    JackPortDisconnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kDisconnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
519
520
521
522
523
524
525
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
526
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
527
528
        CheckRes(trans->Read(&fSrc, sizeof(fSrc)));
        CheckRes(trans->Read(&fDst, sizeof(fDst)));
sletz's avatar
sletz committed
529
        return 0;
sletz's avatar
sletz committed
530
531
532
533
    }

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

/*!
\brief PortConnect request.
*/

547
struct JackPortConnectRequest : public JackRequest
sletz's avatar
sletz committed
548
549
550
551
552
553
554
555
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
556
557
    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
558
559
560
561
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
562
563
564
565
        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
566
567
568
569
    }

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

/*!
\brief PortDisconnect request.
*/

583
struct JackPortDisconnectRequest : public JackRequest
sletz's avatar
sletz committed
584
585
586
587
588
589
590
591
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
592
593
    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
594
595
596
597
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
598
599
600
601
        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
602
603
604
605
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
606
607
608
609
610
        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
611
    }
sletz's avatar
sletz committed
612
    
613
};
sletz's avatar
sletz committed
614

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

    }
sletz's avatar
sletz committed
651
    
652
};
653

sletz's avatar
sletz committed
654
655
656
657
/*!
\brief SetBufferSize request.
*/

658
struct JackSetBufferSizeRequest : public JackRequest
sletz's avatar
sletz committed
659
660
661
662
663
664
{

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
665
666
    JackSetBufferSizeRequest(jack_nframes_t buffer_size)
        : JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
667
668
669
670
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
671
        return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
672
673
674
675
    }

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

/*!
\brief SetFreeWheel request.
*/

686
struct JackSetFreeWheelRequest : public JackRequest
sletz's avatar
sletz committed
687
688
689
690
691
692
{

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
693
694
    JackSetFreeWheelRequest(int onoff)
        : JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
695
696
697
698
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
699
        return trans->Read(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
700
701
702
703
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
704
705
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
706
    }
sletz's avatar
sletz committed
707
    
708
};
sletz's avatar
sletz committed
709
710
711
712
713

/*!
\brief ReleaseTimebase request.
*/

714
struct JackReleaseTimebaseRequest : public JackRequest
sletz's avatar
sletz committed
715
716
717
718
719
720
{

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
721
722
    JackReleaseTimebaseRequest(int refnum)
        : JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
723
724
725
726
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
727
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
728
729
730
731
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
732
733
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
734
    }
sletz's avatar
sletz committed
735
    
736
};
sletz's avatar
sletz committed
737
738
739
740
741

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
750
751
    JackSetTimebaseCallbackRequest(int refnum, int conditional)
        : JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
752
753
754
755
    {}

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

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

769
770
771
772
773
774
775
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
776
    int fRefNum;
777
778
779
780
781
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
782
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
783
784
785
786
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
793
794
795
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
796
    }
sletz's avatar
sletz committed
797
    
798
};
799
800
801
802
803

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
804
struct JackGetInternalClientNameResult : public JackResult
805
806
{

sletz's avatar
sletz committed
807
    char fName[JACK_CLIENT_NAME_SIZE + 1];
808

sletz's avatar
sletz committed
809
    JackGetInternalClientNameResult(): JackResult()
810
    {}
sletz's avatar
sletz committed
811
    JackGetInternalClientNameResult(int32_t result, const char* name)
sletz's avatar
sletz committed
812
            : JackResult(result)
813
    {
sletz's avatar
sletz committed
814
815
        snprintf(fName, sizeof(fName), "%s", name);
    }
816

sletz's avatar
sletz committed
817
    int Read(JackChannelTransaction* trans)
818
    {
sletz's avatar
sletz committed
819
        CheckRes(JackResult::Read(trans));
820
        CheckRes(trans->Read(&fName,  sizeof(fName)));
sletz's avatar
sletz committed
821
        return 0;
822
823
824
825
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
826
        CheckRes(JackResult::Write(trans));
827
        CheckRes(trans->Write(&fName,  sizeof(fName)));
sletz's avatar
sletz committed
828
        return 0;
829
    }
sletz's avatar
sletz committed
830
    
831
};
832
833
834
835
836
837
838
839

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
840
    int fRefNum;
841
842
843
844
845
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
sletz's avatar
sletz committed
846
            : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
847
    {
sletz's avatar
sletz committed
848
849
        snprintf(fName, sizeof(fName), "%s", client_name);
    }
850
851
852

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
853
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
854
        return trans->Read(&fName,  sizeof(fName));
855
856
857
858
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
859
860
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
861
        return trans->Write(&fName,  sizeof(fName));
862
    }
sletz's avatar
sletz committed
863
    
864
};
865
866
867
868
869
870
871
872

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
873
874
    int fStatus;
    int fIntRefNum;
875

sletz's avatar
sletz committed
876
    JackInternalClientHandleResult(): JackResult()
877
878
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
879
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
880
881
    {}

sletz's avatar
sletz committed
882
    int Read(JackChannelTransaction* trans)
883
    {
sletz's avatar
sletz committed
884
885
886
887
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
888
889
890
891
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
892
893
894
895
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
896
    }
sletz's avatar
sletz committed
897
    
898
};
899
900
901
902
903
904
905
906

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

907
#ifndef MAX_PATH
sletz's avatar
sletz committed
908
#define MAX_PATH 256
909
#endif
sletz's avatar
sletz committed
910
911

    int fRefNum;
912
    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
913
914
915
    char fDllName[MAX_PATH + 1];
    char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
    int fOptions;
916
    int fUUID;
917
918
919

    JackInternalClientLoadRequest()
    {}
920
921
    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)
922
    {
sletz's avatar
sletz committed
923
924
925
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
926
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
sletz's avatar
sletz committed
927
    }
928
929
930

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
931
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
932
933
934
        CheckRes(trans->Read(&fName,  sizeof(fName)));
        CheckRes(trans->Read(&fDllName, sizeof(fDllName)));
        CheckRes(trans->Read(&fLoadInitName, sizeof(fLoadInitName)));
935
        CheckRes(trans->Read(&fUUID, sizeof(int)));
sletz's avatar
sletz committed
936
        return trans->Read(&fOptions, sizeof(int));
937
938
939
940
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
941
942
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
943
944
945
        CheckRes(trans->Write(&fName,  sizeof(fName)));
        CheckRes(trans->Write(&fDllName, sizeof(fDllName)));
        CheckRes(trans->Write(&fLoadInitName, sizeof(fLoadInitName)));
946
        CheckRes(trans->Write(&fUUID, sizeof(int)));
sletz's avatar
sletz committed
947
        return trans->Write(&fOptions, sizeof(int));
948
    }
sletz's avatar
sletz committed
949
    
950
};
951
952
953
954
955
956
957
958

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
959
960
    int fStatus;
    int fIntRefNum;
961

sletz's avatar
sletz committed
962
    JackInternalClientLoadResult(): JackResult()
963
964
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
965
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
966
967
    {}

sletz's avatar
sletz committed
968
    int Read(JackChannelTransaction* trans)
969
    {
sletz's avatar
sletz committed
970
971
972
973
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
974
975
976
977
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
978
979
980
981
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
982
    }
sletz's avatar
sletz committed
983
    
984
};
985
986
987
988
989
990
991
992

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
993
    int fRefNum;
994
995
996
997
998
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
999
            : JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref)
1000
    {}
For faster browsing, not all history is shown. View entire blame