Browse Source

Fix NetDriver.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2780 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
moret 16 years ago
parent
commit
c395c90ff8
5 changed files with 55 additions and 41 deletions
  1. +24
    -31
      common/JackNetDriver.cpp
  2. +0
    -3
      common/JackNetDriver.h
  3. +5
    -5
      common/JackNetInterface.cpp
  4. +12
    -1
      common/JackNetManager.cpp
  5. +14
    -1
      common/JackNetTool.cpp

+ 24
- 31
common/JackNetDriver.cpp View File

@@ -49,7 +49,6 @@ namespace Jack
fParams.fNetworkMode = network_mode;
#ifdef JACK_MONITOR
fNetTimeMon = NULL;
fCycleTimeMon = NULL;
#endif
}

@@ -59,7 +58,6 @@ namespace Jack
delete[] fMidiPlaybackPortList;
#ifdef JACK_MONITOR
delete fNetTimeMon;
delete fCycleTimeMon;
#endif
}

@@ -83,8 +81,6 @@ namespace Jack
{
if ( fNetTimeMon )
fNetTimeMon->Save();
if ( fCycleTimeMon )
fCycleTimeMon->Save();
return JackDriver::Close();
}
#endif
@@ -150,7 +146,18 @@ namespace Jack
plot_name = string ( fParams.fName );
plot_name += string ( "_slave" );
plot_name += ( fEngineControl->fSyncMode ) ? string ( "_sync" ) : string ( "_async" );
plot_name += ( fParams.fNetworkMode == 'f' ) ? string ( "_fast" ) : string ( "_normal" );
switch ( fParams.fNetworkMode )
{
case 's' :
plot_name += string ( "_slow" );
break;
case 'n' :
plot_name += string ( "_normal" );
break;
case 'f' :
plot_name += string ( "_fast" );
break;
}
fNetTimeMon = new JackGnuPlotMonitor<float> ( 128, 4, plot_name );
string net_time_mon_fields[] =
{
@@ -165,21 +172,6 @@ namespace Jack
string ( "set ylabel \"% of audio cycle\"" )
};
fNetTimeMon->SetPlotFile ( net_time_mon_options, 2, net_time_mon_fields, 4 );
//CycleTimeMon
plot_name.clear();
plot_name = string ( fParams.fName );
plot_name += string ( "_slave_cycle_duration" );
plot_name += ( fEngineControl->fSyncMode ) ? string ( "_sync" ) : string ( "_async" );
plot_name += ( fParams.fNetworkMode == 'f' ) ? string ( "_fast" ) : string ( "_normal" );
fCycleTimeMon = new JackGnuPlotMonitor<jack_time_t> ( 2048, 1, plot_name );
string cycle_time_mon_field = string ( "cycle duration" );
string cycle_time_mon_options[] =
{
string ( "set xlabel \"audio cycles\"" ),
string ( "set ylabel \"usecs\"" )
};
fCycleTimeMon->SetPlotFile ( cycle_time_mon_options, 2, &cycle_time_mon_field, 1 );
fLastCycleBeginDate = GetMicroSeconds();
#endif

return true;
@@ -209,8 +201,6 @@ namespace Jack
#ifdef JACK_MONITOR
delete fNetTimeMon;
fNetTimeMon = NULL;
delete fCycleTimeMon;
fCycleTimeMon = NULL;
#endif
}

@@ -360,12 +350,6 @@ namespace Jack
//take the time at the beginning of the cycle
JackDriver::CycleTakeBeginTime();

#ifdef JACK_MONITOR
fCycleTimeMon->AddNew ( JackDriver::fBeginDateUst - fLastCycleBeginDate );
fCycleTimeMon->Write();
fLastCycleBeginDate = JackDriver::fBeginDateUst;
#endif

//audio, midi or sync if driver is late
if ( DataRecv() == SOCKET_ERROR )
return SOCKET_ERROR;
@@ -503,8 +487,8 @@ namespace Jack
i++;
strcpy ( desc->params[i].name, "mode" );
desc->params[i].character = 'm';
desc->params[i].type = JackDriverParamChar;
desc->params[i].value.c = 'n';
desc->params[i].type = JackDriverParamString;
strcpy ( desc->params[i].value.str, "normal" );
strcpy ( desc->params[i].short_desc, "Fast (0 latency), Normal (1 cycle latency) or Slow (2 cycles latency)." );
strcpy ( desc->params[i].long_desc, desc->params[i].short_desc );

@@ -513,6 +497,8 @@ namespace Jack

EXPORT Jack::JackDriverClientInterface* driver_initialize ( Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params )
{
jack_log ( "driver_initialize : net" );

if ( SocketAPIInit() < 0 )
{
jack_error ( "Can't init Socket API, exiting..." );
@@ -568,11 +554,18 @@ namespace Jack
transport_sync = param->value.ui;
break;
case 'm' :
network_mode = param->value.c;
if ( strcmp ( param->value.str, "slow" ) == 0 )
network_mode = 's';
else if ( strcmp ( param->value.str, "normal" ) == 0 )
network_mode = 'n';
else if ( strcmp ( param->value.str, "fast" ) == 0 )
network_mode = 'f';
break;
}
}

jack_info ( "mode : %c", network_mode );

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, name, transport_sync, network_mode ) );


+ 0
- 3
common/JackNetDriver.h View File

@@ -46,9 +46,6 @@ namespace Jack
#ifdef JACK_MONITOR
//time measurment
JackGnuPlotMonitor<float>* fNetTimeMon;
//cycle time measurment
jack_time_t fLastCycleBeginDate;
JackGnuPlotMonitor<jack_time_t>* fCycleTimeMon;
#endif

bool Init();


+ 5
- 5
common/JackNetInterface.cpp View File

@@ -311,11 +311,11 @@ namespace Jack
switch ( fParams.fNetworkMode )
{
case 's' :
//slow mode : allow to use full bandwidth
// - extra latency is set to two cycles, what is the time needed to send and receive streams using full network bandwidth
// - if the network is two fast, just wait the next cycle, this mode allows the shortest cycle duration for the master
// - this mode will skip the two first cycles, thus it lets time for data to be queued on the socket rx buffer
//the slow mode is the safest mode because it wait twice the bandwidth relative time (send and return)
//slow mode : allow to use full bandwidth and heavy process on the slave
// - extra latency is set to two cycles, one cycle for send/receive operations + one cycle for heavy process on the slave
// - if the network is two fast, just wait the next cycle, this mode allows a shorter cycle duration for the master
// - this mode will skip the two first cycles, thus it lets time for data to be processed and queued on the socket rx buffer
//the slow mode is the safest mode because it wait twice the bandwidth relative time (send/return + process)
if ( cycle_offset < 2 )
return 0;
else


+ 12
- 1
common/JackNetManager.cpp View File

@@ -67,7 +67,18 @@ namespace Jack
plot_name = string ( fParams.fName );
plot_name += string ( "_master" );
plot_name += string ( ( fParams.fSlaveSyncMode ) ? "_sync" : "_async" );
plot_name += ( fParams.fNetworkMode == 'f' ) ? string ( "_fast" ) : string ( "_normal" );
switch ( fParams.fNetworkMode )
{
case 's' :
plot_name += string ( "_slow" );
break;
case 'n' :
plot_name += string ( "_normal" );
break;
case 'f' :
plot_name += string ( "_fast" );
break;
}
fNetTimeMon = new JackGnuPlotMonitor<float> ( 128, 4, plot_name );
string net_time_mon_fields[] =
{


+ 14
- 1
common/JackNetTool.cpp View File

@@ -202,6 +202,19 @@ namespace Jack
{
char bitdepth[16];
( params->fBitdepth ) ? sprintf ( bitdepth, "%u", params->fBitdepth ) : sprintf ( bitdepth, "%s", "float" );
char mode[8];
switch ( params->fNetworkMode )
{
case 's' :
strcpy ( mode, "slow" );
break;
case 'n' :
strcpy ( mode, "normal" );
break;
case 'f' :
strcpy ( mode, "fast" );
break;
}
jack_info ( "**************** Network parameters ****************" );
jack_info ( "Name : %s", params->fName );
jack_info ( "Protocol revision : %c", params->fProtocolVersion );
@@ -218,7 +231,7 @@ namespace Jack
jack_info ( "Packet per period : %u", params->fPeriodSize / params->fFramesPerPacket );
jack_info ( "Bitdepth : %s", bitdepth );
jack_info ( "Slave mode : %s", ( params->fSlaveSyncMode ) ? "sync" : "async" );
jack_info ( "Network mode : %s", ( params->fNetworkMode == 'f' ) ? "fast" : "normal" );
jack_info ( "Network mode : %s", mode );
jack_info ( "****************************************************" );
}



Loading…
Cancel
Save