Skip to content

Commit

Permalink
obs-outputs: Remove stop thread (unnecessary)
Browse files Browse the repository at this point in the history
Since the RTMP_Close was moved to the send thread (where it should have
been) the stop thread now has no real purpose.
  • Loading branch information
jp9000 committed Nov 18, 2015
1 parent 52d5a9b commit f0cf699
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions plugins/obs-outputs/rtmp-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ struct rtmp_stream {
volatile bool disconnected;
pthread_t send_thread;

pthread_t stop_thread;
int max_shutdown_time_sec;

os_sem_t *send_sem;
Expand Down Expand Up @@ -136,14 +135,12 @@ static inline bool disconnected(struct rtmp_stream *stream)
return os_atomic_load_bool(&stream->disconnected);
}

static void *rtmp_stream_actual_stop(void *data);

static void rtmp_stream_destroy(void *data)
{
struct rtmp_stream *stream = data;

if (stopping(stream) && !connecting(stream)) {
pthread_join(stream->stop_thread, NULL);
pthread_join(stream->send_thread, NULL);

} else if (connecting(stream) || active(stream)) {
if (stream->connecting)
Expand All @@ -154,9 +151,8 @@ static void rtmp_stream_destroy(void *data)
if (active(stream)) {
os_sem_post(stream->send_sem);
obs_output_end_data_capture(stream->output);
pthread_join(stream->send_thread, NULL);
}

rtmp_stream_actual_stop(data);
}

if (stream) {
Expand Down Expand Up @@ -197,24 +193,9 @@ static void *rtmp_stream_create(obs_data_t *settings, obs_output_t *output)
return NULL;
}

static void *rtmp_stream_actual_stop(void *data)
{
struct rtmp_stream *stream = data;
void *ret;

if (active(stream))
pthread_join(stream->send_thread, &ret);

os_event_reset(stream->stop_event);

stream->sent_headers = false;
return NULL;
}

static void rtmp_stream_stop(void *data)
{
struct rtmp_stream *stream = data;
int ret;

if (stopping(stream))
return;
Expand All @@ -228,13 +209,6 @@ static void rtmp_stream_stop(void *data)
os_sem_post(stream->send_sem);
obs_output_end_data_capture(stream->output);
}

ret = pthread_create(&stream->stop_thread, NULL,
rtmp_stream_actual_stop, stream);
if (ret != 0) {
warn("Could not create stop thread! Stopping directly");
rtmp_stream_actual_stop(stream);
}
}

static inline void set_rtmp_str(AVal *val, const char *str)
Expand Down Expand Up @@ -404,6 +378,7 @@ static void *send_thread(void *data)
obs_output_signal_stop(stream->output, OBS_OUTPUT_DISCONNECTED);
}

os_event_reset(stream->stop_event);
os_atomic_set_bool(&stream->active, false);
stream->sent_headers = false;
return NULL;
Expand Down Expand Up @@ -654,7 +629,7 @@ static bool init_connect(struct rtmp_stream *stream)
obs_data_t *settings;

if (stopping(stream))
pthread_join(stream->stop_thread, NULL);
pthread_join(stream->send_thread, NULL);

free_packets(stream);

Expand Down

0 comments on commit f0cf699

Please sign in to comment.