ref: 14a76c31ba5ca60d00a898f70d13c9db14d4e5d4
parent: eee770d0ddad7bcbce81ef84e33c45d20f5a10be
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Dec 14 10:52:12 EST 2020
do not stuck when mcfs failed to extract audio
--- a/main.c
+++ b/main.c
@@ -29,20 +29,26 @@
{
Streamframe f;
Stream *s;
- int audiofd;
+ int audiofd, synced;
+ synced = 0;
if((audiofd = open("/dev/audio", OWRITE|OCEXEC)) < 0){
fprint(2, "runaudio: %r\n");
- recvp(audiosync);
- chanclose(audiosync);
}else{
for(s = x; Sread(s, &f) == 0 && f.sz > 0;){
- recvp(audiosync);
- chanclose(audiosync);
+ if(!synced){
+ recvp(audiosync);
+ chanclose(audiosync);
+ synced = 1;
+ }
write(audiofd, f.buf, f.sz);
}
close(audiofd);
}
+ if(!synced){
+ recvp(audiosync);
+ chanclose(audiosync);
+ }
sendp(audiofinished, nil);
@@ -140,7 +146,6 @@
Cresize,
Cnum,
};
- Streamframe f;
Frame *frame;
Mousectl *mctl;
Keyboardctl *kctl;
@@ -284,12 +289,6 @@
flushimage(display, 1);
unlockdisplay(display);
break;
- }
-
- for(; !end && audiofd >= 0 && saudio != nil;){
- if(Sread(saudio, &f) != 0 || f.sz == 0)
- break;
- write(audiofd, f.buf, f.sz);
}
}