libobs: Fix lockup when an encode call fails
(This commit also modifies the UI, obs-ffmpeg, and obs-output modules) Fixes a long-time regression where the program would lock up if an encode call fails. Shuts down all outputs associated with the failing encoder and displays an error message to the user. Ideally, it would be best if a more detailed error could be displayed to the user about the nature of the error, though the primary problem is the encoder errors are typically not something the user would be able to understand. The current message is a bit of a generic error message; improvement is welcome. Another suggestion is to try to have the encoder restart seamlessly, though it would take a significant amount of work to be able to make it do something like that properly, and it sort of assumes that encoder failures are sporadic, which may not necessarily be the case with some hardware encoders on some systems. It may be better just to use another encoder in that case. For now, seamless restart is ruled out.
This commit is contained in:
@@ -487,8 +487,12 @@ static void *send_thread(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
bool encode_error = os_atomic_load_bool(&stream->encode_error);
|
||||
|
||||
if (disconnected(stream)) {
|
||||
info("Disconnected from %s", stream->path.array);
|
||||
} else if (encode_error) {
|
||||
info("Encoder error, disconnecting");
|
||||
} else {
|
||||
info("User stopped the stream");
|
||||
}
|
||||
@@ -507,6 +511,8 @@ static void *send_thread(void *data)
|
||||
if (!stopping(stream)) {
|
||||
pthread_detach(stream->send_thread);
|
||||
obs_output_signal_stop(stream->output, OBS_OUTPUT_DISCONNECTED);
|
||||
} else if (encode_error) {
|
||||
obs_output_signal_stop(stream->output, OBS_OUTPUT_ENCODE_ERROR);
|
||||
} else {
|
||||
obs_output_end_data_capture(stream->output);
|
||||
}
|
||||
@@ -886,6 +892,7 @@ static bool init_connect(struct rtmp_stream *stream)
|
||||
return false;
|
||||
|
||||
os_atomic_set_bool(&stream->disconnected, false);
|
||||
os_atomic_set_bool(&stream->encode_error, false);
|
||||
stream->total_bytes_sent = 0;
|
||||
stream->dropped_frames = 0;
|
||||
stream->min_priority = 0;
|
||||
@@ -1103,6 +1110,13 @@ static void rtmp_stream_data(void *data, struct encoder_packet *packet)
|
||||
if (disconnected(stream) || !active(stream))
|
||||
return;
|
||||
|
||||
/* encoder fail */
|
||||
if (!packet) {
|
||||
os_atomic_set_bool(&stream->encode_error, true);
|
||||
os_sem_post(stream->send_sem);
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet->type == OBS_ENCODER_VIDEO) {
|
||||
if (!stream->got_first_video) {
|
||||
stream->start_dts_offset =
|
||||
|
Reference in New Issue
Block a user