| @@ -63,6 +63,7 @@ extern "C" | |||
| jack_nframes_t buffer_size; | |||
| jack_nframes_t sample_rate; | |||
| char master_name[MASTER_NAME_SIZE]; | |||
| int time_out; | |||
| } jack_master_t; | |||
| @@ -161,6 +162,7 @@ struct JackNetExtMaster : public JackNetMasterInterface { | |||
| fRequest.sample_rate = request->sample_rate; | |||
| fRequest.audio_input = request->audio_input; | |||
| fRequest.audio_output = request->audio_output; | |||
| fRequest.time_out = request->time_out; | |||
| fAudioCaptureBuffer = NULL; | |||
| fAudioPlaybackBuffer = NULL; | |||
| fMidiCaptureBuffer = NULL; | |||
| @@ -209,7 +211,8 @@ struct JackNetExtMaster : public JackNetMasterInterface { | |||
| // Main loop, wait for data, deal with it and wait again | |||
| int attempt = 0; | |||
| int rx_bytes = 0; | |||
| int try_count = (fRequest.time_out > 0) ? int((1000000.f * float(fRequest.time_out)) / float(MANAGER_INIT_TIMEOUT)) : INT_MAX; | |||
| do | |||
| { | |||
| session_params_t net_params; | |||
| @@ -246,7 +249,12 @@ struct JackNetExtMaster : public JackNetMasterInterface { | |||
| } | |||
| } | |||
| } | |||
| while (fRunning); | |||
| while (fRunning && (--try_count > 0)); | |||
| if (try_count == 0) { | |||
| jack_error("Time out error in connect"); | |||
| return -1; | |||
| } | |||
| // Set result parameters | |||
| result->audio_input = fParams.fSendAudioChannels; | |||
| @@ -643,7 +643,7 @@ namespace Jack | |||
| bool JackNetSlaveInterface::InitConnection(int time_out_sec) | |||
| { | |||
| jack_log("JackNetSlaveInterface::InitConnection time_out_sec = %d", time_out_sec); | |||
| int try_count = (time_out_sec > 0) ? ((1000000 * time_out_sec) / SLAVE_INIT_TIMEOUT) : INT_MAX; | |||
| int try_count = (time_out_sec > 0) ? int((1000000.f * float(time_out_sec)) / float(SLAVE_INIT_TIMEOUT)) : INT_MAX; | |||
| // set the parameters to send | |||
| strcpy(fParams.fPacketType, "params"); | |||
| @@ -53,7 +53,7 @@ typedef struct { | |||
| int midi_input; // from master or to slave (-1 to take master MIDI physical inputs) | |||
| int midi_output; // to master or from slave (-1 to take master MIDI physical outputs) | |||
| int mtu; // network Maximum Transmission Unit | |||
| int time_out; // in second, -1 means in infinite | |||
| int time_out; // in second, -1 means infinite | |||
| int encoder; // encoder type (one of JackNetEncoder) | |||
| int kbps; // KB per second for CELT encoder | |||
| int latency; // network latency | |||
| @@ -66,9 +66,10 @@ typedef struct { | |||
| int audio_output; // master audio physical inputs (-1 to take slave wanted audio outputs) | |||
| int midi_input; // master MIDI physical outputs (-1 to take slave wanted MIDI inputs) | |||
| int midi_output; // master MIDI physical inputs (-1 to take slave wanted MIDI outputs) | |||
| jack_nframes_t buffer_size; // mater buffer size | |||
| jack_nframes_t sample_rate; // mater sample rate | |||
| jack_nframes_t buffer_size; // master buffer size | |||
| jack_nframes_t sample_rate; // master sample rate | |||
| char master_name[MASTER_NAME_SIZE]; // master machine name | |||
| int time_out; // in second, -1 means infinite | |||
| } jack_master_t; | |||
| @@ -100,8 +100,8 @@ main (int argc, char *argv[]) | |||
| } | |||
| int i; | |||
| jack_master_t request = { 4, 4, -1, -1, buffer_size, sample_rate, "master" }; | |||
| //jack_master_t request = { -1, -1, -1, -1, buffer_size, sample_rate, "master" }; | |||
| //jack_master_t request = { 4, 4, -1, -1, buffer_size, sample_rate, "master", -1 }; | |||
| jack_master_t request = { -1, -1, -1, -1, buffer_size, sample_rate, "master", 6 }; | |||
| jack_slave_t result; | |||
| float** audio_input_buffer; | |||
| float** audio_output_buffer; | |||
| @@ -146,7 +146,9 @@ main (int argc, char *argv[]) | |||
| WARNING !! : this code is given for demonstration purpose. For proper timing bevahiour | |||
| it has to be called in a real-time context (which is *not* the case here...) | |||
| */ | |||
| //usleep(5*1000000); | |||
| while (1) { | |||
| // Copy input to output | |||
| @@ -154,17 +156,17 @@ main (int argc, char *argv[]) | |||
| for (i = 0; i < result.audio_input; i++) { | |||
| memcpy(audio_output_buffer[i], audio_input_buffer[i], buffer_size * sizeof(float)); | |||
| } | |||
| if (jack_net_master_send(net, result.audio_output, audio_output_buffer, 0, NULL) < 0) { | |||
| printf("jack_net_master_send failure, exiting\n"); | |||
| break; | |||
| } | |||
| if (jack_net_master_recv(net, result.audio_input, audio_input_buffer, 0, NULL) < 0) { | |||
| printf("jack_net_master_recv failure, exiting\n"); | |||
| break; | |||
| } | |||
| usleep(wait_usec); | |||
| }; | |||