JackRequest.h 26.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
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>
sletz's avatar
sletz committed
29
30
31
32

namespace Jack
{

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

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

struct JackRequest
{

42
    enum RequestType {
sletz's avatar
sletz committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
        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
58
        kClientCheck = 22,
59
60
61
62
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
sletz's avatar
sletz committed
63
64
65
66
        kGetInternalClientName = 27,
        kInternalClientHandle = 28,
        kInternalClientLoad = 29,
        kInternalClientUnload = 30,
67
68
        kPortRename = 31,
        kNotification = 32
69
    };
sletz's avatar
sletz committed
70
71
72
73
74
75
76
77
78

    RequestType fType;

    JackRequest()
    {}

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

sletz's avatar
sletz committed
79
    virtual ~JackRequest()
sletz's avatar
sletz committed
80
81
    {}

sletz's avatar
sletz committed
82
    virtual int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
83
    {
sletz's avatar
sletz committed
84
        return trans->Read(&fType, sizeof(RequestType));
sletz's avatar
sletz committed
85
86
    }

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

};

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

struct JackResult
{

    int	fResult;

    JackResult(): fResult( -1)
    {}
105
    JackResult(int result): fResult(result)
sletz's avatar
sletz committed
106
107
108
109
110
111
    {}
    virtual ~JackResult()
    {}

    virtual int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
112
        return trans->Read(&fResult, sizeof(int));
sletz's avatar
sletz committed
113
114
115
116
    }

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

121
122
123
124
125
126
127
128
/*!
\brief CheckClient request.
*/

struct JackClientCheckRequest : public JackRequest
{

    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
129
    int fProtocol;
sletz's avatar
sletz committed
130
    int fOptions;
131
132
133

    JackClientCheckRequest()
    {}
134
135
    JackClientCheckRequest(const char* name, int protocol, int options)
        : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options)
136
137
138
139
140
141
    {
        snprintf(fName, sizeof(fName), "%s", name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
142
143
144
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fProtocol, sizeof(int)));
        return trans->Read(&fOptions, sizeof(int));
145
146
147
148
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
149
150
151
152
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fProtocol, sizeof(int)));
        return trans->Write(&fOptions, sizeof(int));
153
154
155
156
157
158
159
160
161
162
    }
};

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

sletz's avatar
sletz committed
163
164
    char fName[JACK_CLIENT_NAME_SIZE + 1];
    int fStatus;
165

sletz's avatar
sletz committed
166
    JackClientCheckResult(): JackResult(), fStatus(0)
167
168
    {}
    JackClientCheckResult(int32_t result, const char* name, int status)
sletz's avatar
sletz committed
169
            : JackResult(result), fStatus(status)
170
    {
sletz's avatar
sletz committed
171
172
        snprintf(fName, sizeof(fName), "%s", name);
    }
173

sletz's avatar
sletz committed
174
    int Read(JackChannelTransaction* trans)
175
    {
sletz's avatar
sletz committed
176
177
178
179
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        return 0;
180
181
182
183
    }

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

sletz's avatar
sletz committed
191
192
193
194
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
195
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
196
197
{

198
    int fPID;
sletz's avatar
sletz committed
199
200
    char fName[JACK_CLIENT_NAME_SIZE + 1];

sletz's avatar
sletz committed
201
    JackClientOpenRequest()
sletz's avatar
sletz committed
202
    {}
203
    JackClientOpenRequest(const char* name, int pid): JackRequest(JackRequest::kClientOpen)
sletz's avatar
sletz committed
204
205
    {
        snprintf(fName, sizeof(fName), "%s", name);
206
        fPID = pid;
sletz's avatar
sletz committed
207
208
209
210
    }

    int Read(JackChannelTransaction* trans)
    {
211
        CheckRes(trans->Read(&fPID, sizeof(int)));
sletz's avatar
sletz committed
212
        return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
sletz's avatar
sletz committed
213
214
215
216
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
217
        CheckRes(JackRequest::Write(trans));
218
        CheckRes(trans->Write(&fPID, sizeof(int)));
sletz's avatar
sletz committed
219
        return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
sletz's avatar
sletz committed
220
221
222
223
224
225
226
    }
};

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
227
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
228
229
230
231
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
232
    int fSharedGraph;
233
   
sletz's avatar
sletz committed
234
    JackClientOpenResult()
235
            : JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1)
sletz's avatar
sletz committed
236
    {}
237
    JackClientOpenResult(int32_t result, int index1, int index2, int index3)
238
            : JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3)
sletz's avatar
sletz committed
239
240
    {}

sletz's avatar
sletz committed
241
    int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
242
    {
sletz's avatar
sletz committed
243
244
245
246
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fSharedEngine, sizeof(int)));
        CheckRes(trans->Read(&fSharedClient, sizeof(int)));
        CheckRes(trans->Read(&fSharedGraph, sizeof(int)));
247
         return 0;
sletz's avatar
sletz committed
248
249
250
251
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
252
253
254
255
256
        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
257
258
259
260
261
262
263
    }
};

/*!
\brief CloseClient request.
*/

264
struct JackClientCloseRequest : public JackRequest
sletz's avatar
sletz committed
265
266
267
268
269
270
{

    int fRefNum;

    JackClientCloseRequest()
    {}
271
    JackClientCloseRequest(int refnum): JackRequest(JackRequest::kClientClose), fRefNum(refnum)
sletz's avatar
sletz committed
272
273
274
275
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
276
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
277
278
279
280
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
281
282
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
283
284
285
286
287
288
289
    }
};

/*!
\brief Activate request.
*/

290
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
291
292
293
{

    int fRefNum;
294
    int fState;
sletz's avatar
sletz committed
295
296
297

    JackActivateRequest()
    {}
298
299
    JackActivateRequest(int refnum, int state)
        : JackRequest(JackRequest::kActivateClient), fRefNum(refnum), fState(state)
sletz's avatar
sletz committed
300
301
302
303
    {}

    int Read(JackChannelTransaction* trans)
    {
304
305
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fState, sizeof(int));
sletz's avatar
sletz committed
306
307
308
309
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
310
        CheckRes(JackRequest::Write(trans));
311
312
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fState, sizeof(int));
sletz's avatar
sletz committed
313
314
315
316
317
318
319
320
    }

};

/*!
\brief Deactivate request.
*/

321
struct JackDeactivateRequest : public JackRequest
sletz's avatar
sletz committed
322
323
324
325
326
327
{

    int fRefNum;

    JackDeactivateRequest()
    {}
328
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
329
330
331
332
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
333
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
334
335
336
337
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
338
339
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
340
341
342
343
344
345
346
347
    }

};

/*!
\brief PortRegister request.
*/

348
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
349
350
351
352
353
354
355
356
357
358
359
{

    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)
360
            : JackRequest(JackRequest::kRegisterPort), fRefNum(refnum), fFlags(flags), fBufferSize(buffer_size)
sletz's avatar
sletz committed
361
362
363
364
365
366
367
    {
        strcpy(fName, name);
        strcpy(fPortType, port_type);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
368
369
370
371
372
373
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fName, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fPortType, JACK_PORT_TYPE_SIZE + 1));
        CheckRes(trans->Read(&fFlags, sizeof(unsigned int)));
        CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int)));
        return 0;
sletz's avatar
sletz committed
374
375
376
377
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
378
379
380
381
382
383
384
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fName, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fPortType, JACK_PORT_TYPE_SIZE + 1));
        CheckRes(trans->Write(&fFlags, sizeof(unsigned int)));
        CheckRes(trans->Write(&fBufferSize, sizeof(unsigned int)));
        return 0;
sletz's avatar
sletz committed
385
386
387
388
389
390
391
    }
};

/*!
\brief PortRegister result.
*/

392
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
393
394
{

sletz's avatar
sletz committed
395
    unsigned int fPortIndex;
sletz's avatar
sletz committed
396

sletz's avatar
sletz committed
397
    JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
sletz's avatar
sletz committed
398
399
    {}

sletz's avatar
sletz committed
400
    int Read(JackChannelTransaction* trans)
sletz's avatar
Cleanup    
sletz committed
401
    {
sletz's avatar
sletz committed
402
403
        CheckRes(JackResult::Read(trans));
        return trans->Read(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
404
405
406
407
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
408
409
        CheckRes(JackResult::Write(trans));
        return trans->Write(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
410
411
412
413
414
415
416
    }
};

/*!
\brief PortUnregister request.
*/

417
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
418
419
420
421
422
423
424
{

    int fRefNum;
    int fPortIndex;

    JackPortUnRegisterRequest()
    {}
425
426
    JackPortUnRegisterRequest(int refnum, int index)
        : JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
427
428
429
430
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
431
432
433
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fPortIndex, sizeof(int)));
        return 0;
sletz's avatar
sletz committed
434
435
436
437
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
438
439
440
441
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fPortIndex, sizeof(int)));
        return 0;
sletz's avatar
sletz committed
442
443
444
445
446
447
448
    }
};

/*!
\brief PortConnectName request.
*/

449
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
450
{
sletz's avatar
sletz committed
451

sletz's avatar
sletz committed
452
453
454
455
456
457
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortConnectNameRequest()
    {}
458
459
    JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
460
461
462
463
464
465
466
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
467
468
469
470
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fSrc, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fDst, JACK_PORT_NAME_SIZE + 1));
        return 0;
471

sletz's avatar
sletz committed
472
473
474
475
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
476
477
478
479
480
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fSrc, JACK_PORT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fDst, JACK_PORT_NAME_SIZE + 1));
        return 0;
sletz's avatar
sletz committed
481
482
483
484
485
486
487
    }
};

/*!
\brief PortDisconnectName request.
*/

488
struct JackPortDisconnectNameRequest : public JackRequest
sletz's avatar
sletz committed
489
490
491
492
493
494
495
496
{

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

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

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

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

/*!
\brief PortConnect request.
*/

526
struct JackPortConnectRequest : public JackRequest
sletz's avatar
sletz committed
527
528
529
530
531
532
533
534
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
535
536
    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
537
538
539
540
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
541
542
543
544
        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
545
546
547
548
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
549
550
551
552
553
        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
554
555
556
557
558
559
560
561
    }
};


/*!
\brief PortDisconnect request.
*/

562
struct JackPortDisconnectRequest : public JackRequest
sletz's avatar
sletz committed
563
564
565
566
567
568
569
570
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
571
572
    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
573
574
575
576
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
577
578
579
580
        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
581
582
583
584
    }

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

sletz's avatar
sletz committed
591
592
593
    }
};

594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
/*!
\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)));
        CheckRes(trans->Read(&fName, JACK_PORT_NAME_SIZE + 1));
        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)));
        CheckRes(trans->Write(&fName, JACK_PORT_NAME_SIZE + 1));
        return 0;

    }
};

sletz's avatar
sletz committed
632
633
634
635
/*!
\brief SetBufferSize request.
*/

636
struct JackSetBufferSizeRequest : public JackRequest
sletz's avatar
sletz committed
637
638
639
640
641
642
{

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
643
644
    JackSetBufferSizeRequest(jack_nframes_t buffer_size)
        : JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
645
646
647
648
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
649
        return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
650
651
652
653
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
654
655
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
656
657
658
659
660
661
662
    }
};

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
670
671
    JackSetFreeWheelRequest(int onoff)
        : JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
672
673
674
675
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
676
        return trans->Read(&fOnOff, sizeof(int));
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(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
683
684
685
686
687
688
689
    }
};

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
697
698
    JackReleaseTimebaseRequest(int refnum)
        : JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
699
700
701
702
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
708
709
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
710
711
712
713
714
715
716
    }
};

/*!
\brief SetTimebaseCallback request.
*/

717
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
718
719
720
721
722
723
724
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
725
726
    JackSetTimebaseCallbackRequest(int refnum, int conditional)
        : JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
727
728
729
730
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
731
732
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
733
734
735
736
    }

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

743
744
745
746
747
748
749
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
750
    int fRefNum;
751
752
753
754
755
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
756
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
757
758
759
760
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
761
762
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
763
764
765
766
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
767
768
769
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
770
771
772
773
774
775
776
    }
};

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
777
struct JackGetInternalClientNameResult : public JackResult
778
779
{

sletz's avatar
sletz committed
780
    char fName[JACK_CLIENT_NAME_SIZE + 1];
781

sletz's avatar
sletz committed
782
    JackGetInternalClientNameResult(): JackResult()
783
    {}
sletz's avatar
sletz committed
784
    JackGetInternalClientNameResult(int32_t result, const char* name)
sletz's avatar
sletz committed
785
            : JackResult(result)
786
    {
sletz's avatar
sletz committed
787
788
        snprintf(fName, sizeof(fName), "%s", name);
    }
789

sletz's avatar
sletz committed
790
    int Read(JackChannelTransaction* trans)
791
    {
sletz's avatar
sletz committed
792
793
794
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
795
796
797
798
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
799
800
801
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
802
803
804
805
806
807
808
809
810
811
    }
};

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
812
    int fRefNum;
813
814
815
816
817
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
sletz's avatar
sletz committed
818
            : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
819
    {
sletz's avatar
sletz committed
820
821
        snprintf(fName, sizeof(fName), "%s", client_name);
    }
822
823
824

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
825
826
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
827
828
829
830
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
831
832
833
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
834
835
836
837
838
839
840
841
842
843
    }
};

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
844
845
    int fStatus;
    int fIntRefNum;
846

sletz's avatar
sletz committed
847
    JackInternalClientHandleResult(): JackResult()
848
849
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
850
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
851
852
    {}

sletz's avatar
sletz committed
853
    int Read(JackChannelTransaction* trans)
854
    {
sletz's avatar
sletz committed
855
856
857
858
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
859
860
861
862
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
863
864
865
866
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
867
868
869
870
871
872
873
874
875
876
    }
};

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

877
#ifndef MAX_PATH
sletz's avatar
sletz committed
878
#define MAX_PATH 256
879
#endif
sletz's avatar
sletz committed
880
881

    int fRefNum;
882
    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
883
884
885
    char fDllName[MAX_PATH + 1];
    char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
    int fOptions;
886
887
888
889

    JackInternalClientLoadRequest()
    {}
    JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options)
sletz's avatar
sletz committed
890
            : JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options)
891
    {
sletz's avatar
sletz committed
892
893
894
895
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
    }
896
897
898

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
899
900
901
902
903
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Read(&fDllName, MAX_PATH + 1));
        CheckRes(trans->Read(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1));
        return trans->Read(&fOptions, sizeof(int));
904
905
906
907
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
908
909
910
911
912
913
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        CheckRes(trans->Write(&fDllName, MAX_PATH + 1));
        CheckRes(trans->Write(&fLoadInitName, JACK_LOAD_INIT_LIMIT + 1));
        return trans->Write(&fOptions, sizeof(int));
914
915
916
917
918
919
920
921
922
923
    }
};

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
924
925
    int fStatus;
    int fIntRefNum;
926

sletz's avatar
sletz committed
927
    JackInternalClientLoadResult(): JackResult()
928
929
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
930
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
931
932
    {}

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
943
944
945
946
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
947
948
949
950
951
952
953
954
955
956
    }
};

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
957
    int fRefNum;
958
959
960
961
962
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
963
            : JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref)
964
965
966
967
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
968
969
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
970
971
972
973
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
974
975
976
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
977
978
979
980
981
982
983
984
985
986
987
    }
};


/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientUnloadResult : public JackResult
{

sletz's avatar
sletz committed
988
    int fStatus;
989

sletz's avatar
sletz committed
990
    JackInternalClientUnloadResult(): JackResult()
991
992
    {}
    JackInternalClientUnloadResult(int32_t result, int status)
sletz's avatar
sletz committed
993
            : JackResult(result), fStatus(status)
994
995
    {}

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