obs-outputs: Join with correct thread on destroy
If there was an attempt to destroy the rtmp-stream output while it was already connecting and stopping at the same time, it would try to join with the stop thread rather than with the connect thread. The connect thread would then continue past destruction.master
parent
3dab1ebb0a
commit
730132853a
|
@ -46,7 +46,7 @@ struct rtmp_stream {
|
|||
struct circlebuf packets;
|
||||
bool sent_headers;
|
||||
|
||||
bool connecting;
|
||||
volatile bool connecting;
|
||||
pthread_t connect_thread;
|
||||
|
||||
bool active;
|
||||
|
@ -116,15 +116,15 @@ static void rtmp_stream_destroy(void *data)
|
|||
{
|
||||
struct rtmp_stream *stream = data;
|
||||
|
||||
if (stream->stopping) {
|
||||
if (stream->stopping && !stream->connecting) {
|
||||
pthread_join(stream->stop_thread, NULL);
|
||||
|
||||
} else if (stream->connecting || stream->active) {
|
||||
os_event_signal(stream->stop_event);
|
||||
|
||||
if (stream->connecting)
|
||||
pthread_join(stream->connect_thread, NULL);
|
||||
|
||||
os_event_signal(stream->stop_event);
|
||||
|
||||
if (stream->active) {
|
||||
os_sem_post(stream->send_sem);
|
||||
obs_output_end_data_capture(stream->output);
|
||||
|
@ -196,11 +196,11 @@ static void rtmp_stream_stop(void *data)
|
|||
if (stream->stopping)
|
||||
return;
|
||||
|
||||
os_event_signal(stream->stop_event);
|
||||
|
||||
if (stream->connecting)
|
||||
pthread_join(stream->connect_thread, NULL);
|
||||
|
||||
os_event_signal(stream->stop_event);
|
||||
|
||||
if (stream->active) {
|
||||
os_sem_post(stream->send_sem);
|
||||
obs_output_end_data_capture(stream->output);
|
||||
|
@ -579,6 +579,7 @@ static bool rtmp_stream_start(void *data)
|
|||
if (!obs_output_initialize_encoders(stream->output, 0))
|
||||
return false;
|
||||
|
||||
stream->connecting = true;
|
||||
return pthread_create(&stream->connect_thread, NULL, connect_thread,
|
||||
stream) == 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue