Commit 3f5aa7df authored by Cheng Sun's avatar Cheng Sun Committed by Ronald S. Bultje

pthread: track thread existence in a separate variable.

This fixes a compile error on mingw32 when using p->thread
directly (as if it were a pointer) to track thread existence,
because the type is opaque and may be a non-pointer.
Signed-off-by: 's avatarRonald S. Bultje <rsbultje@gmail.com>
parent 7c5ce99b
...@@ -70,6 +70,7 @@ typedef struct PerThreadContext { ...@@ -70,6 +70,7 @@ typedef struct PerThreadContext {
struct FrameThreadContext *parent; struct FrameThreadContext *parent;
pthread_t thread; pthread_t thread;
int thread_init;
pthread_cond_t input_cond; ///< Used to wait for a new packet from the main thread. pthread_cond_t input_cond; ///< Used to wait for a new packet from the main thread.
pthread_cond_t progress_cond; ///< Used by child threads to wait for progress to change. pthread_cond_t progress_cond; ///< Used by child threads to wait for progress to change.
pthread_cond_t output_cond; ///< Used by the main thread to wait for frames to finish. pthread_cond_t output_cond; ///< Used by the main thread to wait for frames to finish.
...@@ -651,7 +652,7 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count) ...@@ -651,7 +652,7 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count)
pthread_cond_signal(&p->input_cond); pthread_cond_signal(&p->input_cond);
pthread_mutex_unlock(&p->mutex); pthread_mutex_unlock(&p->mutex);
if (p->thread) if (p->thread_init)
pthread_join(p->thread, NULL); pthread_join(p->thread, NULL);
if (codec->close) if (codec->close)
...@@ -756,7 +757,8 @@ static int frame_thread_init(AVCodecContext *avctx) ...@@ -756,7 +757,8 @@ static int frame_thread_init(AVCodecContext *avctx)
if (err) goto error; if (err) goto error;
pthread_create(&p->thread, NULL, frame_worker_thread, p); if (!pthread_create(&p->thread, NULL, frame_worker_thread, p))
p->thread_init = 1;
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment