diff --git a/common/JackNetDriver.cpp b/common/JackNetDriver.cpp index df78e17b..7252cd7f 100644 --- a/common/JackNetDriver.cpp +++ b/common/JackNetDriver.cpp @@ -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 ( 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 ( 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 ) ); diff --git a/common/JackNetDriver.h b/common/JackNetDriver.h index a6fdcb6e..bcede81b 100644 --- a/common/JackNetDriver.h +++ b/common/JackNetDriver.h @@ -46,9 +46,6 @@ namespace Jack #ifdef JACK_MONITOR //time measurment JackGnuPlotMonitor* fNetTimeMon; - //cycle time measurment - jack_time_t fLastCycleBeginDate; - JackGnuPlotMonitor* fCycleTimeMon; #endif bool Init(); diff --git a/common/JackNetInterface.cpp b/common/JackNetInterface.cpp index f6ed10ec..d63b497c 100644 --- a/common/JackNetInterface.cpp +++ b/common/JackNetInterface.cpp @@ -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 diff --git a/common/JackNetManager.cpp b/common/JackNetManager.cpp index b1af3e08..374ea47c 100644 --- a/common/JackNetManager.cpp +++ b/common/JackNetManager.cpp @@ -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 ( 128, 4, plot_name ); string net_time_mon_fields[] = { diff --git a/common/JackNetTool.cpp b/common/JackNetTool.cpp index bf228efc..c86f41ec 100644 --- a/common/JackNetTool.cpp +++ b/common/JackNetTool.cpp @@ -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 ( "****************************************************" ); }