ref: 2483af97ca0413a554e05756888acfa24ec0d3e0
parent: 44b748f47f908187266c51667b0e2950dfb4d5a6
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Sun Oct 7 11:14:59 EDT 2018
Don't clear n_tile_data on first dav1d_frame_task() iteration Should fix hang in #23.
--- a/src/thread_task.c
+++ b/src/thread_task.c
@@ -32,26 +32,22 @@
void *dav1d_frame_task(void *const data) {
Dav1dFrameContext *const f = data;
+ pthread_mutex_lock(&f->frame_thread.td.lock);
for (;;) {
- pthread_mutex_lock(&f->frame_thread.td.lock);
- f->n_tile_data = 0;
- int did_signal = 0;
while (!f->n_tile_data && !f->frame_thread.die) {
- if (!did_signal) {
- did_signal = 1;
- pthread_cond_signal(&f->frame_thread.td.cond);
- }
pthread_cond_wait(&f->frame_thread.td.cond,
&f->frame_thread.td.lock);
}
- if (f->frame_thread.die) {
- pthread_mutex_unlock(&f->frame_thread.td.lock);
- break;
- }
+ if (f->frame_thread.die) break;
pthread_mutex_unlock(&f->frame_thread.td.lock);
dav1d_decode_frame(f);
+
+ pthread_mutex_lock(&f->frame_thread.td.lock);
+ f->n_tile_data = 0;
+ pthread_cond_signal(&f->frame_thread.td.cond);
}
+ pthread_mutex_unlock(&f->frame_thread.td.lock);
return NULL;
}