Jack2 1.9.12

JackRequest.h
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 */
20
21 #ifndef __JackRequest__
22 #define __JackRequest__
23
24 #include "JackConstants.h"
25 #include "JackError.h"
26 #include "JackPlatformPlug.h"
27 #include "JackChannel.h"
28 #include "JackTime.h"
29 #include "types.h"
30 #include <string.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <list>
34
35 namespace Jack
36 {
37
38 #define CheckRes(exp) { if ((exp) < 0) { jack_error("CheckRes error"); return -1; } }
39 #define CheckSize() { CheckRes(trans->Read(&fSize, sizeof(int))); if (fSize != Size()) { jack_error("CheckSize error size = %d Size() = %d", fSize, Size()); return -1; } }
40
45 enum JackSessionReply {
46
47 kImmediateSessionReply = 1,
48 kPendingSessionReply = 2
49
50 };
51
56 struct JackRequest
57 {
58
59 enum RequestType {
60 kRegisterPort = 1,
61 kUnRegisterPort = 2,
62 kConnectPorts = 3,
63 kDisconnectPorts = 4,
64 kSetTimeBaseClient = 5,
65 kActivateClient = 6,
66 kDeactivateClient = 7,
67 kDisconnectPort = 8,
68 kSetClientCapabilities = 9,
69 kGetPortConnections = 10,
70 kGetPortNConnections = 11,
71 kReleaseTimebase = 12,
72 kSetTimebaseCallback = 13,
73 kSetBufferSize = 20,
74 kSetFreeWheel = 21,
75 kClientCheck = 22,
76 kClientOpen = 23,
77 kClientClose = 24,
78 kConnectNamePorts = 25,
79 kDisconnectNamePorts = 26,
80 kGetInternalClientName = 27,
81 kInternalClientHandle = 28,
82 kInternalClientLoad = 29,
83 kInternalClientUnload = 30,
84 kPortRename = 31,
85 kNotification = 32,
86 kSessionNotify = 33,
87 kSessionReply = 34,
88 kGetClientByUUID = 35,
89 kReserveClientName = 36,
90 kGetUUIDByClient = 37,
91 kClientHasSessionCallback = 38,
92 kComputeTotalLatencies = 39
93 };
94
95 RequestType fType;
96 int fSize;
97
98 JackRequest(): fType((RequestType)0), fSize(0)
99 {}
100
101 JackRequest(RequestType type): fType(type), fSize(0)
102 {}
103
104 virtual ~JackRequest()
105 {}
106
107 virtual int Read(detail::JackChannelTransactionInterface* trans)
108 {
109 return trans->Read(&fType, sizeof(RequestType));
110 }
111
112 virtual int Write(detail::JackChannelTransactionInterface* trans) { return -1; }
113
114 virtual int Write(detail::JackChannelTransactionInterface* trans, int size)
115 {
116 fSize = size;
117 CheckRes(trans->Write(&fType, sizeof(RequestType)));
118 return trans->Write(&fSize, sizeof(int));
119 }
120
121 virtual int Size() { return 0; }
122
123 };
124
129 struct JackResult
130 {
131
132 int fResult;
133
134 JackResult(): fResult( -1)
135 {}
136 JackResult(int result): fResult(result)
137 {}
138 virtual ~JackResult()
139 {}
140
141 virtual int Read(detail::JackChannelTransactionInterface* trans)
142 {
143 return trans->Read(&fResult, sizeof(int));
144 }
145
146 virtual int Write(detail::JackChannelTransactionInterface* trans)
147 {
148 return trans->Write(&fResult, sizeof(int));
149 }
150
151 };
152
157 struct JackClientCheckRequest : public JackRequest
158 {
159
160 char fName[JACK_CLIENT_NAME_SIZE+1];
161 int fProtocol;
162 int fOptions;
163 int fUUID;
164 int fOpen;
165
166 JackClientCheckRequest() : fProtocol(0), fOptions(0), fUUID(0), fOpen(0)
167 {
168 memset(fName, 0, sizeof(fName));
169 }
170 JackClientCheckRequest(const char* name, int protocol, int options, int uuid, int open = false)
171 : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options), fUUID(uuid), fOpen(open)
172 {
173 memset(fName, 0, sizeof(fName));
174 snprintf(fName, sizeof(fName), "%s", name);
175 }
176
177 int Read(detail::JackChannelTransactionInterface* trans)
178 {
179 CheckSize();
180 CheckRes(trans->Read(&fName, sizeof(fName)));
181 CheckRes(trans->Read(&fProtocol, sizeof(int)));
182 CheckRes(trans->Read(&fOptions, sizeof(int)));
183 CheckRes(trans->Read(&fUUID, sizeof(int)));
184 return trans->Read(&fOpen, sizeof(int));
185 }
186
187 int Write(detail::JackChannelTransactionInterface* trans)
188 {
189 CheckRes(JackRequest::Write(trans, Size()));
190 CheckRes(trans->Write(&fName, sizeof(fName)));
191 CheckRes(trans->Write(&fProtocol, sizeof(int)));
192 CheckRes(trans->Write(&fOptions, sizeof(int)));
193 CheckRes(trans->Write(&fUUID, sizeof(int)));
194 return trans->Write(&fOpen, sizeof(int));
195 }
196
197 int Size() { return sizeof(fName) + 4 * sizeof(int); }
198
199 };
200
205 struct JackClientCheckResult : public JackResult
206 {
207
208 char fName[JACK_CLIENT_NAME_SIZE+1];
209 int fStatus;
210
211 JackClientCheckResult(): JackResult(), fStatus(0)
212 {
213 memset(fName, 0, sizeof(fName));
214 }
215 JackClientCheckResult(int32_t result, const char* name, int status)
216 : JackResult(result), fStatus(status)
217 {
218 memset(fName, 0, sizeof(fName));
219 snprintf(fName, sizeof(fName), "%s", name);
220 }
221
222 int Read(detail::JackChannelTransactionInterface* trans)
223 {
224 CheckRes(JackResult::Read(trans));
225 CheckRes(trans->Read(&fName, sizeof(fName)));
226 CheckRes(trans->Read(&fStatus, sizeof(int)));
227 return 0;
228 }
229
230 int Write(detail::JackChannelTransactionInterface* trans)
231 {
232 CheckRes(JackResult::Write(trans));
233 CheckRes(trans->Write(&fName, sizeof(fName)));
234 CheckRes(trans->Write(&fStatus, sizeof(int)));
235 return 0;
236 }
237
238 };
239
244 struct JackClientOpenRequest : public JackRequest
245 {
246
247 int fPID;
248 int fUUID;
249 char fName[JACK_CLIENT_NAME_SIZE+1];
250
251 JackClientOpenRequest() : fPID(0), fUUID(0)
252 {
253 memset(fName, 0, sizeof(fName));
254 }
255 JackClientOpenRequest(const char* name, int pid, int uuid): JackRequest(JackRequest::kClientOpen)
256 {
257 memset(fName, 0, sizeof(fName));
258 snprintf(fName, sizeof(fName), "%s", name);
259 fPID = pid;
260 fUUID = uuid;
261 }
262
263 int Read(detail::JackChannelTransactionInterface* trans)
264 {
265 CheckSize();
266 CheckRes(trans->Read(&fPID, sizeof(int)));
267 CheckRes(trans->Read(&fUUID, sizeof(int)));
268 return trans->Read(&fName, sizeof(fName));
269 }
270
271 int Write(detail::JackChannelTransactionInterface* trans)
272 {
273 CheckRes(JackRequest::Write(trans, Size()));
274 CheckRes(trans->Write(&fPID, sizeof(int)));
275 CheckRes(trans->Write(&fUUID, sizeof(int)));
276 return trans->Write(&fName, sizeof(fName));
277 }
278
279 int Size() { return 2 * sizeof(int) + sizeof(fName); }
280
281 };
282
287 struct JackClientOpenResult : public JackResult
288 {
289
290 int fSharedEngine;
291 int fSharedClient;
292 int fSharedGraph;
293
294 JackClientOpenResult()
295 : JackResult(), fSharedEngine(-1), fSharedClient(-1), fSharedGraph(-1)
296 {}
297 JackClientOpenResult(int32_t result, int index1, int index2, int index3)
298 : JackResult(result), fSharedEngine(index1), fSharedClient(index2), fSharedGraph(index3)
299 {}
300
301 int Read(detail::JackChannelTransactionInterface* trans)
302 {
303 CheckRes(JackResult::Read(trans));
304 CheckRes(trans->Read(&fSharedEngine, sizeof(int)));
305 CheckRes(trans->Read(&fSharedClient, sizeof(int)));
306 CheckRes(trans->Read(&fSharedGraph, sizeof(int)));
307 return 0;
308 }
309
310 int Write(detail::JackChannelTransactionInterface* trans)
311 {
312 CheckRes(JackResult::Write(trans));
313 CheckRes(trans->Write(&fSharedEngine, sizeof(int)));
314 CheckRes(trans->Write(&fSharedClient, sizeof(int)));
315 CheckRes(trans->Write(&fSharedGraph, sizeof(int)));
316 return 0;
317 }
318
319 };
320
325 struct JackClientCloseRequest : public JackRequest
326 {
327
328 int fRefNum;
329
330 JackClientCloseRequest() : fRefNum(0)
331 {}
332 JackClientCloseRequest(int refnum): JackRequest(JackRequest::kClientClose), fRefNum(refnum)
333 {}
334
335 int Read(detail::JackChannelTransactionInterface* trans)
336 {
337 CheckSize();
338 return trans->Read(&fRefNum, sizeof(int));
339 }
340
341 int Write(detail::JackChannelTransactionInterface* trans)
342 {
343 CheckRes(JackRequest::Write(trans, Size()));
344 return trans->Write(&fRefNum, sizeof(int));
345 }
346
347 int Size() { return sizeof(int); }
348 };
349
354 struct JackActivateRequest : public JackRequest
355 {
356
357 int fRefNum;
358 int fIsRealTime;
359
360 JackActivateRequest() : fRefNum(0), fIsRealTime(0)
361 {}
362 JackActivateRequest(int refnum, int is_real_time)
363 : JackRequest(JackRequest::kActivateClient), fRefNum(refnum), fIsRealTime(is_real_time)
364 {}
365
366 int Read(detail::JackChannelTransactionInterface* trans)
367 {
368 CheckSize();
369 CheckRes(trans->Read(&fRefNum, sizeof(int)));
370 return trans->Read(&fIsRealTime, sizeof(int));
371 }
372
373 int Write(detail::JackChannelTransactionInterface* trans)
374 {
375 CheckRes(JackRequest::Write(trans, Size()));
376 CheckRes(trans->Write(&fRefNum, sizeof(int)));
377 return trans->Write(&fIsRealTime, sizeof(int));
378 }
379
380 int Size() { return 2 * sizeof(int); }
381 };
382
387 struct JackDeactivateRequest : public JackRequest
388 {
389
390 int fRefNum;
391
392 JackDeactivateRequest() : fRefNum(0)
393 {}
394 JackDeactivateRequest(int refnum): JackRequest(JackRequest::kDeactivateClient), fRefNum(refnum)
395 {}
396
397 int Read(detail::JackChannelTransactionInterface* trans)
398 {
399 CheckSize();
400 return trans->Read(&fRefNum, sizeof(int));
401 }
402
403 int Write(detail::JackChannelTransactionInterface* trans)
404 {
405 CheckRes(JackRequest::Write(trans, Size()));
406 return trans->Write(&fRefNum, sizeof(int));
407 }
408
409 int Size() { return sizeof(int); }
410 };
411
416 struct JackPortRegisterRequest : public JackRequest
417 {
418
419 int fRefNum;
420 char fName[JACK_PORT_NAME_SIZE + 1]; // port short name
421 char fPortType[JACK_PORT_TYPE_SIZE + 1];
422 unsigned int fFlags;
423 unsigned int fBufferSize;
424
425 JackPortRegisterRequest() : fRefNum(0), fFlags(0), fBufferSize(0)
426 {
427 memset(fName, 0, sizeof(fName));
428 memset(fPortType, 0, sizeof(fPortType));
429 }
430 JackPortRegisterRequest(int refnum, const char* name, const char* port_type, unsigned int flags, unsigned int buffer_size)
431 : JackRequest(JackRequest::kRegisterPort), fRefNum(refnum), fFlags(flags), fBufferSize(buffer_size)
432 {
433 memset(fName, 0, sizeof(fName));
434 memset(fPortType, 0, sizeof(fPortType));
435 strncpy(fName, name, sizeof(fName)-1);
436 strncpy(fPortType, port_type, sizeof(fPortType)-1);
437 }
438
439 int Read(detail::JackChannelTransactionInterface* trans)
440 {
441 CheckSize();
442 CheckRes(trans->Read(&fRefNum, sizeof(int)));
443 CheckRes(trans->Read(&fName, sizeof(fName)));
444 CheckRes(trans->Read(&fPortType, sizeof(fPortType)));
445 CheckRes(trans->Read(&fFlags, sizeof(unsigned int)));
446 CheckRes(trans->Read(&fBufferSize, sizeof(unsigned int)));
447 return 0;
448 }
449
450 int Write(detail::JackChannelTransactionInterface* trans)
451 {
452 CheckRes(JackRequest::Write(trans, Size()));
453 CheckRes(trans->Write(&fRefNum, sizeof(int)));
454 CheckRes(trans->Write(&fName, sizeof(fName)));
455 CheckRes(trans->Write(&fPortType, sizeof(fPortType)));
456 CheckRes(trans->Write(&fFlags, sizeof(unsigned int)));
457 CheckRes(trans->Write(&fBufferSize, sizeof(unsigned int)));
458 return 0;
459 }
460
461 int Size() { return sizeof(int) + sizeof(fName) + sizeof(fPortType) + 2 * sizeof(unsigned int); }
462
463 };
464
469 struct JackPortRegisterResult : public JackResult
470 {
471
472 jack_port_id_t fPortIndex;
473
474 JackPortRegisterResult(): JackResult(), fPortIndex(NO_PORT)
475 {}
476
477 int Read(detail::JackChannelTransactionInterface* trans)
478 {
479 CheckRes(JackResult::Read(trans));
480 return trans->Read(&fPortIndex, sizeof(jack_port_id_t));
481 }
482
483 int Write(detail::JackChannelTransactionInterface* trans)
484 {
485 CheckRes(JackResult::Write(trans));
486 return trans->Write(&fPortIndex, sizeof(jack_port_id_t));
487 }
488
489 };
490
495 struct JackPortUnRegisterRequest : public JackRequest
496 {
497
498 int fRefNum;
499 jack_port_id_t fPortIndex;
500
501 JackPortUnRegisterRequest() : fRefNum(0), fPortIndex(0)
502 {}
503 JackPortUnRegisterRequest(int refnum, jack_port_id_t index)
504 : JackRequest(JackRequest::kUnRegisterPort), fRefNum(refnum), fPortIndex(index)
505 {}
506
507 int Read(detail::JackChannelTransactionInterface* trans)
508 {
509 CheckSize();
510 CheckRes(trans->Read(&fRefNum, sizeof(int)));
511 CheckRes(trans->Read(&fPortIndex, sizeof(jack_port_id_t)));
512 return 0;
513 }
514
515 int Write(detail::JackChannelTransactionInterface* trans)
516 {
517 CheckRes(JackRequest::Write(trans, Size()));
518 CheckRes(trans->Write(&fRefNum, sizeof(int)));
519 CheckRes(trans->Write(&fPortIndex, sizeof(jack_port_id_t)));
520 return 0;
521 }
522
523 int Size() { return sizeof(int) + sizeof(jack_port_id_t); }
524 };
525
530 struct JackPortConnectNameRequest : public JackRequest
531 {
532
533 int fRefNum;
534 char fSrc[REAL_JACK_PORT_NAME_SIZE+1]; // port full name
535 char fDst[REAL_JACK_PORT_NAME_SIZE+1]; // port full name
536
537 JackPortConnectNameRequest() : fRefNum(0)
538 {
539 memset(fSrc, 0, sizeof(fSrc));
540 memset(fDst, 0, sizeof(fDst));
541 }
542 JackPortConnectNameRequest(int refnum, const char* src_name, const char* dst_name)
543 : JackRequest(JackRequest::kConnectNamePorts), fRefNum(refnum)
544 {
545 memset(fSrc, 0, sizeof(fSrc));
546 memset(fDst, 0, sizeof(fDst));
547 strncpy(fSrc, src_name, sizeof(fSrc)-1);
548 strncpy(fDst, dst_name, sizeof(fDst)-1);
549 }
550
551 int Read(detail::JackChannelTransactionInterface* trans)
552 {
553 CheckSize();
554 CheckRes(trans->Read(&fRefNum, sizeof(int)));
555 CheckRes(trans->Read(&fSrc, sizeof(fSrc)));
556 CheckRes(trans->Read(&fDst, sizeof(fDst)));
557 return 0;
558 }
559
560 int Write(detail::JackChannelTransactionInterface* trans)
561 {
562 CheckRes(JackRequest::Write(trans, Size()));
563 CheckRes(trans->Write(&fRefNum, sizeof(int)));
564 CheckRes(trans->Write(&fSrc, sizeof(fSrc)));
565 CheckRes(trans->Write(&fDst, sizeof(fDst)));
566 return 0;
567 }
568
569 int Size() { return sizeof(int) + sizeof(fSrc) + sizeof(fDst); }
570
571 };
572
577 struct JackPortDisconnectNameRequest : public JackRequest
578 {
579
580 int fRefNum;
581 char fSrc[REAL_JACK_PORT_NAME_SIZE+1]; // port full name
582 char fDst[REAL_JACK_PORT_NAME_SIZE+1]; // port full name
583
584 JackPortDisconnectNameRequest() : fRefNum(0)
585 {
586 memset(fSrc, 0, sizeof(fSrc));
587 memset(fDst, 0, sizeof(fDst));
588 }
589 JackPortDisconnectNameRequest(int refnum, const char* src_name, const char* dst_name)
590 : JackRequest(JackRequest::kDisconnectNamePorts), fRefNum(refnum)
591 {
592 memset(fSrc, 0, sizeof(fSrc));
593 memset(fDst, 0, sizeof(fDst));
594 strncpy(fSrc, src_name, sizeof(fSrc)-1);
595 strncpy(fDst, dst_name, sizeof(fDst)-1);
596 }
597
598 int Read(detail::JackChannelTransactionInterface* trans)
599 {
600 CheckSize();
601 CheckRes(trans->Read(&fRefNum, sizeof(int)));
602 CheckRes(trans->Read(&fSrc, sizeof(fSrc)));
603 CheckRes(trans->Read(&fDst, sizeof(fDst)));
604 return 0;
605 }
606
607 int Write(detail::JackChannelTransactionInterface* trans)
608 {
609 CheckRes(JackRequest::Write(trans, Size()));
610 CheckRes(trans->Write(&fRefNum, sizeof(int)));
611 CheckRes(trans->Write(&fSrc, sizeof(fSrc)));
612 CheckRes(trans->Write(&fDst, sizeof(fDst)));
613 return 0;
614 }
615
616 int Size() { return sizeof(int) + sizeof(fSrc) + sizeof(fDst); }
617
618 };
619
624 struct JackPortConnectRequest : public JackRequest
625 {
626
627 int fRefNum;
628 jack_port_id_t fSrc;
629 jack_port_id_t fDst;
630
631 JackPortConnectRequest() : fRefNum(0), fSrc(0), fDst(0)
632 {}
633 JackPortConnectRequest(int refnum, jack_port_id_t src, jack_port_id_t dst)
634 : JackRequest(JackRequest::kConnectPorts), fRefNum(refnum), fSrc(src), fDst(dst)
635 {}
636
637 int Read(detail::JackChannelTransactionInterface* trans)
638 {
639 CheckSize();
640 CheckRes(trans->Read(&fRefNum, sizeof(int)));
641 CheckRes(trans->Read(&fSrc, sizeof(jack_port_id_t)));
642 CheckRes(trans->Read(&fDst, sizeof(jack_port_id_t)));
643 return 0;
644 }
645
646 int Write(detail::JackChannelTransactionInterface* trans)
647 {
648 CheckRes(JackRequest::Write(trans, Size()));
649 CheckRes(trans->Write(&fRefNum, sizeof(int)));
650 CheckRes(trans->Write(&fSrc, sizeof(jack_port_id_t)));
651 CheckRes(trans->Write(&fDst, sizeof(jack_port_id_t)));
652 return 0;
653 }
654
655 int Size() { return sizeof(int) + sizeof(jack_port_id_t) + sizeof(jack_port_id_t); }
656 };
657
662 struct JackPortDisconnectRequest : public JackRequest
663 {
664
665 int fRefNum;
666 jack_port_id_t fSrc;
667 jack_port_id_t fDst;
668
669 JackPortDisconnectRequest() : fRefNum(0), fSrc(0), fDst(0)
670 {}
671 JackPortDisconnectRequest(int refnum, jack_port_id_t src, jack_port_id_t dst)
672 : JackRequest(JackRequest::kDisconnectPorts), fRefNum(refnum), fSrc(src), fDst(dst)
673 {}
674
675 int Read(detail::JackChannelTransactionInterface* trans)
676 {
677 CheckSize();
678 CheckRes(trans->Read(&fRefNum, sizeof(int)));
679 CheckRes(trans->Read(&fSrc, sizeof(jack_port_id_t)));
680 CheckRes(trans->Read(&fDst, sizeof(jack_port_id_t)));
681 return 0;
682 }
683
684 int Write(detail::JackChannelTransactionInterface* trans)
685 {
686 CheckRes(JackRequest::Write(trans, Size()));
687 CheckRes(trans->Write(&fRefNum, sizeof(int)));
688 CheckRes(trans->Write(&fSrc, sizeof(jack_port_id_t)));
689 CheckRes(trans->Write(&fDst, sizeof(jack_port_id_t)));
690 return 0;
691 }
692
693 int Size() { return sizeof(int) + sizeof(jack_port_id_t) + sizeof(jack_port_id_t); }
694 };
695
700 struct JackPortRenameRequest : public JackRequest
701 {
702
703 int fRefNum;
704 jack_port_id_t fPort;
705 char fName[JACK_PORT_NAME_SIZE + 1]; // port short name
706
707 JackPortRenameRequest() : fRefNum(0), fPort(0)
708 {
709 memset(fName, 0, sizeof(fName));
710 }
711 JackPortRenameRequest(int refnum, jack_port_id_t port, const char* name)
712 : JackRequest(JackRequest::kPortRename), fRefNum(refnum), fPort(port)
713 {
714 memset(fName, 0, sizeof(fName));
715 strncpy(fName, name, sizeof(fName)-1);
716 }
717
718 int Read(detail::JackChannelTransactionInterface* trans)
719 {
720 CheckSize();
721 CheckRes(trans->Read(&fRefNum, sizeof(int)));
722 CheckRes(trans->Read(&fPort, sizeof(jack_port_id_t)));
723 CheckRes(trans->Read(&fName, sizeof(fName)));
724 return 0;
725 }
726
727 int Write(detail::JackChannelTransactionInterface* trans)
728 {
729 CheckRes(JackRequest::Write(trans, Size()));
730 CheckRes(trans->Write(&fRefNum, sizeof(int)));
731 CheckRes(trans->Write(&fPort, sizeof(jack_port_id_t)));
732 CheckRes(trans->Write(&fName, sizeof(fName)));
733 return 0;
734 }
735
736 int Size() { return sizeof(int) + sizeof(jack_port_id_t) + sizeof(fName); }
737
738 };
739
744 struct JackSetBufferSizeRequest : public JackRequest
745 {
746
747 jack_nframes_t fBufferSize;
748
749 JackSetBufferSizeRequest() : fBufferSize(0)
750 {}
751 JackSetBufferSizeRequest(jack_nframes_t buffer_size)
752 : JackRequest(JackRequest::kSetBufferSize), fBufferSize(buffer_size)
753 {}
754
755 int Read(detail::JackChannelTransactionInterface* trans)
756 {
757 CheckSize();
758 return trans->Read(&fBufferSize, sizeof(jack_nframes_t));
759 }
760
761 int Write(detail::JackChannelTransactionInterface* trans)
762 {
763 CheckRes(JackRequest::Write(trans, Size()));
764 return trans->Write(&fBufferSize, sizeof(jack_nframes_t));
765 }
766
767 int Size() { return sizeof(jack_nframes_t); }
768 };
769
774 struct JackSetFreeWheelRequest : public JackRequest
775 {
776
777 int fOnOff;
778
779 JackSetFreeWheelRequest() : fOnOff(0)
780 {}
781 JackSetFreeWheelRequest(int onoff)
782 : JackRequest(JackRequest::kSetFreeWheel), fOnOff(onoff)
783 {}
784
785 int Read(detail::JackChannelTransactionInterface* trans)
786 {
787 CheckSize();
788 return trans->Read(&fOnOff, sizeof(int));
789 }
790
791 int Write(detail::JackChannelTransactionInterface* trans)
792 {
793 CheckRes(JackRequest::Write(trans, Size()));
794 return trans->Write(&fOnOff, sizeof(int));
795 }
796
797 int Size() { return sizeof(int); }
798
799 };
800
805 struct JackComputeTotalLatenciesRequest : public JackRequest
806 {
807
808 JackComputeTotalLatenciesRequest()
809 : JackRequest(JackRequest::kComputeTotalLatencies)
810 {}
811
812 int Read(detail::JackChannelTransactionInterface* trans)
813 {
814 CheckSize();
815 return 0;
816 }
817
818 int Write(detail::JackChannelTransactionInterface* trans)
819 {
820 CheckRes(JackRequest::Write(trans, Size()));
821 return 0;
822 }
823
824 int Size() { return 0; }
825 };
826
831 struct JackReleaseTimebaseRequest : public JackRequest
832 {
833
834 int fRefNum;
835
836 JackReleaseTimebaseRequest() : fRefNum(0)
837 {}
838 JackReleaseTimebaseRequest(int refnum)
839 : JackRequest(JackRequest::kReleaseTimebase), fRefNum(refnum)
840 {}
841
842 int Read(detail::JackChannelTransactionInterface* trans)
843 {
844 CheckSize();
845 return trans->Read(&fRefNum, sizeof(int));
846 }
847
848 int Write(detail::JackChannelTransactionInterface* trans)
849 {
850 CheckRes(JackRequest::Write(trans, Size()));
851 return trans->Write(&fRefNum, sizeof(int));
852 }
853
854 int Size() { return sizeof(int); }
855
856 };
857
862 struct JackSetTimebaseCallbackRequest : public JackRequest
863 {
864
865 int fRefNum;
866 int fConditionnal;
867
868 JackSetTimebaseCallbackRequest() : fRefNum(0), fConditionnal(0)
869 {}
870 JackSetTimebaseCallbackRequest(int refnum, int conditional)
871 : JackRequest(JackRequest::kSetTimebaseCallback), fRefNum(refnum), fConditionnal(conditional)
872 {}
873
874 int Read(detail::JackChannelTransactionInterface* trans)
875 {
876 CheckSize();
877 CheckRes(trans->Read(&fRefNum, sizeof(int)));
878 return trans->Read(&fConditionnal, sizeof(int));
879 }
880
881 int Write(detail::JackChannelTransactionInterface* trans)
882 {
883 CheckRes(JackRequest::Write(trans, Size()));
884 CheckRes(trans->Write(&fRefNum, sizeof(int)));
885 return trans->Write(&fConditionnal, sizeof(int));
886 }
887
888 int Size() { return sizeof(int) + sizeof(int); }
889 };
890
895 struct JackGetInternalClientNameRequest : public JackRequest
896 {
897
898 int fRefNum;
899 int fIntRefNum;
900
901 JackGetInternalClientNameRequest() : fRefNum(0), fIntRefNum(0)
902 {}
903 JackGetInternalClientNameRequest(int refnum, int int_ref)
904 : JackRequest(JackRequest::kGetInternalClientName), fRefNum(refnum), fIntRefNum(int_ref)
905 {}
906
907 int Read(detail::JackChannelTransactionInterface* trans)
908 {
909 CheckSize();
910 CheckRes(trans->Read(&fRefNum, sizeof(int)));
911 return trans->Read(&fIntRefNum, sizeof(int));
912 }
913
914 int Write(detail::JackChannelTransactionInterface* trans)
915 {
916 CheckRes(JackRequest::Write(trans, Size()));
917 CheckRes(trans->Write(&fRefNum, sizeof(int)));
918 return trans->Write(&fIntRefNum, sizeof(int));
919 }
920
921 int Size() { return sizeof(int) + sizeof(int); }
922 };
923
928 struct JackGetInternalClientNameResult : public JackResult
929 {
930
931 char fName[JACK_CLIENT_NAME_SIZE+1];
932
933 JackGetInternalClientNameResult(): JackResult()
934 {
935 memset(fName, 0, sizeof(fName));
936 }
937 JackGetInternalClientNameResult(int32_t result, const char* name)
938 : JackResult(result)
939 {
940 memset(fName, 0, sizeof(fName));
941 snprintf(fName, sizeof(fName), "%s", name);
942 }
943
944 int Read(detail::JackChannelTransactionInterface* trans)
945 {
946 CheckRes(JackResult::Read(trans));
947 CheckRes(trans->Read(&fName, sizeof(fName)));
948 return 0;
949 }
950
951 int Write(detail::JackChannelTransactionInterface* trans)
952 {
953 CheckRes(JackResult::Write(trans));
954 CheckRes(trans->Write(&fName, sizeof(fName)));
955 return 0;
956 }
957
958 int Size() { return sizeof(fName); }
959 };
960
965 struct JackInternalClientHandleRequest : public JackRequest
966 {
967
968 int fRefNum;
969 char fName[JACK_CLIENT_NAME_SIZE+1];
970
971 JackInternalClientHandleRequest() : fRefNum(0)
972 {
973 memset(fName, 0, sizeof(fName));
974 }
975 JackInternalClientHandleRequest(int refnum, const char* client_name)
976 : JackRequest(JackRequest::kInternalClientHandle), fRefNum(refnum)
977 {
978 memset(fName, 0, sizeof(fName));
979 snprintf(fName, sizeof(fName), "%s", client_name);
980 }
981
982 int Read(detail::JackChannelTransactionInterface* trans)
983 {
984 CheckSize();
985 CheckRes(trans->Read(&fRefNum, sizeof(int)));
986 return trans->Read(&fName, sizeof(fName));
987 }
988
989 int Write(detail::JackChannelTransactionInterface* trans)
990 {
991 CheckRes(JackRequest::Write(trans, Size()));
992 CheckRes(trans->Write(&fRefNum, sizeof(int)));
993 return trans->Write(&fName, sizeof(fName));
994 }
995
996 int Size() { return sizeof(int) + sizeof(fName); }
997 };
998
1003 struct JackInternalClientHandleResult : public JackResult
1004 {
1005
1006 int fStatus;
1007 int fIntRefNum;
1008
1009 JackInternalClientHandleResult(): JackResult(), fStatus(0), fIntRefNum(0)
1010 {}
1011 JackInternalClientHandleResult(int32_t result, int status, int int_ref)
1012 : JackResult(result), fStatus(status), fIntRefNum(int_ref)
1013 {}
1014
1015 int Read(detail::JackChannelTransactionInterface* trans)
1016 {
1017 CheckRes(JackResult::Read(trans));
1018 CheckRes(trans->Read(&fStatus, sizeof(int)));
1019 CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
1020 return 0;
1021 }
1022
1023 int Write(detail::JackChannelTransactionInterface* trans)
1024 {
1025 CheckRes(JackResult::Write(trans));
1026 CheckRes(trans->Write(&fStatus, sizeof(int)));
1027 CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
1028 return 0;
1029 }
1030
1031 int Size() { return sizeof(int) + sizeof(int); }
1032 };
1033
1038 struct JackInternalClientLoadRequest : public JackRequest
1039 {
1040
1041 #ifndef MAX_PATH
1042 #define MAX_PATH 256
1043 #endif
1044
1045 int fRefNum;
1046 char fName[JACK_CLIENT_NAME_SIZE+1];
1047 char fDllName[MAX_PATH+1];
1048 char fLoadInitName[JACK_LOAD_INIT_LIMIT+1];
1049 int fOptions;
1050 int fUUID;
1051
1052 JackInternalClientLoadRequest() : fRefNum(0), fOptions(0), fUUID(0)
1053 {
1054 memset(fName, 0, sizeof(fName));
1055 memset(fDllName, 0, sizeof(fDllName));
1056 memset(fLoadInitName, 0, sizeof(fLoadInitName));
1057 }
1058 JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int uuid )
1059 : JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options), fUUID(uuid)
1060 {
1061 memset(fName, 0, sizeof(fName));
1062 memset(fDllName, 0, sizeof(fDllName));
1063 memset(fLoadInitName, 0, sizeof(fLoadInitName));
1064 snprintf(fName, sizeof(fName), "%s", client_name);
1065 snprintf(fDllName, sizeof(fDllName), "%s", so_name);
1066 snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data);
1067 }
1068
1069 int Read(detail::JackChannelTransactionInterface* trans)
1070 {
1071 CheckSize();
1072 CheckRes(trans->Read(&fRefNum, sizeof(int)));
1073 CheckRes(trans->Read(&fName, sizeof(fName)));
1074 CheckRes(trans->Read(&fDllName, sizeof(fDllName)));
1075 CheckRes(trans->Read(&fLoadInitName, sizeof(fLoadInitName)));
1076 CheckRes(trans->Read(&fUUID, sizeof(int)));
1077 return trans->Read(&fOptions, sizeof(int));
1078 }
1079
1080 int Write(detail::JackChannelTransactionInterface* trans)
1081 {
1082 CheckRes(JackRequest::Write(trans, Size()));
1083 CheckRes(trans->Write(&fRefNum, sizeof(int)));
1084 CheckRes(trans->Write(&fName, sizeof(fName)));
1085 CheckRes(trans->Write(&fDllName, sizeof(fDllName)));
1086 CheckRes(trans->Write(&fLoadInitName, sizeof(fLoadInitName)));
1087 CheckRes(trans->Write(&fUUID, sizeof(int)));
1088 return trans->Write(&fOptions, sizeof(int));
1089 }
1090
1091 int Size() { return sizeof(int) + sizeof(fName) + sizeof(fDllName) + sizeof(fLoadInitName) + 2 * sizeof(int); }
1092 };
1093
1098 struct JackInternalClientLoadResult : public JackResult
1099 {
1100
1101 int fStatus;
1102 int fIntRefNum;
1103
1104 JackInternalClientLoadResult(): JackResult(), fStatus(0), fIntRefNum(0)
1105 {}
1106 JackInternalClientLoadResult(int32_t result, int status, int int_ref)
1107 : JackResult(result), fStatus(status), fIntRefNum(int_ref)
1108 {}
1109
1110 int Read(detail::JackChannelTransactionInterface* trans)
1111 {
1112 CheckRes(JackResult::Read(trans));
1113 CheckRes(trans->Read(&fStatus, sizeof(int)));
1114 CheckRes(trans->Read(&fIntRefNum, sizeof(int)));
1115 return 0;
1116 }
1117
1118 int Write(detail::JackChannelTransactionInterface* trans)
1119 {
1120 CheckRes(JackResult::Write(trans));
1121 CheckRes(trans->Write(&fStatus, sizeof(int)));
1122 CheckRes(trans->Write(&fIntRefNum, sizeof(int)));
1123 return 0;
1124 }
1125
1126 int Size() { return sizeof(int) + sizeof(int); }
1127 };
1128
1133 struct JackInternalClientUnloadRequest : public JackRequest
1134 {
1135
1136 int fRefNum;
1137 int fIntRefNum;
1138
1139 JackInternalClientUnloadRequest() : fRefNum(0), fIntRefNum(0)
1140 {}
1141 JackInternalClientUnloadRequest(int refnum, int int_ref)
1142 : JackRequest(JackRequest::kInternalClientUnload), fRefNum(refnum), fIntRefNum(int_ref)
1143 {}
1144
1145 int Read(detail::JackChannelTransactionInterface* trans)
1146 {
1147 CheckSize();
1148 CheckRes(trans->Read(&fRefNum, sizeof(int)));
1149 return trans->Read(&fIntRefNum, sizeof(int));
1150 }
1151
1152 int Write(detail::JackChannelTransactionInterface* trans)
1153 {
1154 CheckRes(JackRequest::Write(trans, Size()));
1155 CheckRes(trans->Write(&fRefNum, sizeof(int)));
1156 return trans->Write(&fIntRefNum, sizeof(int));
1157 }
1158
1159 int Size() { return sizeof(int) + sizeof(int); }
1160 };
1161
1166 struct JackInternalClientUnloadResult : public JackResult
1167 {
1168
1169 int fStatus;
1170
1171 JackInternalClientUnloadResult(): JackResult(), fStatus(0)
1172 {}
1173 JackInternalClientUnloadResult(int32_t result, int status)
1174 : JackResult(result), fStatus(status)
1175 {}
1176
1177 int Read(detail::JackChannelTransactionInterface* trans)
1178 {
1179 CheckRes(JackResult::Read(trans));
1180 CheckRes(trans->Read(&fStatus, sizeof(int)));
1181 return 0;
1182 }
1183
1184 int Write(detail::JackChannelTransactionInterface* trans)
1185 {
1186 CheckRes(JackResult::Write(trans));
1187 CheckRes(trans->Write(&fStatus, sizeof(int)));
1188 return 0;
1189 }
1190
1191 int Size() { return sizeof(int); }
1192 };
1193
1198 struct JackClientNotificationRequest : public JackRequest
1199 {
1200
1201 int fRefNum;
1202 int fNotify;
1203 int fValue;
1204
1205 JackClientNotificationRequest() : fRefNum(0), fNotify(0), fValue(0)
1206 {}
1207 JackClientNotificationRequest(int refnum, int notify, int value)
1208 : JackRequest(JackRequest::kNotification), fRefNum(refnum), fNotify(notify), fValue(value)
1209 {}
1210
1211 int Read(detail::JackChannelTransactionInterface* trans)
1212 {
1213 CheckSize();
1214 CheckRes(trans->Read(&fRefNum, sizeof(int)));
1215 CheckRes(trans->Read(&fNotify, sizeof(int)));
1216 CheckRes(trans->Read(&fValue, sizeof(int)));
1217 return 0;
1218 }
1219
1220 int Write(detail::JackChannelTransactionInterface* trans)
1221 {
1222 CheckRes(JackRequest::Write(trans, Size()));
1223 CheckRes(trans->Write(&fRefNum, sizeof(int)));
1224 CheckRes(trans->Write(&fNotify, sizeof(int)));
1225 CheckRes(trans->Write(&fValue, sizeof(int)));
1226 return 0;
1227 }
1228
1229 int Size() { return 3 * sizeof(int); }
1230
1231 };
1232
1233 struct JackSessionCommand
1234 {
1235 char fUUID[JACK_UUID_SIZE];
1236 char fClientName[JACK_CLIENT_NAME_SIZE+1];
1237 char fCommand[JACK_SESSION_COMMAND_SIZE];
1238 jack_session_flags_t fFlags;
1239
1240 JackSessionCommand() : fFlags(JackSessionSaveError)
1241 {
1242 memset(fUUID, 0, sizeof(fUUID));
1243 memset(fClientName, 0, sizeof(fClientName));
1244 memset(fCommand, 0, sizeof(fCommand));
1245 }
1246 JackSessionCommand(const char *uuid, const char *clientname, const char *command, jack_session_flags_t flags)
1247 {
1248 memset(fUUID, 0, sizeof(fUUID));
1249 memset(fClientName, 0, sizeof(fClientName));
1250 memset(fCommand, 0, sizeof(fCommand));
1251 strncpy(fUUID, uuid, sizeof(fUUID)-1);
1252 strncpy(fClientName, clientname, sizeof(fClientName)-1);
1253 strncpy(fCommand, command, sizeof(fCommand)-1);
1254 fFlags = flags;
1255 }
1256 };
1257
1258 struct JackSessionNotifyResult : public JackResult
1259 {
1260
1261 std::list<JackSessionCommand> fCommandList;
1262 bool fDone;
1263
1264 JackSessionNotifyResult(): JackResult(), fDone(false)
1265 {}
1266 JackSessionNotifyResult(int32_t result)
1267 : JackResult(result), fDone(false)
1268 {}
1269
1270 int Read(detail::JackChannelTransactionInterface* trans)
1271 {
1272 if (trans == NULL)
1273 {
1274 return 0;
1275 }
1276
1277 CheckRes(JackResult::Read(trans));
1278 while (true) {
1279 JackSessionCommand buffer;
1280
1281 CheckRes(trans->Read(buffer.fUUID, sizeof(buffer.fUUID)));
1282 if (buffer.fUUID[0] == '\0')
1283 break;
1284
1285 CheckRes(trans->Read(buffer.fClientName, sizeof(buffer.fClientName)));
1286 CheckRes(trans->Read(buffer.fCommand, sizeof(buffer.fCommand)));
1287 CheckRes(trans->Read(&(buffer.fFlags), sizeof(buffer.fFlags)));
1288
1289 fCommandList.push_back(buffer);
1290 }
1291
1292 fDone = true;
1293
1294 return 0;
1295 }
1296
1297 int Write(detail::JackChannelTransactionInterface* trans)
1298 {
1299 if (trans == NULL)
1300 {
1301 fDone = true;
1302 return 0;
1303 }
1304
1305 char terminator[JACK_UUID_SIZE];
1306 terminator[0] = '\0';
1307
1308 CheckRes(JackResult::Write(trans));
1309 for (std::list<JackSessionCommand>::iterator i = fCommandList.begin(); i != fCommandList.end(); i++) {
1310 CheckRes(trans->Write(i->fUUID, sizeof(i->fUUID)));
1311 CheckRes(trans->Write(i->fClientName, sizeof(i->fClientName)));
1312 CheckRes(trans->Write(i->fCommand, sizeof(i->fCommand)));
1313 CheckRes(trans->Write(&(i->fFlags), sizeof(i->fFlags)));
1314 }
1315 CheckRes(trans->Write(terminator, sizeof(terminator)));
1316 return 0;
1317 }
1318
1319 jack_session_command_t* GetCommands()
1320 {
1321 /* TODO: some kind of signal should be used instead */
1322 while (!fDone)
1323 {
1324 JackSleep(50000); /* 50 ms */
1325 }
1326
1327 jack_session_command_t* session_command = (jack_session_command_t *)malloc(sizeof(jack_session_command_t) * (fCommandList.size() + 1));
1328 int i = 0;
1329
1330 for (std::list<JackSessionCommand>::iterator ci = fCommandList.begin(); ci != fCommandList.end(); ci++) {
1331 session_command[i].uuid = strdup(ci->fUUID);
1332 session_command[i].client_name = strdup(ci->fClientName);
1333 session_command[i].command = strdup(ci->fCommand);
1334 session_command[i].flags = ci->fFlags;
1335 i += 1;
1336 }
1337
1338 session_command[i].uuid = NULL;
1339 session_command[i].client_name = NULL;
1340 session_command[i].command = NULL;
1341 session_command[i].flags = (jack_session_flags_t)0;
1342
1343 return session_command;
1344 }
1345 };
1346
1351 struct JackSessionNotifyRequest : public JackRequest
1352 {
1353 char fPath[JACK_MESSAGE_SIZE+1];
1354 char fDst[JACK_CLIENT_NAME_SIZE+1];
1355 jack_session_event_type_t fEventType;
1356 int fRefNum;
1357
1358 JackSessionNotifyRequest() : fEventType(JackSessionSave), fRefNum(0)
1359 {}
1360 JackSessionNotifyRequest(int refnum, const char* path, jack_session_event_type_t type, const char* dst)
1361 : JackRequest(JackRequest::kSessionNotify), fEventType(type), fRefNum(refnum)
1362 {
1363 memset(fPath, 0, sizeof(fPath));
1364 memset(fDst, 0, sizeof(fDst));
1365 snprintf(fPath, sizeof(fPath), "%s", path);
1366 fPath[JACK_MESSAGE_SIZE] = 0;
1367 if (dst) {
1368 snprintf(fDst, sizeof(fDst), "%s", dst);
1369 fDst[JACK_CLIENT_NAME_SIZE] = 0;
1370 }
1371 }
1372
1373 int Read(detail::JackChannelTransactionInterface* trans)
1374 {
1375 CheckSize();
1376 CheckRes(trans->Read(&fRefNum, sizeof(fRefNum)));
1377 CheckRes(trans->Read(&fPath, sizeof(fPath)));
1378 CheckRes(trans->Read(&fDst, sizeof(fDst)));
1379 CheckRes(trans->Read(&fEventType, sizeof(fEventType)));
1380 return 0;
1381 }
1382
1383 int Write(detail::JackChannelTransactionInterface* trans)
1384 {
1385 CheckRes(JackRequest::Write(trans, Size()));
1386 CheckRes(trans->Write(&fRefNum, sizeof(fRefNum)));
1387 CheckRes(trans->Write(&fPath, sizeof(fPath)));
1388 CheckRes(trans->Write(&fDst, sizeof(fDst)));
1389 CheckRes(trans->Write(&fEventType, sizeof(fEventType)));
1390 return 0;
1391 }
1392
1393 int Size() { return sizeof(fRefNum) + sizeof(fPath) + sizeof(fDst) + sizeof(fEventType); }
1394 };
1395
1396 struct JackSessionReplyRequest : public JackRequest
1397 {
1398 int fRefNum;
1399
1400 JackSessionReplyRequest() : fRefNum(0)
1401 {}
1402
1403 JackSessionReplyRequest(int refnum)
1404 : JackRequest(JackRequest::kSessionReply), fRefNum(refnum)
1405 {}
1406
1407 int Read(detail::JackChannelTransactionInterface* trans)
1408 {
1409 CheckSize();
1410 CheckRes(trans->Read(&fRefNum, sizeof(int)));
1411 return 0;
1412 }
1413
1414 int Write(detail::JackChannelTransactionInterface* trans)
1415 {
1416 CheckRes(JackRequest::Write(trans, Size()));
1417 CheckRes(trans->Write(&fRefNum, sizeof(int)));
1418 return 0;
1419 }
1420
1421 int Size() { return sizeof(int); }
1422
1423 };
1424
1425 struct JackClientNameResult : public JackResult
1426 {
1427 char fName[JACK_CLIENT_NAME_SIZE+1];
1428
1429 JackClientNameResult(): JackResult()
1430 {
1431 memset(fName, 0, sizeof(fName));
1432 }
1433 JackClientNameResult(int32_t result, const char* name)
1434 : JackResult(result)
1435 {
1436 memset(fName, 0, sizeof(fName));
1437 snprintf(fName, sizeof(fName), "%s", name);
1438 }
1439
1440 int Read(detail::JackChannelTransactionInterface* trans)
1441 {
1442 CheckRes(JackResult::Read(trans));
1443 CheckRes(trans->Read(&fName, sizeof(fName)));
1444 return 0;
1445 }
1446
1447 int Write(detail::JackChannelTransactionInterface* trans)
1448 {
1449 CheckRes(JackResult::Write(trans));
1450 CheckRes(trans->Write(&fName, sizeof(fName)));
1451 return 0;
1452 }
1453
1454 };
1455
1456 struct JackUUIDResult : public JackResult
1457 {
1458 char fUUID[JACK_UUID_SIZE];
1459
1460 JackUUIDResult(): JackResult()
1461 {
1462 memset(fUUID, 0, sizeof(fUUID));
1463 }
1464 JackUUIDResult(int32_t result, const char* uuid)
1465 : JackResult(result)
1466 {
1467 memset(fUUID, 0, sizeof(fUUID));
1468 snprintf(fUUID, sizeof(fUUID), "%s", uuid);
1469 }
1470
1471 int Read(detail::JackChannelTransactionInterface* trans)
1472 {
1473 CheckRes(JackResult::Read(trans));
1474 CheckRes(trans->Read(&fUUID, sizeof(fUUID)));
1475 return 0;
1476 }
1477
1478 int Write(detail::JackChannelTransactionInterface* trans)
1479 {
1480 CheckRes(JackResult::Write(trans));
1481 CheckRes(trans->Write(&fUUID, sizeof(fUUID)));
1482 return 0;
1483 }
1484
1485 };
1486
1487 struct JackGetUUIDRequest : public JackRequest
1488 {
1489 char fName[JACK_CLIENT_NAME_SIZE+1];
1490
1491 JackGetUUIDRequest()
1492 {
1493 memset(fName, 0, sizeof(fName));
1494 }
1495
1496 JackGetUUIDRequest(const char* client_name)
1497 : JackRequest(JackRequest::kGetUUIDByClient)
1498 {
1499 memset(fName, 0, sizeof(fName));
1500 strncpy(fName, client_name, sizeof(fName)-1);
1501 }
1502
1503 int Read(detail::JackChannelTransactionInterface* trans)
1504 {
1505 CheckSize();
1506 CheckRes(trans->Read(&fName, sizeof(fName)));
1507 return 0;
1508 }
1509
1510 int Write(detail::JackChannelTransactionInterface* trans)
1511 {
1512 CheckRes(JackRequest::Write(trans, Size()));
1513 CheckRes(trans->Write(&fName, sizeof(fName)));
1514 return 0;
1515 }
1516
1517 int Size() { return sizeof(fName); }
1518
1519 };
1520
1521 struct JackGetClientNameRequest : public JackRequest
1522 {
1523 char fUUID[JACK_UUID_SIZE];
1524
1525 JackGetClientNameRequest()
1526 {
1527 memset(fUUID, 0, sizeof(fUUID));
1528 }
1529
1530 JackGetClientNameRequest(const char* uuid)
1531 : JackRequest(JackRequest::kGetClientByUUID)
1532 {
1533 memset(fUUID, 0, sizeof(fUUID));
1534 strncpy(fUUID, uuid, sizeof(fUUID)-1);
1535 }
1536
1537 int Read(detail::JackChannelTransactionInterface* trans)
1538 {
1539 CheckSize();
1540 CheckRes(trans->Read(&fUUID, sizeof(fUUID)));
1541 return 0;
1542 }
1543
1544 int Write(detail::JackChannelTransactionInterface* trans)
1545 {
1546 CheckRes(JackRequest::Write(trans, Size()));
1547 CheckRes(trans->Write(&fUUID, sizeof(fUUID)));
1548 return 0;
1549 }
1550
1551 int Size() { return sizeof(fUUID); }
1552
1553 };
1554
1555 struct JackReserveNameRequest : public JackRequest
1556 {
1557 int fRefNum;
1558 char fName[JACK_CLIENT_NAME_SIZE+1];
1559 char fUUID[JACK_UUID_SIZE];
1560
1561 JackReserveNameRequest() : fRefNum(0)
1562 {
1563 memset(fName, 0, sizeof(fName));
1564 memset(fUUID, 0, sizeof(fUUID));
1565 }
1566
1567 JackReserveNameRequest(int refnum, const char *name, const char* uuid)
1568 : JackRequest(JackRequest::kReserveClientName), fRefNum(refnum)
1569 {
1570 memset(fName, 0, sizeof(fName));
1571 memset(fUUID, 0, sizeof(fUUID));
1572 strncpy(fName, name, sizeof(fName)-1);
1573 strncpy(fUUID, uuid, sizeof(fUUID)-1);
1574 }
1575
1576 int Read(detail::JackChannelTransactionInterface* trans)
1577 {
1578 CheckSize();
1579 CheckRes(trans->Read(&fUUID, sizeof(fUUID)));
1580 CheckRes(trans->Read(&fName, sizeof(fName)));
1581 CheckRes(trans->Read(&fRefNum, sizeof(fRefNum)));
1582 return 0;
1583 }
1584
1585 int Write(detail::JackChannelTransactionInterface* trans)
1586 {
1587 CheckRes(JackRequest::Write(trans, Size()));
1588 CheckRes(trans->Write(&fUUID, sizeof(fUUID)));
1589 CheckRes(trans->Write(&fName, sizeof(fName)));
1590 CheckRes(trans->Write(&fRefNum, sizeof(fRefNum)));
1591 return 0;
1592 }
1593
1594 int Size() { return sizeof(fUUID) + sizeof(fName) + sizeof(fRefNum); }
1595
1596 };
1597
1598 struct JackClientHasSessionCallbackRequest : public JackRequest
1599 {
1600 char fName[JACK_CLIENT_NAME_SIZE+1];
1601
1602 JackClientHasSessionCallbackRequest()
1603 {
1604 memset(fName, 0, sizeof(fName));
1605 }
1606
1607 JackClientHasSessionCallbackRequest(const char *name)
1608 : JackRequest(JackRequest::kClientHasSessionCallback)
1609 {
1610 memset(fName, 0, sizeof(fName));
1611 strncpy(fName, name, sizeof(fName)-1);
1612 }
1613
1614 int Read(detail::JackChannelTransactionInterface* trans)
1615 {
1616 CheckSize();
1617 CheckRes(trans->Read(&fName, sizeof(fName)));
1618 return 0;
1619 }
1620
1621 int Write(detail::JackChannelTransactionInterface* trans)
1622 {
1623 CheckRes(JackRequest::Write(trans, Size()));
1624 CheckRes(trans->Write(&fName, sizeof(fName)));
1625 return 0;
1626 }
1627
1628 int Size() { return sizeof(fName); }
1629
1630 };
1631
1636 struct JackClientNotification
1637 {
1638 int fSize;
1639 char fName[JACK_CLIENT_NAME_SIZE+1];
1640 int fRefNum;
1641 int fNotify;
1642 int fValue1;
1643 int fValue2;
1644 int fSync;
1645 char fMessage[JACK_MESSAGE_SIZE+1];
1646
1647 JackClientNotification(): fSize(0), fRefNum(0), fNotify(-1), fValue1(-1), fValue2(-1), fSync(0)
1648 {
1649 memset(fName, 0, sizeof(fName));
1650 memset(fMessage, 0, sizeof(fMessage));
1651 }
1652 JackClientNotification(const char* name, int refnum, int notify, int sync, const char* message, int value1, int value2)
1653 : fRefNum(refnum), fNotify(notify), fValue1(value1), fValue2(value2), fSync(sync)
1654 {
1655 memset(fName, 0, sizeof(fName));
1656 memset(fMessage, 0, sizeof(fMessage));
1657 snprintf(fName, sizeof(fName), "%s", name);
1658 snprintf(fMessage, sizeof(fMessage), "%s", message);
1659 fSize = Size();
1660 }
1661
1662 int Read(detail::JackChannelTransactionInterface* trans)
1663 {
1664 CheckSize();
1665 CheckRes(trans->Read(&fName, sizeof(fName)));
1666 CheckRes(trans->Read(&fRefNum, sizeof(int)));
1667 CheckRes(trans->Read(&fNotify, sizeof(int)));
1668 CheckRes(trans->Read(&fValue1, sizeof(int)));
1669 CheckRes(trans->Read(&fValue2, sizeof(int)));
1670 CheckRes(trans->Read(&fSync, sizeof(int)));
1671 CheckRes(trans->Read(&fMessage, sizeof(fMessage)));
1672 return 0;
1673 }
1674
1675 int Write(detail::JackChannelTransactionInterface* trans)
1676 {
1677 CheckRes(trans->Write(&fSize, sizeof(int)));
1678 CheckRes(trans->Write(&fName, sizeof(fName)));
1679 CheckRes(trans->Write(&fRefNum, sizeof(int)));
1680 CheckRes(trans->Write(&fNotify, sizeof(int)));
1681 CheckRes(trans->Write(&fValue1, sizeof(int)));
1682 CheckRes(trans->Write(&fValue2, sizeof(int)));
1683 CheckRes(trans->Write(&fSync, sizeof(int)));
1684 CheckRes(trans->Write(&fMessage, sizeof(fMessage)));
1685 return 0;
1686 }
1687
1688 int Size() { return sizeof(int) + sizeof(fName) + 5 * sizeof(int) + sizeof(fMessage); }
1689
1690 };
1691
1692 } // end of namespace
1693
1694 #endif
Jack::JackReleaseTimebaseRequest
ReleaseTimebase request.
Definition: JackRequest.h:831
Jack::JackPortConnectNameRequest
PortConnectName request.
Definition: JackRequest.h:530
JackSessionSaveError
Definition: session.h:87
Jack::JackSetBufferSizeRequest
SetBufferSize request.
Definition: JackRequest.h:744
Jack::JackInternalClientHandleResult
InternalClientHandle result.
Definition: JackRequest.h:1003
Jack::JackClientCloseRequest
CloseClient request.
Definition: JackRequest.h:325
Jack::JackClientCheckResult
CheckClient result.
Definition: JackRequest.h:205
Jack::JackSetTimebaseCallbackRequest
SetTimebaseCallback request.
Definition: JackRequest.h:862
Jack::JackPortDisconnectRequest
PortDisconnect request.
Definition: JackRequest.h:662
Jack::JackResult
Result from the server.
Definition: JackRequest.h:129
Jack::JackClientOpenRequest
NewClient request.
Definition: JackRequest.h:244
Jack::JackReserveNameRequest
Definition: JackRequest.h:1555
Jack::JackInternalClientLoadResult
InternalClientLoad result.
Definition: JackRequest.h:1098
Jack::JackRequest
Request from client to server.
Definition: JackRequest.h:56
Jack::JackClientNotificationRequest
ClientNotification request.
Definition: JackRequest.h:1198
Jack::JackClientCheckRequest
CheckClient request.
Definition: JackRequest.h:157
Jack::JackGetInternalClientNameRequest
GetInternalClientName request.
Definition: JackRequest.h:895
Jack::JackClientNameResult
Definition: JackRequest.h:1425
Jack::JackClientOpenResult
NewClient result.
Definition: JackRequest.h:287
Jack::JackGetInternalClientNameResult
GetInternalClient result.
Definition: JackRequest.h:928
jack_session_command_t
Definition: JackSession.h:59
Jack::JackPortRegisterResult
PortRegister result.
Definition: JackRequest.h:469
Jack::JackComputeTotalLatenciesRequest
ComputeTotalLatencies request.
Definition: JackRequest.h:805
Jack::JackPortRenameRequest
PortRename request.
Definition: JackRequest.h:700
Jack::JackDeactivateRequest
Deactivate request.
Definition: JackRequest.h:387
Jack::JackActivateRequest
Activate request.
Definition: JackRequest.h:354
Jack::JackPortUnRegisterRequest
PortUnregister request.
Definition: JackRequest.h:495
jack_session_flags_t
enum JackSessionFlags jack_session_flags_t
Definition: session.h:98
Jack::JackSessionNotifyRequest
SessionNotify request.
Definition: JackRequest.h:1351
Jack::JackInternalClientUnloadRequest
InternalClientUnload request.
Definition: JackRequest.h:1133
Jack::JackInternalClientLoadRequest
InternalClientLoad request.
Definition: JackRequest.h:1038
Jack::JackPortConnectRequest
PortConnect request.
Definition: JackRequest.h:624
Jack::JackInternalClientUnloadResult
InternalClientLoad result.
Definition: JackRequest.h:1166
Jack::JackGetUUIDRequest
Definition: JackRequest.h:1487
Jack::JackPortDisconnectNameRequest
PortDisconnectName request.
Definition: JackRequest.h:577
Jack::JackGetClientNameRequest
Definition: JackRequest.h:1521
Jack::JackSessionCommand
Definition: JackRequest.h:1233
Jack::detail::JackChannelTransactionInterface
Definition: JackChannel.h:38
Jack::JackSetFreeWheelRequest
SetFreeWheel request.
Definition: JackRequest.h:774
Jack::JackSessionNotifyResult
Definition: JackRequest.h:1258
Jack::JackSessionReplyRequest
Definition: JackRequest.h:1396
Jack::JackUUIDResult
Definition: JackRequest.h:1456
Jack::JackClientNotification
ClientNotification.
Definition: JackRequest.h:1636
Jack::JackPortRegisterRequest
PortRegister request.
Definition: JackRequest.h:416
JackSessionSave
Definition: session.h:57
Jack::JackInternalClientHandleRequest
InternalClientHandle request.
Definition: JackRequest.h:965
Jack::JackClientHasSessionCallbackRequest
Definition: JackRequest.h:1598