~ft/aacenc

54d7f35236ac517e28ee4cb4df08804d3c7e0421 — Sigrid Solveig Haflínudóttir 10 months ago d2cdbaf
non-buffered mode: initialize timestamp *after* first read; don't flush the packet with the timestamp alone
1 files changed, 4 insertions(+), 2 deletions(-)

M frontend/aacenc.c
M frontend/aacenc.c => frontend/aacenc.c +4 -2
@@ 123,11 123,13 @@ main(int argc, char **argv)

	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 @@ main(int argc, char **argv)
			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))