00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 namespace Jack
00033 {
00034
00039 PRE_PACKED_STRUCTURE
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];
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 jack_default_audio_sample_t* 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 void RecalculateLatencyAux(jack_port_id_t port_index, jack_latency_callback_mode_t mode);
00057
00058 public:
00059
00060 JackGraphManager(int port_max);
00061 ~JackGraphManager()
00062 {}
00063
00064 void SetBufferSize(jack_nframes_t buffer_size);
00065
00066
00067 jack_port_id_t AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size);
00068 int ReleasePort(int refnum, jack_port_id_t port_index);
00069 void GetInputPorts(int refnum, jack_int_t* res);
00070 void GetOutputPorts(int refnum, jack_int_t* res);
00071 void RemoveAllPorts(int refnum);
00072 void DisconnectAllPorts(int refnum);
00073
00074 JackPort* GetPort(jack_port_id_t index);
00075 jack_port_id_t GetPort(const char* name);
00076
00077 int ComputeTotalLatency(jack_port_id_t port_index);
00078 int ComputeTotalLatencies();
00079 void RecalculateLatency(jack_port_id_t port_index, jack_latency_callback_mode_t mode);
00080
00081 int RequestMonitor(jack_port_id_t port_index, bool onoff);
00082
00083
00084 int Connect(jack_port_id_t src_index, jack_port_id_t dst_index);
00085 int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index);
00086 int IsConnected(jack_port_id_t port_src, jack_port_id_t port_dst);
00087
00088
00089 int GetConnectionsNum(jack_port_id_t port_index)
00090 {
00091 JackConnectionManager* manager = ReadCurrentState();
00092 return manager->Connections(port_index);
00093 }
00094
00095 const char** GetConnections(jack_port_id_t port_index);
00096 void GetConnections(jack_port_id_t port_index, jack_int_t* connections);
00097 const char** GetPorts(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
00098
00099 int GetTwoPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index);
00100 int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst);
00101
00102 void DisconnectAllInput(jack_port_id_t port_index);
00103 void DisconnectAllOutput(jack_port_id_t port_index);
00104 int DisconnectAll(jack_port_id_t port_index);
00105
00106 bool IsDirectConnection(int ref1, int ref2);
00107 void DirectConnect(int ref1, int ref2);
00108 void DirectDisconnect(int ref1, int ref2);
00109
00110 void Activate(int refnum);
00111 void Deactivate(int refnum);
00112
00113 int GetInputRefNum(jack_port_id_t port_index);
00114 int GetOutputRefNum(jack_port_id_t port_index);
00115
00116
00117 void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames);
00118
00119
00120 void RunCurrentGraph();
00121 bool RunNextGraph();
00122 bool IsFinishedGraph();
00123
00124 void InitRefNum(int refnum);
00125 int ResumeRefNum(JackClientControl* control, JackSynchro* table);
00126 int SuspendRefNum(JackClientControl* control, JackSynchro* table, long usecs);
00127 void TopologicalSort(std::vector<jack_int_t>& sorted);
00128
00129 JackClientTiming* GetClientTiming(int refnum)
00130 {
00131 return &fClientTiming[refnum];
00132 }
00133
00134 void Save(JackConnectionManager* dst);
00135 void Restore(JackConnectionManager* src);
00136
00137 static JackGraphManager* Allocate(int port_max);
00138 static void Destroy(JackGraphManager* manager);
00139
00140 } POST_PACKED_STRUCTURE;
00141
00142
00143 }
00144
00145 #endif
00146