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

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

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

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

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

#ifndef __JackRequest__
#define __JackRequest__

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

namespace Jack
{

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

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

struct JackRequest
{

43
    enum RequestType {
sletz's avatar
sletz committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        kRegisterPort = 1,
        kUnRegisterPort = 2,
        kConnectPorts = 3,
        kDisconnectPorts = 4,
        kSetTimeBaseClient = 5,
        kActivateClient = 6,
        kDeactivateClient = 7,
        kDisconnectPort = 8,
        kSetClientCapabilities = 9,
        kGetPortConnections = 10,
        kGetPortNConnections = 11,
        kReleaseTimebase = 12,
        kSetTimebaseCallback = 13,
        kSetBufferSize = 20,
        kSetFreeWheel = 21,
sletz's avatar
sletz committed
59
        kClientCheck = 22,
60
61
62
63
        kClientOpen = 23,
        kClientClose = 24,
        kConnectNamePorts = 25,
        kDisconnectNamePorts = 26,
sletz's avatar
sletz committed
64
65
66
67
        kGetInternalClientName = 27,
        kInternalClientHandle = 28,
        kInternalClientLoad = 29,
        kInternalClientUnload = 30,
68
        kPortRename = 31,
69
70
71
72
        kNotification = 32,
	kSessionNotify = 33,
	kSessionReply  = 34,
	kGetClientByUUID = 35,
73
74
	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
107
108
109
110
    }

};

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

struct JackResult
{

    int	fResult;

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

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

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

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

struct JackClientCheckRequest : public JackRequest
{

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

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

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

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

/*!
\brief CheckClient result.
*/

struct JackClientCheckResult : public JackResult
{

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

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

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

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

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

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

207
    int fPID;
208
    int fUUID;
sletz's avatar
sletz committed
209
    char fName[JACK_CLIENT_NAME_SIZE + 1];
210
 
sletz's avatar
sletz committed
211

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

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

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

/*!
\brief NewClient result.
*/

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

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

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

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

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

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

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

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

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

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

/*!
\brief PortRegister request.
*/

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

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

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
385
386
387
388
389
390
        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
391
392
393
394
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
395
396
397
398
399
400
401
        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
402
    }
sletz's avatar
sletz committed
403
404
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
405
406
407
408
409

/*!
\brief PortRegister result.
*/

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

413
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
414

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

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

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

/*!
\brief PortUnregister request.
*/

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

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

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

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

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

/*!
\brief PortConnectName request.
*/

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

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

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

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
487
488
489
490
        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;
491

sletz's avatar
sletz committed
492
493
494
495
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
496
497
498
499
500
        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
501
    }
sletz's avatar
sletz committed
502
503
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
504
505
506
507
508

/*!
\brief PortDisconnectName request.
*/

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

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

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

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
527
528
529
530
        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
531
532
533
534
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
535
536
537
538
539
        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
540
    }
sletz's avatar
sletz committed
541
542
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
543
544
545
546
547

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

sletz's avatar
sletz committed
613
    }
sletz's avatar
sletz committed
614
615
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
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
646
647
648
649
650
651
652
/*!
\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
653
654
    
} POST_PACKED_STRUCTURE;
655

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

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

    jack_nframes_t fBufferSize;

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

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

struct JackGetInternalClientNameRequest : public JackRequest
{

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

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

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

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

/*!
\brief GetInternalClient result.
*/

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

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

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

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

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

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

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

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

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

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

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

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

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

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

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

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

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

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

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

    int Read(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
933
934
935
936
        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));
937
        CheckRes(trans->Read(&fUUID, sizeof(int)));
sletz's avatar
sletz committed
938
        return trans->Read(&fOptions, sizeof(int));
939
940
941
942
    }

    int Write(JackChannelTransaction* trans)
    {
sletz's avatar
sletz committed
943
944
945
946
947
        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));
948
        CheckRes(trans->Write(&fUUID, sizeof(int)));
sletz's avatar
sletz committed
949
        return trans->Write(&fOptions, sizeof(int));
950
    }
sletz's avatar
sletz committed
951
952
    
} POST_PACKED_STRUCTURE;
953
954
955
956
957
958
959
960

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

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

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

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

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

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

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

    JackInternalClientUnloadRequest()
    {}
    JackInternalClientUnloadRequest(int refnum, int int_ref)
For faster browsing, not all history is shown. View entire blame