diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-11-27 05:55:20 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-11-27 05:55:20 +0100 |
commit | 2bb79b23fe106a45eab6ff80d7ef7519d542d1f7 (patch) | |
tree | 47d1093684d7de5df642fd055b8496cc3b2445c0 /libavcodec/pthread.c | |
parent | 3d977edb043c59e7a4aca8555e29f01caa2ee1fe (diff) | |
download | ffmpeg-2bb79b23fe106a45eab6ff80d7ef7519d542d1f7.tar.gz |
pthread: next try on freeing threads without crashing.
This should fix mingw
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
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 75168e4598..ad1fe122e1 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -72,6 +72,7 @@ typedef struct PerThreadContext { struct FrameThreadContext *parent; pthread_t thread; + int thread_created; 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. @@ -658,8 +659,9 @@ 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_created) pthread_join(p->thread, NULL); + p->thread_created=0; if (codec->close) codec->close(p->avctx); @@ -763,7 +765,7 @@ static int frame_thread_init(AVCodecContext *avctx) if (err) goto error; - pthread_create(&p->thread, NULL, frame_worker_thread, p); + p->thread_created= !pthread_create(&p->thread, NULL, frame_worker_thread, p); } return 0; |