shithub: aacenc

Download patch

ref: 54d7f35236ac517e28ee4cb4df08804d3c7e0421
parent: d2cdbaf885cfe2efabe0b4c1a6011bb3fb5b2781
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Jul 14 22:47:27 EDT 2023

non-buffered mode: initialize timestamp *after* first read; don't flush the packet with the timestamp alone

--- a/frontend/aacenc.c
+++ b/frontend/aacenc.c
@@ -123,11 +123,13 @@
 
 	atnotify(done, 1);
 
-	ns = nsec();
+	ns = ~0ULL;
 	for(;;){
 		for(n = 0; n == 0 || (n & (sizeof(*pcm)-1)) != 0; n += r){
 			if((r = Bread(&in, pcm+n, insz-n)) < 0)
 				sysfatal("read: %r");
+			if(ns == ~0ULL)
+				ns = nsec();
 			if(r == 0)
 				break;
 		}
@@ -152,7 +154,7 @@
 			for(i = 0; i < 8; i++, ns >>= 8)
 				ph[12+i] = ns;
 			ns = 0;
-			if(Bwrite(&out, ph, sizeof(ph)) < 0 || Bflush(&out) < 0)
+			if(Bwrite(&out, ph, sizeof(ph)) < 0)
 				break;
 		}
 		if(Bwrite(&out, obuf, sz) < 0 || (nobuffer && Bflush(&out) < 0))