2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
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.
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.
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.
21 #ifndef __JackGraphManager__
22 #define __JackGraphManager__
24 #include "JackShmMem.h"
26 #include "JackConstants.h"
27 #include "JackConnectionManager.h"
28 #include "JackAtomicState.h"
29 #include "JackPlatformPlug.h"
30 #include "JackSystemDeps.h"
37 \brief Graph manager: contains the connection manager and the port array.
40 class SERVER_EXPORT JackGraphManager
: public JackShmMem
, public JackAtomicState
<JackConnectionManager
>
45 unsigned int fPortMax
;
46 JackClientTiming fClientTiming
[CLIENT_NUM
];
47 JackPort fPortArray
[0]; // The actual size depends of port_max, it will be dynamically computed and allocated using "placement" new
49 void AssertPort(jack_port_id_t port_index
);
50 jack_port_id_t
AllocatePortAux(int refnum
, const char* port_name
, const char* port_type
, JackPortFlags flags
);
51 void GetConnectionsAux(JackConnectionManager
* manager
, const char** res
, jack_port_id_t port_index
);
52 void GetPortsAux(const char** matching_ports
, const char* port_name_pattern
, const char* type_name_pattern
, unsigned long flags
);
53 float* GetBuffer(jack_port_id_t port_index
);
54 void* GetBufferAux(JackConnectionManager
* manager
, jack_port_id_t port_index
, jack_nframes_t frames
);
55 jack_nframes_t
ComputeTotalLatencyAux(jack_port_id_t port_index
, jack_port_id_t src_port_index
, JackConnectionManager
* manager
, int hop_count
);
59 JackGraphManager(int port_max
);
63 void SetBufferSize(jack_nframes_t buffer_size
);
66 jack_port_id_t
AllocatePort(int refnum
, const char* port_name
, const char* port_type
, JackPortFlags flags
, jack_nframes_t buffer_size
);
67 int ReleasePort(int refnum
, jack_port_id_t port_index
);
68 void ActivatePort(jack_port_id_t port_index
);
69 void DeactivatePort(jack_port_id_t port_index
);
70 void GetInputPorts(int refnum
, jack_int_t
* res
);
71 void GetOutputPorts(int refnum
, jack_int_t
* res
);
72 void RemoveAllPorts(int refnum
);
73 void DisconnectAllPorts(int refnum
);
75 JackPort
* GetPort(jack_port_id_t index
);
76 jack_port_id_t
GetPort(const char* name
);
77 int ComputeTotalLatency(jack_port_id_t port_index
);
78 int ComputeTotalLatencies();
79 int RequestMonitor(jack_port_id_t port_index
, bool onoff
);
81 // Connections management
82 int Connect(jack_port_id_t src_index
, jack_port_id_t dst_index
);
83 int Disconnect(jack_port_id_t src_index
, jack_port_id_t dst_index
);
84 int IsConnected(jack_port_id_t port_src
, jack_port_id_t port_dst
);
87 int GetConnectionsNum(jack_port_id_t port_index
)
89 JackConnectionManager
* manager
= ReadCurrentState();
90 return manager
->Connections(port_index
);
93 const char** GetConnections(jack_port_id_t port_index
);
94 void GetConnections(jack_port_id_t port_index
, jack_int_t
* connections
); // TODO
95 const char** GetPorts(const char* port_name_pattern
, const char* type_name_pattern
, unsigned long flags
);
97 int GetTwoPorts(const char* src
, const char* dst
, jack_port_id_t
* src_index
, jack_port_id_t
* dst_index
);
98 int CheckPorts(jack_port_id_t port_src
, jack_port_id_t port_dst
);
100 void DisconnectAllInput(jack_port_id_t port_index
);
101 void DisconnectAllOutput(jack_port_id_t port_index
);
102 int DisconnectAll(jack_port_id_t port_index
);
104 bool IsDirectConnection(int ref1
, int ref2
);
105 void DirectConnect(int ref1
, int ref2
);
106 void DirectDisconnect(int ref1
, int ref2
);
108 void Activate(int refnum
);
109 void Deactivate(int refnum
);
111 int GetInputRefNum(jack_port_id_t port_index
);
112 int GetOutputRefNum(jack_port_id_t port_index
);
115 void* GetBuffer(jack_port_id_t port_index
, jack_nframes_t frames
);
117 // Activation management
118 void RunCurrentGraph();
120 bool IsFinishedGraph();
122 void InitRefNum(int refnum
);
123 int ResumeRefNum(JackClientControl
* control
, JackSynchro
* table
);
124 int SuspendRefNum(JackClientControl
* control
, JackSynchro
* table
, long usecs
);
126 JackClientTiming
* GetClientTiming(int refnum
)
128 return &fClientTiming
[refnum
];
131 void Save(JackConnectionManager
* dst
);
132 void Restore(JackConnectionManager
* src
);
134 static JackGraphManager
* Allocate(int port_max
);
135 static void Destroy(JackGraphManager
* manager
);
137 } POST_PACKED_STRUCTURE
;
140 } // end of namespace