Jack2: JackNetManager.h Source File

Jack2 1.9.12

JackNetManager.h
1 /*
2 Copyright (C) 2008-2011 Romain Moret at Grame
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __JACKNETMANAGER_H__
21 #define __JACKNETMANAGER_H__
22
23 #include "JackNetInterface.h"
24 #include "jack.h"
25 #include <list>
26 #include <map>
27
28 namespace Jack
29 {
30 class JackNetMasterManager;
31
36 typedef std::list<std::pair<std::string, std::string> > connections_list_t;
37
38 class JackNetMaster : public JackNetMasterInterface
39 {
40 friend class JackNetMasterManager;
41
42 private:
43
44 static int SetProcess(jack_nframes_t nframes, void* arg);
45 static int SetBufferSize(jack_nframes_t nframes, void* arg);
46 static int SetSampleRate(jack_nframes_t nframes, void* arg);
47 static void SetTimebaseCallback(jack_transport_state_t state, jack_nframes_t nframes, jack_position_t* pos, int new_pos, void* arg);
48 static void SetConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect, void* arg);
49 static void LatencyCallback(jack_latency_callback_mode_t mode, void* arg);
50
51 //jack client
52 jack_client_t* fClient;
53 const char* fName;
54
55 //jack ports
56 jack_port_t** fAudioCapturePorts;
57 jack_port_t** fAudioPlaybackPorts;
58 jack_port_t** fMidiCapturePorts;
59 jack_port_t** fMidiPlaybackPorts;
60
61 //sync and transport
62 int fLastTransportState;
63
64 //monitoring
65 #ifdef JACK_MONITOR
66 jack_time_t fPeriodUsecs;
67 JackGnuPlotMonitor<float>* fNetTimeMon;
68 #endif
69
70 bool Init(bool auto_connect);
71 int AllocPorts();
72 void FreePorts();
73
74 //transport
75 void EncodeTransportData();
76 void DecodeTransportData();
77
78 int Process();
79 void TimebaseCallback(jack_position_t* pos);
80 void ConnectPorts();
81 void ConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect);
82
83 void SaveConnections(connections_list_t& connections);
84 void LoadConnections(const connections_list_t& connections);
85
86 public:
87
88 JackNetMaster(JackNetSocket& socket, session_params_t& params, const char* multicast_ip);
89 ~JackNetMaster();
90
91 bool IsSlaveReadyToRoll();
92 };
93
94 typedef std::list<JackNetMaster*> master_list_t;
95 typedef master_list_t::iterator master_list_it_t;
96 typedef std::map <std::string, connections_list_t> master_connections_list_t;
97
102 class JackNetMasterManager
103 {
104 friend class JackNetMaster;
105
106 private:
107
108 static void SetShutDown(void* arg);
109 static int SetSyncCallback(jack_transport_state_t state, jack_position_t* pos, void* arg);
110 static void* NetManagerThread(void* arg);
111
112 jack_client_t* fClient;
113 const char* fName;
114 char fMulticastIP[32];
115 JackNetSocket fSocket;
116 jack_native_thread_t fThread;
117 master_list_t fMasterList;
118 master_connections_list_t fMasterConnectionList;
119 uint32_t fGlobalID;
120 bool fRunning;
121 bool fAutoConnect;
122 bool fAutoSave;
123
124 void Run();
125 JackNetMaster* InitMaster(session_params_t& params);
126 master_list_it_t FindMaster(uint32_t client_id);
127 int KillMaster(session_params_t* params);
128 int SyncCallback(jack_transport_state_t state, jack_position_t* pos);
129 int CountIO(const char* type, int flags);
130 void ShutDown();
131
132 public:
133
134 JackNetMasterManager(jack_client_t* jack_client, const JSList* params);
135 ~JackNetMasterManager();
136 };
137 }
138
139 #endif
_jack_position
Definition: types.h:554
Jack
Definition: JackAC3Encoder.cpp:30
Jack::JackNetMaster
Definition: JackNetManager.h:38
Jack::JackNetUnixSocket
Definition: JackNetUnixSocket.h:40
Jack::JackNetMasterInterface
Definition: JackNetInterface.h:143
Jack::JackGnuPlotMonitor
Generic monitoring class. Saves data to GnuPlot files (&#39;.plt&#39; and &#39;.log&#39; datafile) ...
Definition: JackTools.h:101
_JSList
Definition: linux/alsa/jslist.h:35
Jack::_session_params
This structure containes master/slave connection parameters, it&#39;s used to setup the whole system...
Definition: JackNetTool.h:91
Jack::JackNetMasterManager
Definition: JackNetManager.h:102