JackRequest.h 34.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>
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
    int fUUID;
139
140
141

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

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

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

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

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

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

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

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

sletz's avatar
sletz committed
203
204
205
206
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
207
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
208
209
{

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

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

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

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
244
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
245
246
247
248
{

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

309
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
310
311
312
{

    int fRefNum;
sletz's avatar
sletz committed
313
    int fIsRealTime;
sletz's avatar
sletz committed
314
315
316

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

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

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

334
};
sletz's avatar
sletz committed
335
336
337
338
339

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

361
};
sletz's avatar
sletz committed
362
363
364
365
366

/*!
\brief PortRegister request.
*/

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

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

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

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

/*!
\brief PortRegister result.
*/

412
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
413
414
{

415
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
416

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

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

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

/*!
\brief PortUnregister request.
*/

438
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
439
440
441
{

    int fRefNum;
442
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
443
444
445

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

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

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

/*!
\brief PortConnectName request.
*/

471
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
472
{
sletz's avatar
sletz committed
473

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

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

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

sletz's avatar
sletz committed
494
495
496
497
    }

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

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

    }
sletz's avatar
sletz committed
654
    
655
};
656

sletz's avatar
sletz committed
657
658
659
660
/*!
\brief SetBufferSize request.
*/

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

    jack_nframes_t fBufferSize;

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
724
725
    JackReleaseTimebaseRequest(int refnum)
        : JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
726
727
728
729
    {}

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

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

/*!
\brief SetTimebaseCallback request.
*/

745
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
746
747
748
749
750
751
752
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
753
754
    JackSetTimebaseCallbackRequest(int refnum, int conditional)
        : JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
755
756
757
758
    {}

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

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

772
773
774
775
776
777
778
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
779
    int fRefNum;
780
781
782
783
784
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
785
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
786
787
788
789
    {}

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

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

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
807
struct JackGetInternalClientNameResult : public JackResult
808
809
{

sletz's avatar
sletz committed
810
    char fName[JACK_CLIENT_NAME_SIZE + 1];
811

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

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

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

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
843
    int fRefNum;
844
845
846
847
848
    char fName[JACK_CLIENT_NAME_SIZE + 1];

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

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

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

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
876
877
    int fStatus;
    int fIntRefNum;
878

sletz's avatar
sletz committed
879
    JackInternalClientHandleResult(): JackResult()
880
881
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
882
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
883
884
    {}

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

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

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

910
#ifndef MAX_PATH
sletz's avatar
sletz committed
911
#define MAX_PATH 256
912
#endif
sletz's avatar
sletz committed
913
914

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

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

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

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

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
962
963
    int fStatus;
    int fIntRefNum;
964

sletz's avatar
sletz committed
965
    JackInternalClientLoadResult(): JackResult()
966
967
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
968
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
969
970
    {}

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

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

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
996
    int fRefNum;
997
998
999
1000
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}