Jack2 1.9.6
|
00001 /* 00002 Copyright (C) 2001 Paul Davis 00003 Copyright (C) 2004-2008 Grame 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU Lesser General Public License as published by 00007 the Free Software Foundation; either version 2.1 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 */ 00020 00021 #ifndef __JackGraphManager__ 00022 #define __JackGraphManager__ 00023 00024 #include "JackShmMem.h" 00025 #include "JackPort.h" 00026 #include "JackConstants.h" 00027 #include "JackConnectionManager.h" 00028 #include "JackAtomicState.h" 00029 #include "JackPlatformPlug.h" 00030 #include "JackSystemDeps.h" 00031 00032 00033 namespace Jack 00034 { 00035 00040 class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectionManager> 00041 { 00042 00043 private: 00044 00045 unsigned int fPortMax; 00046 JackClientTiming fClientTiming[CLIENT_NUM]; 00047 JackPort fPortArray[0]; // The actual size depends of port_max, it will be dynamically computed and allocated using "placement" new 00048 00049 void AssertPort(jack_port_id_t port_index); 00050 jack_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags); 00051 void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index); 00052 void GetPortsAux(const char** matching_ports, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); 00053 float* GetBuffer(jack_port_id_t port_index); 00054 void* GetBufferAux(JackConnectionManager* manager, jack_port_id_t port_index, jack_nframes_t frames); 00055 jack_nframes_t ComputeTotalLatencyAux(jack_port_id_t port_index, jack_port_id_t src_port_index, JackConnectionManager* manager, int hop_count); 00056 00057 public: 00058 00059 JackGraphManager(int port_max); 00060 ~JackGraphManager() 00061 {} 00062 00063 void SetBufferSize(jack_nframes_t buffer_size); 00064 00065 // Ports management 00066 jack_port_id_t AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size); 00067 int ReleasePort(int refnum, jack_port_id_t port_index); 00068 void ActivatePort(jack_port_id_t port_index); 00069 void DeactivatePort(jack_port_id_t port_index); 00070 void GetInputPorts(int refnum, jack_int_t* res); 00071 void GetOutputPorts(int refnum, jack_int_t* res); 00072 void RemoveAllPorts(int refnum); 00073 void DisconnectAllPorts(int refnum); 00074 00075 JackPort* GetPort(jack_port_id_t index); 00076 jack_port_id_t GetPort(const char* name); 00077 int ComputeTotalLatency(jack_port_id_t port_index); 00078 int ComputeTotalLatencies(); 00079 int RequestMonitor(jack_port_id_t port_index, bool onoff); 00080 00081 // Connections management 00082 int Connect(jack_port_id_t src_index, jack_port_id_t dst_index); 00083 int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index); 00084 int IsConnected(jack_port_id_t port_src, jack_port_id_t port_dst); 00085 00086 // RT, client 00087 int GetConnectionsNum(jack_port_id_t port_index) 00088 { 00089 JackConnectionManager* manager = ReadCurrentState(); 00090 return manager->Connections(port_index); 00091 } 00092 00093 const char** GetConnections(jack_port_id_t port_index); 00094 void GetConnections(jack_port_id_t port_index, jack_int_t* connections); // TODO 00095 const char** GetPorts(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags); 00096 00097 int GetTwoPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index); 00098 int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst); 00099 00100 void DisconnectAllInput(jack_port_id_t port_index); 00101 void DisconnectAllOutput(jack_port_id_t port_index); 00102 int DisconnectAll(jack_port_id_t port_index); 00103 00104 bool IsDirectConnection(int ref1, int ref2); 00105 void DirectConnect(int ref1, int ref2); 00106 void DirectDisconnect(int ref1, int ref2); 00107 00108 void Activate(int refnum); 00109 void Deactivate(int refnum); 00110 00111 int GetInputRefNum(jack_port_id_t port_index); 00112 int GetOutputRefNum(jack_port_id_t port_index); 00113 00114 // Buffer management 00115 void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames); 00116 00117 // Activation management 00118 void RunCurrentGraph(); 00119 bool RunNextGraph(); 00120 bool IsFinishedGraph(); 00121 00122 void InitRefNum(int refnum); 00123 int ResumeRefNum(JackClientControl* control, JackSynchro* table); 00124 int SuspendRefNum(JackClientControl* control, JackSynchro* table, long usecs); 00125 00126 JackClientTiming* GetClientTiming(int refnum) 00127 { 00128 return &fClientTiming[refnum]; 00129 } 00130 00131 void Save(JackConnectionManager* dst); 00132 void Restore(JackConnectionManager* src); 00133 00134 static JackGraphManager* Allocate(int port_max); 00135 static void Destroy(JackGraphManager* manager); 00136 00137 } POST_PACKED_STRUCTURE; 00138 00139 00140 } // end of namespace 00141 00142 #endif 00143