ref: bf2a0ea2464a89431888f01af4f5b5c0bbe62105
parent: 21f92cf520f83cee37c3e7c8b53c13a8b0179410
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Wed Jul 14 09:59:05 EDT 2021
flush the reminding frames properly
--- a/hj264.c
+++ b/hj264.c
@@ -43,6 +43,7 @@
H264E_io_yuv_t yuv;
Biobuf out;
Channel *frame;
+ Channel *done;
Hjthread threads[H264E_MAX_THREADS];
Hjob jobs[H264E_MAX_THREADS];
int nthreads;
@@ -319,8 +320,10 @@
}
Bflush(&h->out);
- hj264free(h);
+ if(h->done != nil)
+ sendp(h->done, nil);
+
threadexits(nil);
}
@@ -420,6 +423,7 @@
if(Binit(&h->out, 1, OWRITE) < 0)
sysfatal("Binit failed: %r");
h->frame = chancreate(sizeof(void*), 1); /* FIXME this is wrong as the encoder might be too late */
+ h->done = chancreate(sizeof(void*), 0);
/* FIXME how about changing these on the fly? */
h->rp.encode_speed = Maxquality - quality;
@@ -451,6 +455,8 @@
fprint(2, "%d fps\n", (int)(nframes / ((end - start)/1000000000ULL)));
chanclose(h->frame);
+ recvp(h->done);
+ hj264free(h);
threadexitsall(nil);