git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2517 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.90
@@ -1,6 +1,6 @@ | |||
/* | |||
Copyright (C) 2001 Paul Davis | |||
Copyright (C) 2004-2008 Grame | |||
Copyright (C) 2008 Grame | |||
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 | |||
@@ -35,12 +35,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
namespace Jack | |||
{ | |||
JackNetDriver::JackNetDriver ( const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, | |||
const char* ip, int port, int midi_input_ports, int midi_output_ports, const char* net_name ) | |||
const char* ip, int port, int mtu, int midi_input_ports, int midi_output_ports, const char* net_name ) | |||
: JackAudioDriver ( name, alias, engine, table ) | |||
{ | |||
fMulticastIP = new char[strlen ( ip ) + 1]; | |||
strcpy ( fMulticastIP, ip ); | |||
fUDPPort = port; | |||
fParams.fMtu = mtu; | |||
fParams.fSendMidiChannels = midi_input_ports; | |||
fParams.fReturnMidiChannels = midi_output_ports; | |||
strcpy ( fParams.fName, net_name ); | |||
@@ -574,7 +575,7 @@ namespace Jack | |||
{ | |||
jack_driver_desc_t* desc = ( jack_driver_desc_t* ) calloc ( 1, sizeof ( jack_driver_desc_t ) ); | |||
strcpy ( desc->name, "net" ); | |||
desc->nparams = 7; | |||
desc->nparams = 8; | |||
desc->params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) ); | |||
int i = 0; | |||
@@ -593,6 +594,14 @@ namespace Jack | |||
strcpy ( desc->params[i].short_desc, "UDP port" ); | |||
strcpy ( desc->params[i].long_desc, desc->params[i].short_desc ); | |||
i++; | |||
strcpy ( desc->params[i].name, "mtu" ); | |||
desc->params[i].character = 'M'; | |||
desc->params[i].type = JackDriverParamInt; | |||
desc->params[i].value.i = 1500; | |||
strcpy ( desc->params[i].short_desc, "MTU to the master" ); | |||
strcpy ( desc->params[i].long_desc, desc->params[i].short_desc ); | |||
i++; | |||
strcpy ( desc->params[i].name, "input_ports" ); | |||
desc->params[i].character = 'C'; | |||
@@ -642,6 +651,7 @@ namespace Jack | |||
char name[JACK_CLIENT_NAME_SIZE]; | |||
gethostname ( name, JACK_CLIENT_NAME_SIZE ); | |||
int udp_port = DEFAULT_PORT; | |||
int mtu = 1500; | |||
jack_nframes_t period_size = 128; | |||
jack_nframes_t sample_rate = 48000; | |||
int audio_capture_ports = 2; | |||
@@ -663,6 +673,9 @@ namespace Jack | |||
case 'p': | |||
udp_port = param->value.ui; | |||
break; | |||
case 'M': | |||
mtu = param->value.i; | |||
break; | |||
case 'C': | |||
audio_capture_ports = param->value.i; | |||
break; | |||
@@ -681,7 +694,7 @@ namespace Jack | |||
} | |||
Jack::JackDriverClientInterface* driver = new Jack::JackWaitThreadedDriver ( | |||
new Jack::JackNetDriver ( "system", "net_pcm", engine, table, multicast_ip, udp_port, midi_input_ports, midi_output_ports, name ) ); | |||
new Jack::JackNetDriver ( "system", "net_pcm", engine, table, multicast_ip, udp_port, mtu, midi_input_ports, midi_output_ports, name ) ); | |||
if ( driver->Open ( period_size, sample_rate, 1, 1, audio_capture_ports, audio_playback_ports, | |||
monitor, "from_master_", "to_master_", 0, 0 ) == 0 ) | |||
return driver; | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
Copyright (C) 2001 Paul Davis | |||
Copyright (C) 2004-2008 Grame | |||
Copyright (C) 2008 Grame | |||
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 | |||
@@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
namespace Jack | |||
{ | |||
class JackNetDriver : public JackAudioDriver | |||
{ | |||
private: | |||
@@ -72,7 +71,7 @@ namespace Jack | |||
public: | |||
JackNetDriver ( const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, | |||
const char* ip, int port, int midi_input_ports, int midi_output_ports, const char* master_name ); | |||
const char* ip, int port, int mtu, int midi_input_ports, int midi_output_ports, const char* master_name ); | |||
~JackNetDriver(); | |||
int Open ( jack_nframes_t frames_per_cycle, jack_nframes_t rate, bool capturing, bool playing, | |||
@@ -1,22 +1,21 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2008 by Romain Moret * | |||
* moret@grame.fr * | |||
* * | |||
* 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., * | |||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | |||
***************************************************************************/ | |||
/* | |||
Copyright (C) 2008 Grame | |||
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. | |||
*/ | |||
#include "JackNetManager.h" | |||
#include "JackError.h" | |||
@@ -591,7 +590,6 @@ namespace Jack | |||
jack_log ( "JackNetMasterManager::MasterInit, Slave : %s", params.fName ); | |||
//settings | |||
gethostname ( params.fMasterNetName, 255 ); | |||
params.fMtu = 1500; | |||
params.fID = ++fGlobalID; | |||
params.fSampleRate = jack_get_sample_rate ( fManagerClient ); | |||
params.fPeriodSize = jack_get_buffer_size ( fManagerClient ); | |||
@@ -1,22 +1,21 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2008 by Romain Moret * | |||
* moret@grame.fr * | |||
* * | |||
* 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., * | |||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | |||
***************************************************************************/ | |||
/* | |||
Copyright (C) 2008 Grame | |||
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. | |||
*/ | |||
#ifndef __JACKNETMASTER_H__ | |||
#define __JACKNETMASTER_H__ | |||
@@ -1,3 +1,21 @@ | |||
/* | |||
Copyright (C) 2008 Grame | |||
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. | |||
*/ | |||
#include "JackNetTool.h" | |||
#include "JackError.h" | |||
@@ -38,8 +56,8 @@ namespace Jack | |||
for ( uint event = 0; event < fPortBuffer[port_index]->event_count; event++ ) | |||
if ( fPortBuffer[port_index]->IsValid() ) | |||
jack_info ( "port %d : midi event %u/%u -> time : %u, size : %u", | |||
port_index + 1, event + 1, fPortBuffer[port_index]->event_count, | |||
fPortBuffer[port_index]->events[event].time, fPortBuffer[port_index]->events[event].size ); | |||
port_index + 1, event + 1, fPortBuffer[port_index]->event_count, | |||
fPortBuffer[port_index]->events[event].time, fPortBuffer[port_index]->events[event].size ); | |||
} | |||
} | |||
@@ -53,7 +71,7 @@ namespace Jack | |||
memcpy ( fBuffer + pos, fPortBuffer[port_index], copy_size ); | |||
pos += copy_size; | |||
memcpy ( fBuffer + pos, fPortBuffer[port_index] + ( fPortBuffer[port_index]->buffer_size - fPortBuffer[port_index]->write_pos ), | |||
fPortBuffer[port_index]->write_pos ); | |||
fPortBuffer[port_index]->write_pos ); | |||
pos += fPortBuffer[port_index]->write_pos; | |||
} | |||
return pos; | |||
@@ -65,11 +83,11 @@ namespace Jack | |||
int copy_size; | |||
for ( int port_index = 0; port_index < fNPorts; port_index++ ) | |||
{ | |||
copy_size = sizeof ( JackMidiBuffer ) + reinterpret_cast<JackMidiBuffer*>(fBuffer + pos)->event_count * sizeof ( JackMidiEvent ); | |||
copy_size = sizeof ( JackMidiBuffer ) + reinterpret_cast<JackMidiBuffer*> ( fBuffer + pos )->event_count * sizeof ( JackMidiEvent ); | |||
memcpy ( fPortBuffer[port_index], fBuffer + pos, copy_size ); | |||
pos += copy_size; | |||
memcpy ( fPortBuffer[port_index] + ( fPortBuffer[port_index]->buffer_size - fPortBuffer[port_index]->write_pos ), | |||
fBuffer + pos, fPortBuffer[port_index]->write_pos ); | |||
fBuffer + pos, fPortBuffer[port_index]->write_pos ); | |||
pos += fPortBuffer[port_index]->write_pos; | |||
} | |||
return pos; | |||
@@ -262,7 +280,7 @@ namespace Jack | |||
if ( !params->fSendAudioChannels && !params->fReturnAudioChannels ) | |||
return ( params->fFramesPerPacket = params->fPeriodSize ); | |||
size_t period = ( int ) powf ( 2.f, ( int ) log2 ( ( params->fMtu - sizeof ( packet_header_t ) ) | |||
/ ( max ( params->fReturnAudioChannels, params->fSendAudioChannels ) * sizeof ( sample_t ) ) ) ); | |||
/ ( max ( params->fReturnAudioChannels, params->fSendAudioChannels ) * sizeof ( sample_t ) ) ) ); | |||
( period > params->fPeriodSize ) ? params->fFramesPerPacket = params->fPeriodSize : params->fFramesPerPacket = period; | |||
return params->fFramesPerPacket; | |||
} | |||
@@ -1,3 +1,21 @@ | |||
/* | |||
Copyright (C) 2008 Grame | |||
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. | |||
*/ | |||
#include "types.h" | |||
#include "JackConstants.h" | |||
@@ -22,7 +40,6 @@ namespace Jack | |||
{ | |||
typedef struct _session_params session_params_t; | |||
typedef struct _packet_header packet_header_t; | |||
typedef struct _midi_portbuf_desc midi_portbuf_desc_t; | |||
typedef struct sockaddr socket_address_t; | |||
typedef struct in_addr address_t; | |||
typedef jack_default_audio_sample_t sample_t; | |||
@@ -99,6 +116,9 @@ namespace Jack | |||
char fFree[13]; //unused | |||
}; | |||
#ifndef __NetMidiBuffer__ | |||
#define __NetMidiBuffer__ | |||
//midi data *********************************************************************************** | |||
class EXPORT NetMidiBuffer | |||
@@ -128,8 +148,13 @@ namespace Jack | |||
int RenderToNetwork ( int subcycle, size_t total_size ); | |||
}; | |||
#endif | |||
// audio data ********************************************************************************* | |||
#ifndef __NetAudioBuffer__ | |||
#define __NetAudioBuffer__ | |||
class EXPORT NetAudioBuffer | |||
{ | |||
private: | |||
@@ -150,6 +175,8 @@ namespace Jack | |||
void RenderToJackPorts ( int subcycle ); | |||
}; | |||
#endif | |||
//utility ************************************************************************************* | |||
//n<-->h functions | |||