History

protect against audio overruns

Sigrid Solveig Haflínudóttir committed 5 years ago

Commit daf4e541 parent f68aad91 file · +10 −2Browse files

Unified · Split

main.c+10−2
@@ -13,6 +13,7 @@ int debug = 0; · 12 unmodified lines
13static RTMP *r;13static RTMP *r;
14static ulong sid;14static ulong sid;
15static uvlong ns₀;15static uvlong ns₀;
16static uvlong vms;
16 17
17static void18static void
18usage(void)19usage(void)
@@ -32,14 +33,20 @@ audio(void *aux) · 13 unmodified lines
32 memset(&af, 0, sizeof(af));33 memset(&af, 0, sizeof(af));
33 for(;;){34 for(;;){
34 if(adtsread(a, &af) != 0)35 if(adtsread(a, &af) != 0)
35 sysfatal("%r");36 goto err;
36 if(af.sz == 0)37 if(af.sz == 0) /* eof */
37 break;38 break;
38 ms = (af.ns₀ - ns₀ + af.ns)/1000000ULL;39 ms = (af.ns₀ - ns₀ + af.ns)/1000000ULL;
40
39 if(rtmpdata(r, sid, ms, Taudio, af.buf, af.sz) != 0){41 if(rtmpdata(r, sid, ms, Taudio, af.buf, af.sz) != 0){
42err:
40 fprint(2, "%r\n");43 fprint(2, "%r\n");
41 break;44 break;
42 }45 }
46
47 /* protect against overruns */
48 if(vms+200 < ms)
49 sleep(100);
43 }50 }
44 51
45 /* FIXME properly close RTMP connection */52 /* FIXME properly close RTMP connection */
@@ -100,6 +107,7 @@ threadmain(int argc, char **argv) · 54 unmodified lines
100 fprint(2, "%r\n");107 fprint(2, "%r\n");
101 break;108 break;
102 }109 }
110 vms = ms;
103 }111 }
104 112
105 /* FIXME properly close RTMP connection */113 /* FIXME properly close RTMP connection */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t