2 Copyright (C) 2004-2008 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "JackSystemDeps.h"
25 #include "JackLockedEngine.h"
26 #include "JackExternalClient.h"
27 #include "JackInternalClient.h"
28 #include "JackEngineControl.h"
29 #include "JackClientControl.h"
30 #include "JackGlobals.h"
31 #include "JackChannel.h"
32 #include "JackError.h"
37 #define AssertRefnum(ref) assert(ref >= 0 && ref < CLIENT_NUM);
39 JackEngine::JackEngine(JackGraphManager
* manager
,
41 JackEngineControl
* control
)
43 fGraphManager
= manager
;
44 fSynchroTable
= table
;
45 fEngineControl
= control
;
46 for (int i
= 0; i
< CLIENT_NUM
; i
++)
47 fClientTable
[i
] = NULL
;
50 JackEngine::~JackEngine()
52 jack_log("JackEngine::~JackEngine");
55 int JackEngine::Open()
57 jack_log("JackEngine::Open");
59 // Open audio thread => request thread communication channel
60 if (fChannel
.Open(fEngineControl
->fServerName
) < 0) {
61 jack_error("Cannot connect to server");
68 int JackEngine::Close()
70 jack_log("JackEngine::Close");
73 // Close remaining clients (RT is stopped)
74 for (int i
= REAL_REFNUM
; i
< CLIENT_NUM
; i
++) {
75 if (JackLoadableInternalClient
* loadable_client
= dynamic_cast<JackLoadableInternalClient
*>(fClientTable
[i
])) {
76 jack_log("JackEngine::Close loadable client = %s", loadable_client
->GetClientControl()->fName
);
77 loadable_client
->Close();
78 // Close does not delete the pointer for internal clients
79 fClientTable
[i
] = NULL
;
80 delete loadable_client
;
81 } else if (JackExternalClient
* external_client
= dynamic_cast<JackExternalClient
*>(fClientTable
[i
])) {
82 jack_log("JackEngine::Close external client = %s", external_client
->GetClientControl()->fName
);
83 external_client
->Close();
84 // Close deletes the pointer for external clients
85 fClientTable
[i
] = NULL
;
93 //-----------------------------
94 // Client ressource management
95 //-----------------------------
97 int JackEngine::AllocateRefnum()
99 for (int i
= 0; i
< CLIENT_NUM
; i
++) {
100 if (!fClientTable
[i
]) {
101 jack_log("JackEngine::AllocateRefNum ref = %ld", i
);
108 void JackEngine::ReleaseRefnum(int ref
)
110 fClientTable
[ref
] = NULL
;
112 if (fEngineControl
->fTemporary
) {
114 for (i
= REAL_REFNUM
; i
< CLIENT_NUM
; i
++) {
118 if (i
== CLIENT_NUM
) {
119 // last client and temporay case: quit the server
120 jack_log("JackEngine::ReleaseRefnum server quit");
121 fEngineControl
->fTemporary
= false;
133 void JackEngine::ProcessNext(jack_time_t cur_cycle_begin
)
135 fLastSwitchUsecs
= cur_cycle_begin
;
136 if (fGraphManager
->RunNextGraph()) // True if the graph actually switched to a new state
137 fChannel
.Notify(ALL_CLIENTS
, kGraphOrderCallback
, 0);
138 fSignal
.SignalAll(); // Signal for threads waiting for next cycle
141 void JackEngine::ProcessCurrent(jack_time_t cur_cycle_begin
)
143 if (cur_cycle_begin
< fLastSwitchUsecs
+ 2 * fEngineControl
->fPeriodUsecs
) // Signal XRun only for the first failing cycle
144 CheckXRun(cur_cycle_begin
);
145 fGraphManager
->RunCurrentGraph();
148 bool JackEngine::Process(jack_time_t cur_cycle_begin
, jack_time_t prev_cycle_end
)
153 fEngineControl
->CycleBegin(fClientTable
, fGraphManager
, cur_cycle_begin
, prev_cycle_end
);
156 if (fGraphManager
->IsFinishedGraph()) {
157 ProcessNext(cur_cycle_begin
);
160 jack_log("Process: graph not finished!");
161 if (cur_cycle_begin
> fLastSwitchUsecs
+ fEngineControl
->fTimeOutUsecs
) {
162 jack_log("Process: switch to next state delta = %ld", long(cur_cycle_begin
- fLastSwitchUsecs
));
163 ProcessNext(cur_cycle_begin
);
166 jack_log("Process: waiting to switch delta = %ld", long(cur_cycle_begin
- fLastSwitchUsecs
));
167 ProcessCurrent(cur_cycle_begin
);
173 fEngineControl
->CycleEnd(fClientTable
);
179 Client that finish *after* the callback date are considered late even if their output buffers may have been
180 correctly mixed in the time window: callbackUsecs <==> Read <==> Write.
183 void JackEngine::CheckXRun(jack_time_t callback_usecs
) // REVOIR les conditions de fin
185 for (int i
= REAL_REFNUM
; i
< CLIENT_NUM
; i
++) {
186 JackClientInterface
* client
= fClientTable
[i
];
187 if (client
&& client
->GetClientControl()->fActive
) {
188 JackClientTiming
* timing
= fGraphManager
->GetClientTiming(i
);
189 jack_client_state_t status
= timing
->fStatus
;
190 jack_time_t finished_date
= timing
->fFinishedAt
;
192 if (status
!= NotTriggered
&& status
!= Finished
) {
193 jack_error("JackEngine::XRun: client = %s was not run: state = %ld", client
->GetClientControl()->fName
, status
);
194 fChannel
.Notify(ALL_CLIENTS
, kXRunCallback
, 0); // Notify all clients
197 if (status
== Finished
&& (long)(finished_date
- callback_usecs
) > 0) {
198 jack_error("JackEngine::XRun: client %s finished after current callback", client
->GetClientControl()->fName
);
199 fChannel
.Notify(ALL_CLIENTS
, kXRunCallback
, 0); // Notify all clients
209 void JackEngine::NotifyClient(int refnum
, int event
, int sync
, int value1
, int value2
)
211 JackClientInterface
* client
= fClientTable
[refnum
];
213 // The client may be notified by the RT thread while closing
215 jack_log("JackEngine::NotifyClient: client not available anymore");
216 } else if (client
->GetClientControl()->fCallback
[event
]) {
217 if (client
->ClientNotify(refnum
, client
->GetClientControl()->fName
, event
, sync
, value1
, value2
) < 0)
218 jack_error("NotifyClient fails name = %s event = %ld = val1 = %ld val2 = %ld", client
->GetClientControl()->fName
, event
, value1
, value2
);
220 jack_log("JackEngine::NotifyClient: no callback for event = %ld", event
);
224 void JackEngine::NotifyClients(int event
, int sync
, int value1
, int value2
)
226 for (int i
= 0; i
< CLIENT_NUM
; i
++) {
227 JackClientInterface
* client
= fClientTable
[i
];
229 if (client
->GetClientControl()->fCallback
[event
]) {
230 if (client
->ClientNotify(i
, client
->GetClientControl()->fName
, event
, sync
, value1
, value2
) < 0)
231 jack_error("NotifyClient fails name = %s event = %ld = val1 = %ld val2 = %ld", client
->GetClientControl()->fName
, event
, value1
, value2
);
233 jack_log("JackEngine::NotifyClients: no callback for event = %ld", event
);
239 int JackEngine::NotifyAddClient(JackClientInterface
* new_client
, const char* name
, int refnum
)
241 // Notify existing clients of the new client and new client of existing clients.
242 for (int i
= 0; i
< CLIENT_NUM
; i
++) {
243 JackClientInterface
* old_client
= fClientTable
[i
];
245 if (old_client
->ClientNotify(refnum
, name
, kAddClient
, true, 0, 0) < 0) {
246 jack_error("NotifyAddClient old_client fails name = %s", old_client
->GetClientControl()->fName
);
249 if (new_client
->ClientNotify(i
, old_client
->GetClientControl()->fName
, kAddClient
, true, 0, 0) < 0) {
250 jack_error("NotifyAddClient new_client fails name = %s", name
);
259 void JackEngine::NotifyRemoveClient(const char* name
, int refnum
)
261 // Notify existing clients (including the one beeing suppressed) of the removed client
262 for (int i
= 0; i
< CLIENT_NUM
; i
++) {
263 JackClientInterface
* client
= fClientTable
[i
];
265 client
->ClientNotify(refnum
, name
, kRemoveClient
, true, 0, 0);
270 // Coming from the driver
271 void JackEngine::NotifyXRun(jack_time_t callback_usecs
, float delayed_usecs
)
273 // Use the audio thread => request thread communication channel
274 fEngineControl
->ResetFrameTime(callback_usecs
);
275 fEngineControl
->NotifyXRun(delayed_usecs
);
276 fChannel
.Notify(ALL_CLIENTS
, kXRunCallback
, 0);
279 void JackEngine::NotifyXRun(int refnum
)
281 if (refnum
== ALL_CLIENTS
) {
282 NotifyClients(kXRunCallback
, false, 0, 0);
284 NotifyClient(refnum
, kXRunCallback
, false, 0, 0);
288 void JackEngine::NotifyGraphReorder()
290 NotifyClients(kGraphOrderCallback
, false, 0, 0);
293 void JackEngine::NotifyBufferSize(jack_nframes_t buffer_size
)
295 NotifyClients(kBufferSizeCallback
, true, buffer_size
, 0);
298 void JackEngine::NotifySampleRate(jack_nframes_t sample_rate
)
300 NotifyClients(kSampleRateCallback
, true, sample_rate
, 0);
303 void JackEngine::NotifyFreewheel(bool onoff
)
305 fEngineControl
->fRealTime
= !onoff
;
306 NotifyClients((onoff
? kStartFreewheelCallback
: kStopFreewheelCallback
), true, 0, 0);
309 void JackEngine::NotifyPortRegistation(jack_port_id_t port_index
, bool onoff
)
311 NotifyClients((onoff
? kPortRegistrationOnCallback
: kPortRegistrationOffCallback
), false, port_index
, 0);
314 void JackEngine::NotifyPortRename(jack_port_id_t port
)
316 NotifyClients(kPortRenameCallback
, false, port
, 0);
319 void JackEngine::NotifyPortConnect(jack_port_id_t src
, jack_port_id_t dst
, bool onoff
)
321 NotifyClients((onoff
? kPortConnectCallback
: kPortDisconnectCallback
), false, src
, dst
);
324 void JackEngine::NotifyActivate(int refnum
)
326 NotifyClient(refnum
, kActivateClient
, true, 0, 0);
329 //----------------------------
330 // Loadable client management
331 //----------------------------
333 int JackEngine::GetInternalClientName(int refnum
, char* name_res
)
335 AssertRefnum(refnum
);
336 JackClientInterface
* client
= fClientTable
[refnum
];
338 strncpy(name_res
, client
->GetClientControl()->fName
, JACK_CLIENT_NAME_SIZE
);
345 int JackEngine::InternalClientHandle(const char* client_name
, int* status
, int* int_ref
)
350 for (int i
= 0; i
< CLIENT_NUM
; i
++) {
351 JackClientInterface
* client
= fClientTable
[i
];
352 if (client
&& dynamic_cast<JackLoadableInternalClient
*>(client
) && (strcmp(client
->GetClientControl()->fName
, client_name
) == 0)) {
353 jack_log("InternalClientHandle found client name = %s ref = %ld", client_name
, i
);
359 *status
|= (JackNoSuchClient
| JackFailure
);
363 int JackEngine::InternalClientUnload(int refnum
, int* status
)
365 AssertRefnum(refnum
);
366 JackClientInterface
* client
= fClientTable
[refnum
];
368 int res
= client
->Close();
373 *status
= (JackNoSuchClient
| JackFailure
);
378 //-------------------
380 //-------------------
382 int JackEngine::ClientCheck(const char* name
, char* name_res
, int protocol
, int options
, int* status
)
386 strcpy(name_res
, name
);
388 jack_log("Check protocol client %ld server = %ld", protocol
, JACK_PROTOCOL_VERSION
);
390 if (protocol
!= JACK_PROTOCOL_VERSION
) {
391 *status
|= (JackFailure
| JackVersionError
);
392 jack_error("JACK protocol mismatch (%d vs %d)", protocol
, JACK_PROTOCOL_VERSION
);
396 if (ClientCheckName(name
)) {
398 *status
|= JackNameNotUnique
;
400 if (options
& JackUseExactName
) {
401 jack_error("cannot create new client; %s already exists", name
);
402 *status
|= JackFailure
;
406 if (GenerateUniqueName(name_res
)) {
407 *status
|= JackFailure
;
415 bool JackEngine::GenerateUniqueName(char* name
)
418 int length
= strlen(name
);
420 if (length
> JACK_CLIENT_NAME_SIZE
- 4) {
421 jack_error("%s exists and is too long to make unique", name
);
422 return true; /* failure */
425 /* generate a unique name by appending "-01".."-99" */
426 name
[length
++] = '-';
433 while (ClientCheckName(name
)) {
434 if (name
[ones
] == '9') {
435 if (name
[tens
] == '9') {
436 jack_error("client %s has 99 extra instances already", name
);
437 return true; /* give up */
448 bool JackEngine::ClientCheckName(const char* name
)
450 for (int i
= 0; i
< CLIENT_NUM
; i
++) {
451 JackClientInterface
* client
= fClientTable
[i
];
452 if (client
&& (strcmp(client
->GetClientControl()->fName
, name
) == 0))
459 int JackEngine::GetClientPID(const char* name
)
461 for (int i
= 0; i
< CLIENT_NUM
; i
++) {
462 JackClientInterface
* client
= fClientTable
[i
];
463 if (client
&& (strcmp(client
->GetClientControl()->fName
, name
) == 0))
464 return client
->GetClientControl()->fPID
;
470 // Used for external clients
471 int JackEngine::ClientExternalOpen(const char* name
, int pid
, int* ref
, int* shared_engine
, int* shared_client
, int* shared_graph_manager
)
473 jack_log("JackEngine::ClientOpen: name = %s ", name
);
475 int refnum
= AllocateRefnum();
477 jack_error("No more refnum available");
481 JackExternalClient
* client
= new JackExternalClient();
483 if (!fSynchroTable
[refnum
].Allocate(name
, fEngineControl
->fServerName
, 0)) {
484 jack_error("Cannot allocate synchro");
488 if (client
->Open(name
, pid
, refnum
, shared_client
) < 0) {
489 jack_error("Cannot open client");
493 if (!fSignal
.TimedWait(DRIVER_OPEN_TIMEOUT
* 1000000)) {
494 // Failure if RT thread is not running (problem with the driver...)
495 jack_error("Driver is not running");
499 fClientTable
[refnum
] = client
;
501 if (NotifyAddClient(client
, name
, refnum
) < 0) {
502 jack_error("Cannot notify add client");
506 fGraphManager
->InitRefNum(refnum
);
507 fEngineControl
->ResetRollingUsecs();
508 *shared_engine
= fEngineControl
->GetShmIndex();
509 *shared_graph_manager
= fGraphManager
->GetShmIndex();
515 fSynchroTable
[refnum
].Destroy();
516 fClientTable
[refnum
] = 0;
522 // Used for server driver clients
523 int JackEngine::ClientInternalOpen(const char* name
, int* ref
, JackEngineControl
** shared_engine
, JackGraphManager
** shared_manager
, JackClientInterface
* client
, bool wait
)
525 jack_log("JackEngine::ClientInternalNew: name = %s", name
);
527 int refnum
= AllocateRefnum();
529 jack_error("No more refnum available");
533 if (!fSynchroTable
[refnum
].Allocate(name
, fEngineControl
->fServerName
, 0)) {
534 jack_error("Cannot allocate synchro");
538 if (wait
&& !fSignal
.TimedWait(DRIVER_OPEN_TIMEOUT
* 1000000)) {
539 // Failure if RT thread is not running (problem with the driver...)
540 jack_error("Driver is not running");
544 fClientTable
[refnum
] = client
;
546 if (NotifyAddClient(client
, name
, refnum
) < 0) {
547 jack_error("Cannot notify add client");
551 fGraphManager
->InitRefNum(refnum
);
552 fEngineControl
->ResetRollingUsecs();
553 *shared_engine
= fEngineControl
;
554 *shared_manager
= fGraphManager
;
560 fSynchroTable
[refnum
].Destroy();
561 fClientTable
[refnum
] = 0;
565 // Used for external clients
566 int JackEngine::ClientExternalClose(int refnum
)
568 AssertRefnum(refnum
);
569 JackClientInterface
* client
= fClientTable
[refnum
];
572 fEngineControl
->fTransport
.ResetTimebase(refnum
);
573 int res
= ClientCloseAux(refnum
, client
, true);
582 // Used for server internal clients or drivers when the RT thread is stopped
583 int JackEngine::ClientInternalClose(int refnum
, bool wait
)
585 AssertRefnum(refnum
);
586 JackClientInterface
* client
= fClientTable
[refnum
];
587 return (client
) ? ClientCloseAux(refnum
, client
, wait
) : -1;
590 int JackEngine::ClientCloseAux(int refnum
, JackClientInterface
* client
, bool wait
)
592 jack_log("JackEngine::ClientCloseAux ref = %ld", refnum
);
594 // Unregister all ports ==> notifications are sent
595 jack_int_t ports
[PORT_NUM_FOR_CLIENT
];
598 fGraphManager
->GetInputPorts(refnum
, ports
);
599 for (i
= 0; (i
< PORT_NUM_FOR_CLIENT
) && (ports
[i
] != EMPTY
) ; i
++) {
600 PortUnRegister(refnum
, ports
[i
]);
603 fGraphManager
->GetOutputPorts(refnum
, ports
);
604 for (i
= 0; (i
< PORT_NUM_FOR_CLIENT
) && (ports
[i
] != EMPTY
) ; i
++) {
605 PortUnRegister(refnum
, ports
[i
]);
608 // Remove the client from the table
609 ReleaseRefnum(refnum
);
612 fGraphManager
->RemoveAllPorts(refnum
);
614 // Wait until next cycle to be sure client is not used anymore
616 if (!fSignal
.TimedWait(fEngineControl
->fTimeOutUsecs
* 2)) { // Must wait at least until a switch occurs in Process, even in case of graph end failure
617 jack_error("JackEngine::ClientCloseAux wait error ref = %ld", refnum
);
621 // Notify running clients
622 NotifyRemoveClient(client
->GetClientControl()->fName
, client
->GetClientControl()->fRefNum
);
625 fSynchroTable
[refnum
].Destroy();
626 fEngineControl
->ResetRollingUsecs();
630 int JackEngine::ClientActivate(int refnum
, bool state
)
632 AssertRefnum(refnum
);
633 JackClientInterface
* client
= fClientTable
[refnum
];
634 assert(fClientTable
[refnum
]);
636 jack_log("JackEngine::ClientActivate ref = %ld name = %s", refnum
, client
->GetClientControl()->fName
);
638 fGraphManager
->Activate(refnum
);
640 // Wait for graph state change to be effective
641 if (!fSignal
.TimedWait(fEngineControl
->fTimeOutUsecs
* 10)) {
642 jack_error("JackEngine::ClientActivate wait error ref = %ld name = %s", refnum
, client
->GetClientControl()->fName
);
645 NotifyActivate(refnum
);
650 // May be called without client
651 int JackEngine::ClientDeactivate(int refnum
)
653 AssertRefnum(refnum
);
654 JackClientInterface
* client
= fClientTable
[refnum
];
658 jack_log("JackEngine::ClientDeactivate ref = %ld name = %s", refnum
, client
->GetClientControl()->fName
);
660 // Disconnect all ports ==> notifications are sent
661 jack_int_t ports
[PORT_NUM_FOR_CLIENT
];
664 fGraphManager
->GetInputPorts(refnum
, ports
);
665 for (i
= 0; (i
< PORT_NUM_FOR_CLIENT
) && (ports
[i
] != EMPTY
) ; i
++) {
666 PortDisconnect(refnum
, ports
[i
], ALL_PORTS
);
669 fGraphManager
->GetOutputPorts(refnum
, ports
);
670 for (i
= 0; (i
< PORT_NUM_FOR_CLIENT
) && (ports
[i
] != EMPTY
) ; i
++) {
671 PortDisconnect(refnum
, ports
[i
], ALL_PORTS
);
674 fGraphManager
->Deactivate(refnum
);
675 fLastSwitchUsecs
= 0; // Force switch to occur next cycle, even when called with "dead" clients
677 // Wait for graph state change to be effective
678 if (!fSignal
.TimedWait(fEngineControl
->fTimeOutUsecs
* 10)) {
679 jack_error("JackEngine::ClientDeactivate wait error ref = %ld name = %s", refnum
, client
->GetClientControl()->fName
);
690 int JackEngine::PortRegister(int refnum
, const char* name
, const char *type
, unsigned int flags
, unsigned int buffer_size
, jack_port_id_t
* port_index
)
692 jack_log("JackEngine::PortRegister ref = %ld name = %s type = %s flags = %d buffer_size = %d", refnum
, name
, type
, flags
, buffer_size
);
693 AssertRefnum(refnum
);
694 assert(fClientTable
[refnum
]);
696 // Check if port name already exists
697 if (fGraphManager
->GetPort(name
) != NO_PORT
) {
698 jack_error("port_name \"%s\" already exists", name
);
702 *port_index
= fGraphManager
->AllocatePort(refnum
, name
, type
, (JackPortFlags
)flags
, fEngineControl
->fBufferSize
);
703 if (*port_index
!= NO_PORT
) {
704 NotifyPortRegistation(*port_index
, true);
711 int JackEngine::PortUnRegister(int refnum
, jack_port_id_t port_index
)
713 jack_log("JackEngine::PortUnRegister ref = %ld port_index = %ld", refnum
, port_index
);
714 AssertRefnum(refnum
);
715 assert(fClientTable
[refnum
]);
717 // Disconnect port ==> notification is sent
718 PortDisconnect(refnum
, port_index
, ALL_PORTS
);
720 if (fGraphManager
->ReleasePort(refnum
, port_index
) == 0) {
721 NotifyPortRegistation(port_index
, false);
728 int JackEngine::PortConnect(int refnum
, const char* src
, const char* dst
)
730 jack_log("JackEngine::PortConnect src = %s dst = %s", src
, dst
);
731 jack_port_id_t port_src
, port_dst
;
733 return (fGraphManager
->CheckPorts(src
, dst
, &port_src
, &port_dst
) < 0)
735 : PortConnect(refnum
, port_src
, port_dst
);
738 int JackEngine::PortConnect(int refnum
, jack_port_id_t src
, jack_port_id_t dst
)
740 jack_log("JackEngine::PortConnect src = %d dst = %d", src
, dst
);
741 AssertRefnum(refnum
);
742 JackClientInterface
* client
;
745 if (fGraphManager
->CheckPorts(src
, dst
) < 0)
748 ref
= fGraphManager
->GetOutputRefNum(src
);
750 client
= fClientTable
[ref
];
752 if (!client
->GetClientControl()->fActive
) {
753 jack_error("Cannot connect ports owned by inactive clients:"
754 " \"%s\" is not active", client
->GetClientControl()->fName
);
758 ref
= fGraphManager
->GetInputRefNum(dst
);
760 client
= fClientTable
[ref
];
762 if (!client
->GetClientControl()->fActive
) {
763 jack_error("Cannot connect ports owned by inactive clients:"
764 " \"%s\" is not active", client
->GetClientControl()->fName
);
768 int res
= fGraphManager
->Connect(src
, dst
);
770 NotifyPortConnect(src
, dst
, true);
774 int JackEngine::PortDisconnect(int refnum
, const char* src
, const char* dst
)
776 jack_log("JackEngine::PortDisconnect src = %s dst = %s", src
, dst
);
777 AssertRefnum(refnum
);
778 jack_port_id_t port_src
, port_dst
;
780 if (fGraphManager
->CheckPorts(src
, dst
, &port_src
, &port_dst
) < 0) {
782 } else if (fGraphManager
->Disconnect(port_src
, port_dst
) == 0) {
783 NotifyPortConnect(port_src
, port_dst
, false);
790 int JackEngine::PortDisconnect(int refnum
, jack_port_id_t src
, jack_port_id_t dst
)
792 jack_log("JackEngine::PortDisconnect src = %d dst = %d", src
, dst
);
793 AssertRefnum(refnum
);
795 if (dst
== ALL_PORTS
) {
797 jack_int_t connections
[CONNECTION_NUM_FOR_PORT
];
798 fGraphManager
->GetConnections(src
, connections
);
801 JackPort
* port
= fGraphManager
->GetPort(src
);
802 if (port
->GetFlags() & JackPortIsOutput
) {
803 for (int i
= 0; (i
< CONNECTION_NUM_FOR_PORT
) && (connections
[i
] != EMPTY
); i
++) {
804 jack_log("NotifyPortConnect src = %ld dst = %ld false", src
, connections
[i
]);
805 NotifyPortConnect(src
, connections
[i
], false);
808 for (int i
= 0; (i
< CONNECTION_NUM_FOR_PORT
) && (connections
[i
] != EMPTY
); i
++) {
809 jack_log("NotifyPortConnect src = %ld dst = %ld false", connections
[i
], src
);
810 NotifyPortConnect(connections
[i
], src
, false);
814 return fGraphManager
->DisconnectAll(src
);
815 } else if (fGraphManager
->CheckPorts(src
, dst
) < 0) {
817 } else if (fGraphManager
->Disconnect(src
, dst
) == 0) {
819 NotifyPortConnect(src
, dst
, false);
826 int JackEngine::PortRename(int refnum
, jack_port_id_t port
, const char* name
)
828 fGraphManager
->GetPort(port
)->SetName(name
);
829 NotifyPortRename(port
);
833 } // end of namespace