2008-06-13 11:41:44 +03:00
|
|
|
/*
|
2011-07-24 15:53:59 +03:00
|
|
|
Copyright (C) 2008-2011 Romain Moret at Grame
|
2008-06-13 11:41:44 +03:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
2008-06-04 16:34:25 +03:00
|
|
|
|
2008-07-18 11:01:40 +03:00
|
|
|
#ifndef __JACKNETMANAGER_H__
|
|
|
|
#define __JACKNETMANAGER_H__
|
2008-06-04 16:34:25 +03:00
|
|
|
|
2008-08-05 17:06:37 +03:00
|
|
|
#include "JackNetInterface.h"
|
2008-07-10 12:16:32 +03:00
|
|
|
#include "jack.h"
|
2008-06-11 12:51:50 +03:00
|
|
|
#include <list>
|
2013-05-13 10:33:50 +03:00
|
|
|
#include <map>
|
2008-06-04 16:34:25 +03:00
|
|
|
|
|
|
|
namespace Jack
|
|
|
|
{
|
2008-07-10 12:16:32 +03:00
|
|
|
class JackNetMasterManager;
|
|
|
|
|
2008-08-05 19:05:03 +03:00
|
|
|
/**
|
|
|
|
\Brief This class describes a Net Master
|
|
|
|
*/
|
2019-01-21 00:14:23 +02:00
|
|
|
|
2013-05-13 10:33:50 +03:00
|
|
|
typedef std::list<std::pair<std::string, std::string> > connections_list_t;
|
2008-07-28 19:31:39 +03:00
|
|
|
|
2008-08-05 17:06:37 +03:00
|
|
|
class JackNetMaster : public JackNetMasterInterface
|
2008-07-10 12:16:32 +03:00
|
|
|
{
|
2008-08-05 19:05:03 +03:00
|
|
|
friend class JackNetMasterManager;
|
2011-04-02 13:21:31 +03:00
|
|
|
|
|
|
|
private:
|
2019-01-21 00:14:23 +02:00
|
|
|
|
2011-07-26 13:16:30 +03:00
|
|
|
static int SetProcess(jack_nframes_t nframes, void* arg);
|
|
|
|
static int SetBufferSize(jack_nframes_t nframes, void* arg);
|
2013-05-09 17:06:29 +03:00
|
|
|
static int SetSampleRate(jack_nframes_t nframes, void* arg);
|
2011-07-26 13:16:30 +03:00
|
|
|
static void SetTimebaseCallback(jack_transport_state_t state, jack_nframes_t nframes, jack_position_t* pos, int new_pos, void* arg);
|
2012-02-01 13:16:25 +02:00
|
|
|
static void SetConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect, void* arg);
|
2013-03-04 17:19:20 +02:00
|
|
|
static void LatencyCallback(jack_latency_callback_mode_t mode, void* arg);
|
2008-07-24 11:20:57 +03:00
|
|
|
|
|
|
|
//jack client
|
2012-01-19 15:27:55 +02:00
|
|
|
jack_client_t* fClient;
|
|
|
|
const char* fName;
|
2008-07-24 11:20:57 +03:00
|
|
|
|
|
|
|
//jack ports
|
|
|
|
jack_port_t** fAudioCapturePorts;
|
|
|
|
jack_port_t** fAudioPlaybackPorts;
|
|
|
|
jack_port_t** fMidiCapturePorts;
|
|
|
|
jack_port_t** fMidiPlaybackPorts;
|
|
|
|
|
|
|
|
//sync and transport
|
2008-08-26 16:25:23 +03:00
|
|
|
int fLastTransportState;
|
2019-01-21 00:14:23 +02:00
|
|
|
|
2008-07-24 11:20:57 +03:00
|
|
|
//monitoring
|
2008-07-22 15:57:07 +03:00
|
|
|
#ifdef JACK_MONITOR
|
2008-07-24 11:20:57 +03:00
|
|
|
jack_time_t fPeriodUsecs;
|
2008-08-01 17:31:40 +03:00
|
|
|
JackGnuPlotMonitor<float>* fNetTimeMon;
|
2008-07-22 14:44:30 +03:00
|
|
|
#endif
|
|
|
|
|
2009-03-05 17:17:15 +02:00
|
|
|
bool Init(bool auto_connect);
|
2008-08-05 17:06:37 +03:00
|
|
|
int AllocPorts();
|
2008-07-24 11:20:57 +03:00
|
|
|
void FreePorts();
|
2011-03-04 14:01:48 +02:00
|
|
|
|
2008-08-25 18:55:14 +03:00
|
|
|
//transport
|
2009-03-04 12:13:29 +02:00
|
|
|
void EncodeTransportData();
|
|
|
|
void DecodeTransportData();
|
2008-08-25 18:55:14 +03:00
|
|
|
|
2008-07-24 11:20:57 +03:00
|
|
|
int Process();
|
2011-07-27 08:03:53 +03:00
|
|
|
void TimebaseCallback(jack_position_t* pos);
|
2009-03-05 17:17:15 +02:00
|
|
|
void ConnectPorts();
|
2012-02-01 13:16:25 +02:00
|
|
|
void ConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect);
|
2019-01-21 00:14:23 +02:00
|
|
|
|
2013-05-13 10:33:50 +03:00
|
|
|
void SaveConnections(connections_list_t& connections);
|
|
|
|
void LoadConnections(const connections_list_t& connections);
|
2008-08-25 18:55:14 +03:00
|
|
|
|
2008-07-24 11:20:57 +03:00
|
|
|
public:
|
2011-04-02 14:10:07 +03:00
|
|
|
|
2011-07-27 08:03:53 +03:00
|
|
|
JackNetMaster(JackNetSocket& socket, session_params_t& params, const char* multicast_ip);
|
|
|
|
~JackNetMaster();
|
2008-08-25 18:55:14 +03:00
|
|
|
|
|
|
|
bool IsSlaveReadyToRoll();
|
2008-07-10 12:16:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::list<JackNetMaster*> master_list_t;
|
|
|
|
typedef master_list_t::iterator master_list_it_t;
|
2013-05-13 10:33:50 +03:00
|
|
|
typedef std::map <std::string, connections_list_t> master_connections_list_t;
|
2008-07-10 12:16:32 +03:00
|
|
|
|
2008-08-05 19:05:03 +03:00
|
|
|
/**
|
|
|
|
\Brief This class describer the Network Manager
|
|
|
|
*/
|
2008-07-28 19:31:39 +03:00
|
|
|
|
2008-07-10 12:16:32 +03:00
|
|
|
class JackNetMasterManager
|
|
|
|
{
|
2008-07-24 11:20:57 +03:00
|
|
|
friend class JackNetMaster;
|
2011-04-02 13:21:31 +03:00
|
|
|
|
2008-07-24 11:20:57 +03:00
|
|
|
private:
|
2011-04-02 13:21:31 +03:00
|
|
|
|
2012-01-24 18:33:31 +02:00
|
|
|
static void SetShutDown(void* arg);
|
2011-07-27 08:03:53 +03:00
|
|
|
static int SetSyncCallback(jack_transport_state_t state, jack_position_t* pos, void* arg);
|
|
|
|
static void* NetManagerThread(void* arg);
|
2008-07-24 11:20:57 +03:00
|
|
|
|
2012-01-19 15:27:55 +02:00
|
|
|
jack_client_t* fClient;
|
|
|
|
const char* fName;
|
2009-02-20 16:40:56 +02:00
|
|
|
char fMulticastIP[32];
|
2008-07-24 11:20:57 +03:00
|
|
|
JackNetSocket fSocket;
|
2012-01-19 15:27:55 +02:00
|
|
|
jack_native_thread_t fThread;
|
2008-07-24 11:20:57 +03:00
|
|
|
master_list_t fMasterList;
|
2013-05-13 10:33:50 +03:00
|
|
|
master_connections_list_t fMasterConnectionList;
|
2008-07-24 11:20:57 +03:00
|
|
|
uint32_t fGlobalID;
|
|
|
|
bool fRunning;
|
2009-03-05 17:17:15 +02:00
|
|
|
bool fAutoConnect;
|
2013-05-13 10:33:50 +03:00
|
|
|
bool fAutoSave;
|
2008-07-24 11:20:57 +03:00
|
|
|
|
|
|
|
void Run();
|
2011-07-27 08:03:53 +03:00
|
|
|
JackNetMaster* InitMaster(session_params_t& params);
|
|
|
|
master_list_it_t FindMaster(uint32_t client_id);
|
|
|
|
int KillMaster(session_params_t* params);
|
|
|
|
int SyncCallback(jack_transport_state_t state, jack_position_t* pos);
|
2013-05-09 17:06:29 +03:00
|
|
|
int CountIO(const char* type, int flags);
|
2012-01-24 18:33:31 +02:00
|
|
|
void ShutDown();
|
2011-04-02 13:21:31 +03:00
|
|
|
|
2008-07-24 11:20:57 +03:00
|
|
|
public:
|
2011-04-02 13:21:31 +03:00
|
|
|
|
2011-07-27 08:03:53 +03:00
|
|
|
JackNetMasterManager(jack_client_t* jack_client, const JSList* params);
|
2008-07-24 11:20:57 +03:00
|
|
|
~JackNetMasterManager();
|
2008-07-10 12:16:32 +03:00
|
|
|
};
|
2008-06-04 16:34:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|