JackRequest.h 30.6 KB
Newer Older
sletz's avatar
sletz committed
1
/*
sletz's avatar
sletz committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
        kPortRename = 31,
68
69
70
71
72
        kNotification = 32,
	kSessionNotify = 33,
	kSessionReply  = 34,
	kGetClientByUUID = 35,
	kReserveClientName = 36
73
    };
sletz's avatar
sletz committed
74
75
76
77
78
79
80
81
82

    RequestType fType;

    JackRequest()
    {}

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

sletz's avatar
sletz committed
83
    virtual ~JackRequest()
sletz's avatar
sletz committed
84
85
    {}

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

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

};

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

struct JackResult
{

    int	fResult;

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

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

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

126
127
128
129
130
131
132
133
/*!
\brief CheckClient request.
*/

struct JackClientCheckRequest : public JackRequest
{

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

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

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
154
155
156
157
        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));
158
    }
sletz's avatar
sletz committed
159
160
    
} POST_PACKED_STRUCTURE;
161
162
163
164
165
166
167
168

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

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

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

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

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

sletz's avatar
sletz committed
198
199
200
201
/*!
\brief NewClient request.
*/

sletz's avatar
sletz committed
202
struct JackClientOpenRequest : public JackRequest
sletz's avatar
sletz committed
203
204
{

205
    int fPID;
sletz's avatar
sletz committed
206
207
    char fName[JACK_CLIENT_NAME_SIZE + 1];

sletz's avatar
sletz committed
208
    JackClientOpenRequest()
sletz's avatar
sletz committed
209
    {}
210
    JackClientOpenRequest(const char* name, int pid): JackRequest(JackRequest::kClientOpen)
sletz's avatar
sletz committed
211
212
    {
        snprintf(fName, sizeof(fName), "%s", name);
213
        fPID = pid;
sletz's avatar
sletz committed
214
215
216
217
    }

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

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
224
        CheckRes(JackRequest::Write(trans));
225
        CheckRes(trans->Write(&fPID, sizeof(int)));
sletz's avatar
sletz committed
226
        return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
sletz's avatar
sletz committed
227
    }
sletz's avatar
sletz committed
228
229
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
230
231
232
233
234

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
235
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
236
237
238
239
{

    int fSharedEngine;
    int fSharedClient;
sletz's avatar
sletz committed
240
    int fSharedGraph;
241
   
sletz's avatar
sletz committed
242
    JackClientOpenResult()
243
            : JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1)
sletz's avatar
sletz committed
244
    {}
245
    JackClientOpenResult(int32_t result, int index1, int index2, int index3)
246
            : JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3)
sletz's avatar
sletz committed
247
248
    {}

sletz's avatar
sletz committed
249
    int Read(JackChannelTransaction* trans)
sletz's avatar
sletz committed
250
    {
sletz's avatar
sletz committed
251
252
253
254
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fSharedEngine, sizeof(int)));
        CheckRes(trans->Read(&fSharedClient, sizeof(int)));
        CheckRes(trans->Read(&fSharedGraph, sizeof(int)));
255
        return 0;
sletz's avatar
sletz committed
256
257
258
259
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
260
261
262
263
264
        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
265
    }
sletz's avatar
sletz committed
266
267
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
268
269
270
271
272

/*!
\brief CloseClient request.
*/

273
struct JackClientCloseRequest : public JackRequest
sletz's avatar
sletz committed
274
275
276
277
278
279
{

    int fRefNum;

    JackClientCloseRequest()
    {}
280
    JackClientCloseRequest(int refnum): JackRequest(JackRequest::kClientClose), fRefNum(refnum)
sletz's avatar
sletz committed
281
282
283
284
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
285
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
286
287
288
289
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
290
291
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
292
    }
sletz's avatar
sletz committed
293
294
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
295
296
297
298
299

/*!
\brief Activate request.
*/

300
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
301
302
303
{

    int fRefNum;
sletz's avatar
sletz committed
304
    int fIsRealTime;
sletz's avatar
sletz committed
305
306
307

    JackActivateRequest()
    {}
sletz's avatar
sletz committed
308
309
    JackActivateRequest(int refnum, int is_real_time)
        : JackRequest(JackRequest::kActivateClient), fRefNum(refnum), fIsRealTime(is_real_time)
sletz's avatar
sletz committed
310
311
312
313
    {}

    int Read(JackChannelTransaction* trans)
    {
314
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
315
        return trans->Read(&fIsRealTime, sizeof(int));
sletz's avatar
sletz committed
316
317
318
319
    }

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

sletz's avatar
sletz committed
325
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
326
327
328
329
330

/*!
\brief Deactivate request.
*/

331
struct JackDeactivateRequest : public JackRequest
sletz's avatar
sletz committed
332
333
334
335
336
337
{

    int fRefNum;

    JackDeactivateRequest()
    {}
338
    JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
sletz's avatar
sletz committed
339
340
341
342
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
343
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
344
345
346
347
    }

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

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

/*!
\brief PortRegister request.
*/

358
struct JackPortRegisterRequest : public JackRequest
sletz's avatar
sletz committed
359
360
361
362
363
364
365
366
367
368
369
{

    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)
370
            : JackRequest(JackRequest::kRegisterPort), fRefNum(refnum), fFlags(flags), fBufferSize(buffer_size)
sletz's avatar
sletz committed
371
372
373
374
375
376
377
    {
        strcpy(fName, name);
        strcpy(fPortType, port_type);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
378
379
380
381
382
383
        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
384
385
386
387
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
388
389
390
391
392
393
394
        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
395
    }
sletz's avatar
sletz committed
396
397
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
398
399
400
401
402

/*!
\brief PortRegister result.
*/

403
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
404
405
{

406
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
407

sletz's avatar
sletz committed
408
    JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
sletz's avatar
sletz committed
409
410
    {}

sletz's avatar
sletz committed
411
    int Read(JackChannelTransaction* trans)
sletz's avatar
Cleanup    
sletz committed
412
    {
sletz's avatar
sletz committed
413
414
        CheckRes(JackResult::Read(trans));
        return trans->Read(&fPortIndex, sizeof(jack_port_id_t));
sletz's avatar
sletz committed
415
416
417
418
    }

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

/*!
\brief PortUnregister request.
*/

429
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
430
431
432
{

    int fRefNum;
433
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
434
435
436

    JackPortUnRegisterRequest()
    {}
437
    JackPortUnRegisterRequest(int refnum, jack_port_id_t index)
438
        : JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
sletz's avatar
sletz committed
439
440
441
442
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
443
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
444
        CheckRes(trans->Read(&fPortIndex, sizeof(jack_port_id_t)));
sletz's avatar
sletz committed
445
        return 0;
sletz's avatar
sletz committed
446
447
448
449
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
450
451
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
sletz's avatar
sletz committed
452
        CheckRes(trans->Write(&fPortIndex, sizeof(jack_port_id_t)));
sletz's avatar
sletz committed
453
        return 0;
sletz's avatar
sletz committed
454
    }
sletz's avatar
sletz committed
455
456
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
457
458
459
460
461

/*!
\brief PortConnectName request.
*/

462
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
463
{
sletz's avatar
sletz committed
464

sletz's avatar
sletz committed
465
466
467
468
469
470
    int fRefNum;
    char fSrc[JACK_PORT_NAME_SIZE + 1];
    char fDst[JACK_PORT_NAME_SIZE + 1];

    JackPortConnectNameRequest()
    {}
471
472
    JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
473
474
475
476
477
478
479
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
480
481
482
483
        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;
484

sletz's avatar
sletz committed
485
486
487
488
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
489
490
491
492
493
        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
494
    }
sletz's avatar
sletz committed
495
496
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
497
498
499
500
501

/*!
\brief PortDisconnectName request.
*/

502
struct JackPortDisconnectNameRequest : public JackRequest
sletz's avatar
sletz committed
503
504
505
506
507
508
509
510
{

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

    JackPortDisconnectNameRequest()
    {}
511
512
    JackPortDisconnectNameRequest(int refnum, const char* src_name, const char* dst_name)
        : JackRequest(JackRequest::kDisconnectNamePorts), fRefNum(refnum)
sletz's avatar
sletz committed
513
514
515
516
517
518
519
    {
        strcpy(fSrc, src_name);
        strcpy(fDst, dst_name);
    }

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
520
521
522
523
        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
524
525
526
527
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
528
529
530
531
532
        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
533
    }
sletz's avatar
sletz committed
534
535
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
536
537
538
539
540

/*!
\brief PortConnect request.
*/

541
struct JackPortConnectRequest : public JackRequest
sletz's avatar
sletz committed
542
543
544
545
546
547
548
549
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortConnectRequest()
    {}
550
551
    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
552
553
554
555
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
556
557
558
559
        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
560
561
562
563
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
564
565
566
567
568
        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
569
    }
sletz's avatar
sletz committed
570
571
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
572
573
574
575
576

/*!
\brief PortDisconnect request.
*/

577
struct JackPortDisconnectRequest : public JackRequest
sletz's avatar
sletz committed
578
579
580
581
582
583
584
585
{

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

    JackPortDisconnectRequest()
    {}
586
587
    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
588
589
590
591
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
592
593
594
595
        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
596
597
598
599
    }

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

sletz's avatar
sletz committed
606
    }
sletz's avatar
sletz committed
607
608
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
609

610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
/*!
\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
646
647
    
} POST_PACKED_STRUCTURE;
648

sletz's avatar
sletz committed
649
650
651
652
/*!
\brief SetBufferSize request.
*/

653
struct JackSetBufferSizeRequest : public JackRequest
sletz's avatar
sletz committed
654
655
656
657
658
659
{

    jack_nframes_t fBufferSize;

    JackSetBufferSizeRequest()
    {}
660
661
    JackSetBufferSizeRequest(jack_nframes_t buffer_size)
        : JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
sletz's avatar
sletz committed
662
663
664
665
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
666
        return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
667
668
669
670
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
671
672
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fBufferSize, sizeof(jack_nframes_t));
sletz's avatar
sletz committed
673
    }
sletz's avatar
sletz committed
674
675
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
676
677
678
679
680

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

    JackSetFreeWheelRequest()
    {}
688
689
    JackSetFreeWheelRequest(int onoff)
        : JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
sletz's avatar
sletz committed
690
691
692
693
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
694
        return trans->Read(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
695
696
697
698
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
699
700
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fOnOff, sizeof(int));
sletz's avatar
sletz committed
701
    }
sletz's avatar
sletz committed
702
703
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
704
705
706
707
708

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

    JackReleaseTimebaseRequest()
    {}
716
717
    JackReleaseTimebaseRequest(int refnum)
        : JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
sletz's avatar
sletz committed
718
719
720
721
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
722
        return trans->Read(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
723
724
725
726
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
727
728
        CheckRes(JackRequest::Write(trans));
        return trans->Write(&fRefNum, sizeof(int));
sletz's avatar
sletz committed
729
    }
sletz's avatar
sletz committed
730
731
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
732
733
734
735
736

/*!
\brief SetTimebaseCallback request.
*/

737
struct JackSetTimebaseCallbackRequest : public JackRequest
sletz's avatar
sletz committed
738
739
740
741
742
743
744
{

    int fRefNum;
    int fConditionnal;

    JackSetTimebaseCallbackRequest()
    {}
745
746
    JackSetTimebaseCallbackRequest(int refnum, int conditional)
        : JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
sletz's avatar
sletz committed
747
748
749
750
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
751
752
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fConditionnal, sizeof(int));
sletz's avatar
sletz committed
753
754
755
756
    }

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

764
765
766
767
768
769
770
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
771
    int fRefNum;
772
773
774
775
776
    int fIntRefNum;

    JackGetInternalClientNameRequest()
    {}
    JackGetInternalClientNameRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
777
            : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
778
779
780
781
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
782
783
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
784
785
786
787
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
788
789
790
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fIntRefNum, sizeof(int));
791
    }
sletz's avatar
sletz committed
792
793
    
} POST_PACKED_STRUCTURE;
794
795
796
797
798

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
799
struct JackGetInternalClientNameResult : public JackResult
800
801
{

sletz's avatar
sletz committed
802
    char fName[JACK_CLIENT_NAME_SIZE + 1];
803

sletz's avatar
sletz committed
804
    JackGetInternalClientNameResult(): JackResult()
805
    {}
sletz's avatar
sletz committed
806
    JackGetInternalClientNameResult(int32_t result, const char* name)
sletz's avatar
sletz committed
807
            : JackResult(result)
808
    {
sletz's avatar
sletz committed
809
810
        snprintf(fName, sizeof(fName), "%s", name);
    }
811

sletz's avatar
sletz committed
812
    int Read(JackChannelTransaction* trans)
813
    {
sletz's avatar
sletz committed
814
815
816
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
817
818
819
820
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
821
822
823
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1));
        return 0;
824
    }
sletz's avatar
sletz committed
825
826
    
} POST_PACKED_STRUCTURE;
827
828
829
830
831
832
833
834

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

sletz's avatar
sletz committed
835
    int fRefNum;
836
837
838
839
840
    char fName[JACK_CLIENT_NAME_SIZE + 1];

    JackInternalClientHandleRequest()
    {}
    JackInternalClientHandleRequest(int refnum, const char* client_name)
sletz's avatar
sletz committed
841
            : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
842
    {
sletz's avatar
sletz committed
843
844
        snprintf(fName, sizeof(fName), "%s", client_name);
    }
845
846
847

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
848
849
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fName, JACK_CLIENT_NAME_SIZE + 1);
850
851
852
853
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
854
855
856
        CheckRes(JackRequest::Write(trans));
        CheckRes(trans->Write(&fRefNum, sizeof(int)));
        return trans->Write(&fName, JACK_CLIENT_NAME_SIZE + 1);
857
    }
sletz's avatar
sletz committed
858
859
    
} POST_PACKED_STRUCTURE;
860
861
862
863
864
865
866
867

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
868
869
    int fStatus;
    int fIntRefNum;
870

sletz's avatar
sletz committed
871
    JackInternalClientHandleResult(): JackResult()
872
873
    {}
    JackInternalClientHandleResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
874
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
875
876
    {}

sletz's avatar
sletz committed
877
    int Read(JackChannelTransaction* trans)
878
    {
sletz's avatar
sletz committed
879
880
881
882
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
883
884
885
886
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
887
888
889
890
        CheckRes(JackResult::Write(trans));
        CheckRes(trans->Write(&fStatus, sizeof(int)));
        CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
        return 0;
891
    }
sletz's avatar
sletz committed
892
893
    
} POST_PACKED_STRUCTURE;
894
895
896
897
898
899
900
901

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

902
#ifndef MAX_PATH
sletz's avatar
sletz committed
903
#define MAX_PATH 256
904
#endif
sletz's avatar
sletz committed
905
906

    int fRefNum;
907
    char fName[JACK_CLIENT_NAME_SIZE + 1];
sletz's avatar
sletz committed
908
909
910
    char fDllName[MAX_PATH + 1];
    char fLoadInitName[JACK_LOAD_INIT_LIMIT + 1];
    int fOptions;
911
912
913
914

    JackInternalClientLoadRequest()
    {}
    JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options)
sletz's avatar
sletz committed
915
            : JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options)
916
    {
sletz's avatar
sletz committed
917
918
919
920
        snprintf(fName, sizeof(fName), "%s", client_name);
        snprintf(fDllName, sizeof(fDllName), "%s", so_name);
        snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
    }
921
922
923

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
924
925
926
927
928
        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));
929
930
931
932
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
933
934
935
936
937
938
        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));
939
    }
sletz's avatar
sletz committed
940
941
    
} POST_PACKED_STRUCTURE;
942
943
944
945
946
947
948
949

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
950
951
    int fStatus;
    int fIntRefNum;
952

sletz's avatar
sletz committed
953
    JackInternalClientLoadResult(): JackResult()
954
955
    {}
    JackInternalClientLoadResult(int32_t result, int status, int int_ref)
sletz's avatar
sletz committed
956
            : JackResult(result), fStatus(status), fIntRefNum(int_ref)
957
958
    {}

sletz's avatar
sletz committed
959
    int Read(JackChannelTransaction* trans)
960
    {
sletz's avatar
sletz committed
961
962
963
964
        CheckRes(JackResult::Read(trans));
        CheckRes(trans->Read(&fStatus, sizeof(int)));
        CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
        return 0;
965
966
967
968
    }

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

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
984
    int fRefNum;
985
986
987
988
989
    int fIntRefNum;

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
sletz's avatar
sletz committed
990
            : JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref)
991
992
993
994
    {}

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
995
996
        CheckRes(trans->Read(&fRefNum, sizeof(int)));
        return trans->Read(&fIntRefNum, sizeof(int));
997
998
999
1000
    }

    int Write(JackChannelTransaction* trans)
    {
For faster browsing, not all history is shown. View entire blame