From c83cf254899f7d8c4b697afdf35f996aab120aee Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Thu, 14 Apr 2011 21:15:57 +0430 Subject: [PATCH] add AUDIOBUFS to config.h --- config.h | 3 +++ fbff.c | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/config.h b/config.h index df9daa5..980436c 100644 --- a/config.h +++ b/config.h @@ -11,3 +11,6 @@ typedef unsigned int fbval_t; * + 8bit: PIX_FMT_RGB8 */ #define FFMPEG_PIXFMT PIX_FMT_RGB32 + +/* audio packets to buffer (power of two); increase if sound is choppy */ +#define AUDIOBUFS (1 << 3) diff --git a/fbff.c b/fbff.c index 69dd2c0..2d825a5 100644 --- a/fbff.c +++ b/fbff.c @@ -70,11 +70,11 @@ static void draw_frame(fbval_t *img, int linelen) } #define ABUFSZ (1 << 18) -#define BUFS (1 << 6) + static int a_cons; static int a_prod; -static char a_buf[BUFS][ABUFSZ]; -static int a_len[BUFS]; +static char a_buf[AUDIOBUFS][ABUFSZ]; +static int a_len[AUDIOBUFS]; static int a_reset; static int a_conswait(void) @@ -84,7 +84,7 @@ static int a_conswait(void) static int a_prodwait(void) { - return ((a_prod + 1) & (BUFS - 1)) == a_cons; + return ((a_prod + 1) & (AUDIOBUFS - 1)) == a_cons; } static void a_doreset(int pause) @@ -191,7 +191,7 @@ static int is_vsync(void) int cur = ffs_seq(affs, 0); int all = ffs_seq(affs, 1); int ratio = all ? (all - cur) * 1024 / all : 512; - int avdiff = BUFS * 4 * ratio / 1024; + int avdiff = AUDIOBUFS * 4 * ratio / 1024; return ffs_seq(vffs, 1) + avdiff < ffs_seq(affs, 1); } @@ -211,7 +211,7 @@ static void mainloop(void) eof = 1; if (ret > 0) { a_len[a_prod] = ret; - a_prod = (a_prod + 1) & (BUFS - 1); + a_prod = (a_prod + 1) & (AUDIOBUFS - 1); } } if (video && (!audio || eof || is_vsync())) { @@ -264,7 +264,7 @@ static void *process_audio(void *dat) continue; } write(afd, a_buf[a_cons], a_len[a_cons]); - a_cons = (a_cons + 1) & (BUFS - 1); + a_cons = (a_cons + 1) & (AUDIOBUFS - 1); } ret: oss_close(); -- 2.11.4.GIT