Commit 3e9e0a12 authored by moret's avatar moret
Browse files

Fix profiling recording in NetXXX files.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2921 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 27db4a18
......@@ -37,8 +37,8 @@ namespace Jack
jack_log ( "JackNetDriver::JackNetDriver ip %s, port %d", ip, port );
// Use the hostname if no name parameter was given
if (strcmp(net_name, "") == 0)
GetHostName(net_name, JACK_CLIENT_NAME_SIZE);
if ( strcmp ( net_name, "" ) == 0 )
GetHostName ( net_name, JACK_CLIENT_NAME_SIZE );
fParams.fMtu = mtu;
fParams.fSendMidiChannels = midi_input_ports;
......@@ -70,23 +70,26 @@ namespace Jack
const char* capture_driver_name, const char* playback_driver_name,
jack_nframes_t capture_latency, jack_nframes_t playback_latency )
{
if (JackAudioDriver::Open(buffer_size,
samplerate,
capturing,
playing,
inchannels,
outchannels,
monitor,
capture_driver_name,
playback_driver_name,
capture_latency,
playback_latency ) == 0) {
if ( JackAudioDriver::Open ( buffer_size,
samplerate,
capturing,
playing,
inchannels,
outchannels,
monitor,
capture_driver_name,
playback_driver_name,
capture_latency,
playback_latency ) == 0 )
{
fEngineControl->fPeriod = 0;
fEngineControl->fComputation = 500 * 1000;
fEngineControl->fConstraint = 500 * 1000;
return 0;
} else {
return -1;
fEngineControl->fConstraint = 500 * 1000;
return 0;
}
else
{
return -1;
}
}
......@@ -194,8 +197,8 @@ namespace Jack
//allocate midi ports lists
fMidiCapturePortList = new jack_port_id_t [fParams.fSendMidiChannels];
fMidiPlaybackPortList = new jack_port_id_t [fParams.fReturnMidiChannels];
assert(fMidiCapturePortList);
assert(fMidiPlaybackPortList);
assert ( fMidiCapturePortList );
assert ( fMidiPlaybackPortList );
return true;
}
......@@ -573,8 +576,8 @@ namespace Jack
{
jack_driver_desc_t* desc = ( jack_driver_desc_t* ) calloc ( 1, sizeof ( jack_driver_desc_t ) );
strcpy(desc->name, "net"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy(desc->desc, "netjack slave backend component"); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
strcpy ( desc->name, "net" ); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy ( desc->desc, "netjack slave backend component" ); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
desc->nparams = 10;
desc->params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) );
......@@ -728,21 +731,27 @@ namespace Jack
}
}
try {
try
{
Jack::JackDriverClientInterface* driver =
new Jack::JackWaitThreadedDriver(
new Jack::JackNetDriver("system", "net_pcm", engine, table, multicast_ip, udp_port, mtu,
midi_input_ports, midi_output_ports, net_name, transport_sync, network_mode));
if (driver->Open (period_size, sample_rate, 1, 1, audio_capture_ports, audio_playback_ports,
monitor, "from_master_", "to_master_", 0, 0) == 0) {
new Jack::JackWaitThreadedDriver (
new Jack::JackNetDriver ( "system", "net_pcm", engine, table, multicast_ip, udp_port, mtu,
midi_input_ports, midi_output_ports, net_name, transport_sync, network_mode ) );
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;
} else {
}
else
{
delete driver;
return NULL;
}
} catch (...) {
}
catch ( ... )
{
return NULL;
}
}
......
......@@ -170,8 +170,8 @@ namespace Jack
//network buffers
fTxBuffer = new char[fParams.fMtu];
fRxBuffer = new char[fParams.fMtu];
assert(fTxBuffer);
assert(fRxBuffer);
assert ( fTxBuffer );
assert ( fRxBuffer );
//net audio/midi buffers'addresses
fTxData = fTxBuffer + sizeof ( packet_header_t );
......@@ -272,14 +272,14 @@ namespace Jack
//midi net buffers
fNetMidiCaptureBuffer = new NetMidiBuffer ( &fParams, fParams.fSendMidiChannels, fTxData );
fNetMidiPlaybackBuffer = new NetMidiBuffer ( &fParams, fParams.fReturnMidiChannels, fRxData );
assert(fNetMidiCaptureBuffer);
assert(fNetMidiPlaybackBuffer);
assert ( fNetMidiCaptureBuffer );
assert ( fNetMidiPlaybackBuffer );
//audio net buffers
fNetAudioCaptureBuffer = new NetAudioBuffer ( &fParams, fParams.fSendAudioChannels, fTxData );
fNetAudioPlaybackBuffer = new NetAudioBuffer ( &fParams, fParams.fReturnAudioChannels, fRxData );
assert(fNetAudioCaptureBuffer);
assert(fNetAudioPlaybackBuffer);
assert ( fNetAudioCaptureBuffer );
assert ( fNetAudioPlaybackBuffer );
//audio netbuffer length
fAudioTxLen = sizeof ( packet_header_t ) + fNetAudioPlaybackBuffer->GetSize();
......@@ -292,7 +292,7 @@ namespace Jack
//stop process
fRunning = false;
//send a 'multicast euthanasia request' - new socket is required on macosx
jack_info ( "Exiting '%s'", fParams.fName );
SetPacketType ( &fParams, KILL_MASTER );
......@@ -302,7 +302,7 @@ namespace Jack
if ( mcast_socket.SendTo ( &fParams, sizeof ( session_params_t ), 0, fMulticastIP ) == SOCKET_ERROR )
jack_error ( "Can't send suicide request : %s", StrError ( NET_ERROR_CODE ) );
mcast_socket.Close();
// UGLY temporary way to be sure the thread does not call code possibly causing a deadlock in JackEngine.
ThreadExit();
}
......@@ -423,7 +423,7 @@ namespace Jack
else
rx_bytes = Recv ( rx_head->fPacketSize, 0 );
break;
case 'n' :
//normal use of the network :
// - extra latency is set to one cycle, what is the time needed to receive streams using full network bandwidth
......@@ -434,7 +434,7 @@ namespace Jack
else
rx_bytes = Recv ( rx_head->fPacketSize, 0 );
break;
case 'f' :
//fast mode suppose the network bandwith is larger than required for the transmission (only a few channels for example)
// - packets can be quickly received, quickly is here relative to the cycle duration
......@@ -445,7 +445,7 @@ namespace Jack
jack_error ( "'%s' can't run in fast network mode, data received too late (%d cycle(s) offset)", fParams.fName, cycle_offset );
break;
}
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
return rx_bytes;
}
......@@ -484,7 +484,7 @@ namespace Jack
fNetMidiPlaybackBuffer->RenderToJackPorts();
jumpcnt = 0;
break;
case 'a': //audio
Recv ( rx_head->fPacketSize, 0 );
if ( !IsNextPacket() )
......@@ -495,7 +495,7 @@ namespace Jack
fNetAudioPlaybackBuffer->RenderToJackPorts ( rx_head->fSubCycle );
jumpcnt = 0;
break;
case 's': //sync
if ( rx_head->fCycle == fTxHeader.fCycle )
return 0;
......@@ -722,7 +722,7 @@ namespace Jack
if ( ++recvd_midi_pckt == rx_head->fNMidiPckt )
fNetMidiCaptureBuffer->RenderToJackPorts();
break;
case 'a': //audio
rx_bytes = Recv ( rx_head->fPacketSize, 0 );
if ( !IsNextPacket() )
......@@ -732,7 +732,7 @@ namespace Jack
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
fNetAudioCaptureBuffer->RenderToJackPorts ( rx_head->fSubCycle );
break;
case 's': //sync
jack_info ( "NetSlave : overloaded, skipping receive." );
return 0;
......
......@@ -21,6 +21,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef __JackNetInterface__
#define __JackNetInterface__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "JackNetTool.h"
namespace Jack
......@@ -148,8 +152,10 @@ namespace Jack
JackNetSlaveInterface() : JackNetInterface()
{
//open Socket API with the first slave
if (fSlaveCounter++ == 0) {
if (SocketAPIInit() < 0) {
if ( fSlaveCounter++ == 0 )
{
if ( SocketAPIInit() < 0 )
{
jack_error ( "Can't init Socket API, exiting..." );
throw -1;
}
......@@ -158,8 +164,10 @@ namespace Jack
JackNetSlaveInterface ( const char* ip, int port ) : JackNetInterface ( ip, port )
{
//open Socket API with the first slave
if (fSlaveCounter++ == 0) {
if (SocketAPIInit() < 0) {
if ( fSlaveCounter++ == 0 )
{
if ( SocketAPIInit() < 0 )
{
jack_error ( "Can't init Socket API, exiting..." );
throw -1;
}
......
......@@ -16,10 +16,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include "JackNetManager.h"
using namespace std;
......@@ -696,9 +692,9 @@ extern "C"
jack_driver_desc_t *desc;
desc = ( jack_driver_desc_t* ) calloc ( 1, sizeof ( jack_driver_desc_t ) );
strcpy(desc->name, "netmanager"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy(desc->desc, "netjack multi-cast master component"); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
strcpy ( desc->name, "netmanager" ); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy ( desc->desc, "netjack multi-cast master component" ); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
desc->nparams = 2;
desc->params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) );
......@@ -740,19 +736,20 @@ extern "C"
{
JSList* params = NULL;
jack_driver_desc_t* desc = jack_get_descriptor();
Jack::JackArgParser parser(load_init);
if (parser.GetArgc() > 0)
parser.ParseParams(desc, &params);
int res = jack_internal_initialize(jack_client, params);
parser.FreeParams(params);
Jack::JackArgParser parser ( load_init );
if ( parser.GetArgc() > 0 )
parser.ParseParams ( desc, &params );
int res = jack_internal_initialize ( jack_client, params );
parser.FreeParams ( params );
return res;
}
SERVER_EXPORT void jack_finish ( void* arg )
{
if (master_manager) {
if ( master_manager )
{
jack_log ( "Unloading Master Manager" );
delete master_manager;
master_manager = NULL;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment