diff --git a/src/aubuf.c b/src/aubuf.c index 90065590..096ed65f 100644 --- a/src/aubuf.c +++ b/src/aubuf.c @@ -15,17 +15,21 @@ #define AUDIO_TIMEBASE 1000000U +enum { + FRAMES = 80, +}; + static int test_aubuf_raw(void) { struct aubuf *ab = NULL; - int16_t sampv_in[160]; - int16_t sampv_out[160]; + int16_t sampv_in[2 * FRAMES]; + int16_t sampv_out[2 * FRAMES]; struct mbuf *mb; unsigned i; int err; - mb = mbuf_alloc(80 * sizeof(int16_t)); + mb = mbuf_alloc(FRAMES * sizeof(int16_t)); if (!mb) return ENOMEM; @@ -33,24 +37,24 @@ static int test_aubuf_raw(void) sampv_in[i] = i; memset(sampv_out, 0, sizeof(sampv_out)); - err = aubuf_alloc(&ab, 320, 0); + err = aubuf_alloc(&ab, 4 * FRAMES, 0); TEST_ERR(err); TEST_EQUALS(0, aubuf_cur_size(ab)); - err = aubuf_write(ab, (uint8_t *)sampv_in, 80 * sizeof(int16_t)); + err = aubuf_write(ab, (uint8_t *)sampv_in, FRAMES * sizeof(int16_t)); TEST_ERR(err); - TEST_EQUALS(160, aubuf_cur_size(ab)); + TEST_EQUALS(2 * FRAMES, aubuf_cur_size(ab)); - (void)mbuf_write_mem(mb, (uint8_t *)&sampv_in[80], - 80 * sizeof(int16_t)); + (void)mbuf_write_mem(mb, (uint8_t *)&sampv_in[FRAMES], + FRAMES * sizeof(int16_t)); mb->pos = 0; err = aubuf_append(ab, mb); TEST_ERR(err); - TEST_EQUALS(320, aubuf_cur_size(ab)); + TEST_EQUALS(4 * FRAMES, aubuf_cur_size(ab)); memset(sampv_out, 0, sizeof(sampv_out)); - aubuf_read(ab, (uint8_t *)sampv_out, 160 * sizeof(int16_t)); + aubuf_read(ab, (uint8_t *)sampv_out, 2 * FRAMES * sizeof(int16_t)); TEST_MEMCMP(sampv_in, sizeof(sampv_in), sampv_out, sizeof(sampv_out)); TEST_EQUALS(0, aubuf_cur_size(ab)); @@ -64,8 +68,8 @@ static int test_aubuf_raw(void) static int test_aubuf_samp(void) { struct aubuf *ab = NULL; - int16_t sampv_in[160]; - int16_t sampv_out[160]; + int16_t sampv_in[2 * FRAMES]; + int16_t sampv_out[2 * FRAMES]; unsigned i; int err; @@ -73,16 +77,16 @@ static int test_aubuf_samp(void) sampv_in[i] = i; memset(sampv_out, 0, sizeof(sampv_out)); - err = aubuf_alloc(&ab, 320, 0); + err = aubuf_alloc(&ab, 4 * FRAMES, 0); TEST_ERR(err); TEST_EQUALS(0, aubuf_cur_size(ab)); - err |= aubuf_write_samp(ab, sampv_in, 80); - err |= aubuf_write_samp(ab, &sampv_in[80], 80); + err |= aubuf_write_samp(ab, sampv_in, FRAMES); + err |= aubuf_write_samp(ab, &sampv_in[FRAMES], FRAMES); TEST_ERR(err); - TEST_EQUALS(320, aubuf_cur_size(ab)); + TEST_EQUALS(4 * FRAMES, aubuf_cur_size(ab)); aubuf_read_samp(ab, sampv_out, ARRAY_SIZE(sampv_out)); TEST_MEMCMP(sampv_in, sizeof(sampv_in), sampv_out, sizeof(sampv_out)); @@ -97,74 +101,96 @@ static int test_aubuf_samp(void) static int test_aubuf_auframe(void) { struct aubuf *ab = NULL; - float sampv_in[160]; - float sampv_out[160]; + float sampv_in[3 * FRAMES + (FRAMES / 2)]; + float sampv_out[3 * FRAMES + (FRAMES / 2)]; uint64_t dt; struct auframe af_in; struct auframe af_out; - unsigned i; int err; - for (i=0; i