pthread : Remove lock/unlock pairs in worker loop to avoid unexpected state changes.
Reviewed-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
9621646eb3
commit
aa9c2e41b6
@ -365,21 +365,17 @@ static attribute_align_arg void *frame_worker_thread(void *arg)
|
|||||||
AVCodecContext *avctx = p->avctx;
|
AVCodecContext *avctx = p->avctx;
|
||||||
AVCodec *codec = avctx->codec;
|
AVCodec *codec = avctx->codec;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&p->mutex);
|
||||||
while (1) {
|
while (1) {
|
||||||
int i;
|
int i;
|
||||||
if (p->state == STATE_INPUT_READY && !fctx->die) {
|
|
||||||
pthread_mutex_lock(&p->mutex);
|
|
||||||
while (p->state == STATE_INPUT_READY && !fctx->die)
|
while (p->state == STATE_INPUT_READY && !fctx->die)
|
||||||
pthread_cond_wait(&p->input_cond, &p->mutex);
|
pthread_cond_wait(&p->input_cond, &p->mutex);
|
||||||
pthread_mutex_unlock(&p->mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fctx->die) break;
|
if (fctx->die) break;
|
||||||
|
|
||||||
if (!codec->update_thread_context && (avctx->thread_safe_callbacks || avctx->get_buffer == avcodec_default_get_buffer))
|
if (!codec->update_thread_context && (avctx->thread_safe_callbacks || avctx->get_buffer == avcodec_default_get_buffer))
|
||||||
ff_thread_finish_setup(avctx);
|
ff_thread_finish_setup(avctx);
|
||||||
|
|
||||||
pthread_mutex_lock(&p->mutex);
|
|
||||||
avcodec_get_frame_defaults(&p->frame);
|
avcodec_get_frame_defaults(&p->frame);
|
||||||
p->got_frame = 0;
|
p->got_frame = 0;
|
||||||
p->result = codec->decode(avctx, &p->frame, &p->got_frame, &p->avpkt);
|
p->result = codec->decode(avctx, &p->frame, &p->got_frame, &p->avpkt);
|
||||||
@ -397,9 +393,8 @@ static attribute_align_arg void *frame_worker_thread(void *arg)
|
|||||||
pthread_cond_broadcast(&p->progress_cond);
|
pthread_cond_broadcast(&p->progress_cond);
|
||||||
pthread_cond_signal(&p->output_cond);
|
pthread_cond_signal(&p->output_cond);
|
||||||
pthread_mutex_unlock(&p->progress_mutex);
|
pthread_mutex_unlock(&p->progress_mutex);
|
||||||
|
|
||||||
pthread_mutex_unlock(&p->mutex);
|
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&p->mutex);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user