JackRequest.h 35.1 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;
sletz's avatar
sletz committed
208
209
    char fName[JACK_CLIENT_NAME_SIZE + 1];

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

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

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

/*!
\brief NewClient result.
*/

sletz's avatar
sletz committed
237
struct JackClientOpenResult : public JackResult
sletz's avatar
sletz committed
238
239
240
241
{

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

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

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

/*!
\brief CloseClient request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief Activate request.
*/

302
struct JackActivateRequest : public JackRequest
sletz's avatar
sletz committed
303
304
305
{

    int fRefNum;
sletz's avatar
sletz committed
306
    int fIsRealTime;
sletz's avatar
sletz committed
307
308
309

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

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

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

sletz's avatar
sletz committed
327
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
328
329
330
331
332

/*!
\brief Deactivate request.
*/

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

    int fRefNum;

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

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

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

sletz's avatar
sletz committed
354
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
355
356
357
358
359

/*!
\brief PortRegister request.
*/

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

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

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

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

/*!
\brief PortRegister result.
*/

405
struct JackPortRegisterResult : public JackResult
sletz's avatar
sletz committed
406
407
{

408
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
409

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

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

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

/*!
\brief PortUnregister request.
*/

431
struct JackPortUnRegisterRequest : public JackRequest
sletz's avatar
sletz committed
432
433
434
{

    int fRefNum;
435
    jack_port_id_t fPortIndex;
sletz's avatar
sletz committed
436
437
438

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

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

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

/*!
\brief PortConnectName request.
*/

464
struct JackPortConnectNameRequest : public JackRequest
sletz's avatar
sletz committed
465
{
sletz's avatar
sletz committed
466

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

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

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

sletz's avatar
sletz committed
487
488
489
490
    }

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

/*!
\brief PortDisconnectName request.
*/

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

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

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

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

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

/*!
\brief PortConnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

/*!
\brief PortDisconnect request.
*/

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

    int fRefNum;
    jack_port_id_t fSrc;
    jack_port_id_t fDst;

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

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

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

sletz's avatar
sletz committed
608
    }
sletz's avatar
sletz committed
609
610
    
} POST_PACKED_STRUCTURE;
sletz's avatar
sletz committed
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
646
647
/*!
\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
648
649
    
} POST_PACKED_STRUCTURE;
650

sletz's avatar
sletz committed
651
652
653
654
/*!
\brief SetBufferSize request.
*/

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

    jack_nframes_t fBufferSize;

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

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

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

/*!
\brief SetFreeWheel request.
*/

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

    int fOnOff;

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

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

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

/*!
\brief ReleaseTimebase request.
*/

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

    int fRefNum;

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

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

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

/*!
\brief SetTimebaseCallback request.
*/

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

    int fRefNum;
    int fConditionnal;

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

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

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

766
767
768
769
770
771
772
/*!
\brief GetInternalClientName request.
*/

struct JackGetInternalClientNameRequest : public JackRequest
{

sletz's avatar
sletz committed
773
    int fRefNum;
774
775
776
777
778
    int fIntRefNum;

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

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

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

/*!
\brief GetInternalClient result.
*/

sletz's avatar
sletz committed
801
struct JackGetInternalClientNameResult : public JackResult
802
803
{

sletz's avatar
sletz committed
804
    char fName[JACK_CLIENT_NAME_SIZE + 1];
805

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

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

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

/*!
\brief InternalClientHandle request.
*/

struct JackInternalClientHandleRequest : public JackRequest
{

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

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

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

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

/*!
\brief InternalClientHandle result.
*/

struct JackInternalClientHandleResult : public JackResult
{

sletz's avatar
sletz committed
870
871
    int fStatus;
    int fIntRefNum;
872

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

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

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

/*!
\brief InternalClientLoad request.
*/

struct JackInternalClientLoadRequest : public JackRequest
{

904
#ifndef MAX_PATH
sletz's avatar
sletz committed
905
#define MAX_PATH 256
906
#endif
sletz's avatar
sletz committed
907
908

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

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

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

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

/*!
\brief InternalClientLoad result.
*/

struct JackInternalClientLoadResult : public JackResult
{

sletz's avatar
sletz committed
952
953
    int fStatus;
    int fIntRefNum;
954

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

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

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

/*!
\brief InternalClientUnload request.
*/

struct JackInternalClientUnloadRequest : public JackRequest
{

sletz's avatar
sletz committed
986
    int fRefNum;
987
988
989
990
991
    int fIntRefNum;

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

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