static void output_reconnect(struct obs_output *output) { int ret; if (!output->reconnecting) output->reconnect_retries = 0; if (output->reconnect_retries >= output->reconnect_retry_max) { output->reconnecting = false; signal_stop(output, OBS_OUTPUT_DISCONNECTED); return; } if (!output->reconnecting) { output->reconnecting = true; os_event_reset(output->reconnect_stop_event); } output->reconnect_retries++; ret = pthread_create(&output->reconnect_thread, NULL, &reconnect_thread, output); if (ret < 0) { blog(LOG_WARNING, "Failed to create reconnect thread"); output->reconnecting = false; signal_stop(output, OBS_OUTPUT_DISCONNECTED); } else { blog(LOG_INFO, "Output '%s': Reconnecting in %d seconds..", output->context.name, output->reconnect_retry_sec); signal_reconnect(output); } }
static void output_reconnect(struct obs_output *output) { int ret; if (!reconnecting(output)) { output->reconnect_retry_cur_sec = output->reconnect_retry_sec; output->reconnect_retries = 0; } if (output->reconnect_retries >= output->reconnect_retry_max) { output->stop_code = OBS_OUTPUT_DISCONNECTED; os_atomic_set_bool(&output->reconnecting, false); if (delay_active(output)) os_atomic_set_bool(&output->delay_active, false); obs_output_end_data_capture(output); return; } if (!reconnecting(output)) { os_atomic_set_bool(&output->reconnecting, true); os_event_reset(output->reconnect_stop_event); } if (output->reconnect_retries) { output->reconnect_retry_cur_sec *= 2; if (output->reconnect_retry_cur_sec > MAX_RETRY_SEC) output->reconnect_retry_cur_sec = MAX_RETRY_SEC; } output->reconnect_retries++; output->stop_code = OBS_OUTPUT_DISCONNECTED; ret = pthread_create(&output->reconnect_thread, NULL, &reconnect_thread, output); if (ret < 0) { blog(LOG_WARNING, "Failed to create reconnect thread"); os_atomic_set_bool(&output->reconnecting, false); } else { blog(LOG_INFO, "Output '%s': Reconnecting in %d seconds..", output->context.name, output->reconnect_retry_sec); signal_reconnect(output); } }