diff options
author | Cheng Sun <cheng.sun@ymail.com> | 2011-11-26 16:36:50 -0800 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-11-26 17:14:13 -0800 |
commit | 3f5aa7dfa64c8757e5eef7b1bf870ec754e40f96 (patch) | |
tree | 01d8ccecfc51e179ae7c9b56b7c6ac3a3603390e /libavcodec/pthread.c | |
parent | 7c5ce99bd92fb480b7235cbc9a005f7e6d31f1d7 (diff) | |
download | ffmpeg-streaming-3f5aa7dfa64c8757e5eef7b1bf870ec754e40f96.zip ffmpeg-streaming-3f5aa7dfa64c8757e5eef7b1bf870ec754e40f96.tar.gz |
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: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/pthread.c')
-rw-r--r-- | libavcodec/pthread.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index dae28e6..21e32b5 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -70,6 +70,7 @@ typedef struct PerThreadContext { struct FrameThreadContext *parent; 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 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. @@ -651,7 +652,7 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count) pthread_cond_signal(&p->input_cond); pthread_mutex_unlock(&p->mutex); - if (p->thread) + if (p->thread_init) pthread_join(p->thread, NULL); if (codec->close) @@ -756,7 +757,8 @@ static int frame_thread_init(AVCodecContext *avctx) 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; |