Changeset 3954
- Timestamp:
- 03/10/10 12:33:09 (5 months ago)
- Files:
-
- jack2/branches/libjacknet/common/jack/net.h (modified) (1 diff)
- jack2/branches/libjacknet/common/JackNetAPI.cpp (modified) (5 diffs)
- jack2/branches/libjacknet/common/JackNetInterface.cpp (modified) (4 diffs)
- jack2/branches/libjacknet/common/JackNetInterface.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
jack2/branches/libjacknet/common/jack/net.h
r3953 r3954 50 50 int midi_output; // to master or from slave 51 51 int mtu; 52 int time_out; // in millisecond, -1 means in infinite52 int time_out; // in second, -1 means in infinite 53 53 char mode; 54 54 jack2/branches/libjacknet/common/JackNetAPI.cpp
r3953 r3954 47 47 int audio_output; 48 48 int midi_input; 49 int midi_ou put;49 int midi_output; 50 50 int mtu; 51 51 int time_out; // in millisecond, -1 means in infinite … … 231 231 result->audio_output = fParams.fReturnAudioChannels; 232 232 result->midi_input = fParams.fSendMidiChannels; 233 result->midi_ou put = fParams.fReturnMidiChannels;234 result->m idi_ouput= fParams.fMtu;233 result->midi_output = fParams.fReturnMidiChannels; 234 result->mtu = fParams.fMtu; 235 235 result->mode = fParams.fNetworkMode; 236 236 return 0; … … 426 426 JackMidiBuffer** fMidiPlaybackBuffer; 427 427 428 int fConnectTimeOut; 429 428 430 JackNetExtSlave(const char* ip, 429 431 int port, … … 449 451 fParams.fReturnAudioChannels = request->audio_output; 450 452 fParams.fSendMidiChannels = request->midi_input; 451 fParams.fReturnMidiChannels = request->midi_ou put;453 fParams.fReturnMidiChannels = request->midi_output; 452 454 fParams.fNetworkMode = request->mode; 453 455 fParams.fSlaveSyncMode = 1; 456 fConnectTimeOut = request->time_out; 454 457 455 458 // Create name with hostname and client name … … 469 472 { 470 473 // Init network connection 471 if (!JackNetSlaveInterface::InitConnection( ))474 if (!JackNetSlaveInterface::InitConnection(fConnectTimeOut)) 472 475 return -1; 473 476 jack2/branches/libjacknet/common/JackNetInterface.cpp
r3953 r3954 610 610 // Separate the connection protocol into two separated step 611 611 612 bool JackNetSlaveInterface::InitConnection() 613 { 614 jack_log ( "JackNetSlaveInterface::InitConnection()" ); 615 612 bool JackNetSlaveInterface::InitConnection(int time_out) 613 { 614 jack_log("JackNetSlaveInterface::InitConnection()"); 615 int try_count = (time_out > 0) ? ((1000000 * time_out) / SLAVE_INIT_TIMEOUT) : LONG_MAX; 616 616 617 //set the parameters to send 617 618 strcpy (fParams.fPacketType, "params"); … … 623 624 { 624 625 //get a master 625 status = SendAvailableToMaster( );626 status = SendAvailableToMaster(try_count); 626 627 if (status == NET_SOCKET_ERROR) 627 628 return false; 628 629 } 629 while (status != NET_CONNECTED );630 while (status != NET_CONNECTED && --try_count > 0); 630 631 631 return true;632 return (try_count != 0); 632 633 } 633 634 … … 650 651 } 651 652 652 net_status_t JackNetSlaveInterface::SendAvailableToMaster( )653 net_status_t JackNetSlaveInterface::SendAvailableToMaster(int count) 653 654 { 654 655 jack_log ( "JackNetSlaveInterface::SendAvailableToMaster()" ); … … 698 699 } 699 700 } 700 while ( strcmp ( host_params.fPacketType, fParams.fPacketType ) && ( GetPacketType ( &host_params ) != SLAVE_SETUP ) ); 701 while (strcmp(host_params.fPacketType, fParams.fPacketType) && (GetPacketType(&host_params) != SLAVE_SETUP) && (--count > 0)); 702 703 // Time out failure.. 704 if (count == 0) { 705 return NET_CONNECT_ERROR; 706 } 701 707 702 708 //everything is OK, copy parameters jack2/branches/libjacknet/common/JackNetInterface.h
r3950 r3954 146 146 147 147 bool Init(); 148 bool InitConnection( );148 bool InitConnection(int time_out); 149 149 bool InitRendering(); 150 150 151 net_status_t SendAvailableToMaster( );151 net_status_t SendAvailableToMaster(int count = LONG_MAX); 152 152 net_status_t SendStartToMaster(); 153 153 … … 208 208 209 209 #define MASTER_INIT_TIMEOUT 1000000 // in usec 210 #define SLAVE_INIT_TIMEOUT 2000000 // in usec210 #define SLAVE_INIT_TIMEOUT 1000000 // in usec 211 211 212 212 #define CYCLE_OFFSET_FAST 0
