ref: 44f4ed0d8f048de95984e01e33d34cff27040114
parent: 99bb4ede6aa7d3fdcabdbe02abe1f65261127972
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue Sep 15 11:34:17 EDT 2020
send decoder's status when finished
--- a/decoder_av1.c
+++ b/decoder_av1.c
@@ -111,7 +111,7 @@
dav1d_close(&a->c);
free(a);
c = d->finished;
- sendp(c, nil);
+ sendp(c, res == 0 ? nil : "error");
chanclose(c);
threadexits(nil);
--- a/decoder_h264.c
+++ b/decoder_h264.c
@@ -94,7 +94,7 @@
h264bsdShutdown(&a->c);
free(a);
c = d->finished;
- sendp(c, nil);
+ sendp(c, res == 0 ? nil : "error");
chanclose(c);
threadexits(nil);
--- a/main.c
+++ b/main.c
@@ -118,7 +118,7 @@
Keyboardctl *kctl;
Rune key;
Mouse m;
- char *s, *audio;
+ char *s, *audio, *status;
Stream *stream, *svideo, *saudio;
Decoder *d;
int i, j, end, done, forced, res, nstreams;
@@ -125,7 +125,7 @@
Alt a[Cnum+1] =
{
[Cframe] = { nil, &frame, CHANRCV },
- [Cplayerdone] = { nil, nil, CHANRCV },
+ [Cplayerdone] = { nil, &status, CHANRCV },
[Cmouse] = { nil, &m, CHANRCV },
[Ckeyboard] = { nil, &key, CHANRCV },
[Cresize] = { nil, nil, CHANRCV },
@@ -202,6 +202,9 @@
audiosync = chancreate(sizeof(void*), 1);
audiofinished = chancreate(sizeof(void*), 0);
proccreate(audioproc, saudio, 4096);
+ }else{
+ audiosync = nil;
+ audiofinished = nil;
}
for(done = forced = 0; !done && !end;){
@@ -213,6 +216,8 @@
case Cplayerdone:
done = 1;
+ if(status != nil)
+ forced = 1;
break;
case Cmouse:
@@ -236,7 +241,6 @@
break;
}
-
for(; !end && audiofd >= 0 && saudio != nil;){
if(Sread(saudio, &f) != 0 || f.sz == 0)
break;
@@ -244,8 +248,10 @@
}
}
- if(forced)
+ if(forced){
Sclose(saudio);
+ chanclose(audiosync);
+ }
if(audiofinished != nil){
recvp(audiofinished);
chanclose(audiofinished);