On Wed, 01 Jun 2016 15:31:57 +0530 Arun Raghavan <a...@arunraghavan.net> wrote:
> > I don't have good example as such, but I do know the alsa pulse plugin > for example sets different flags (and buffer attrs?) from the more > standard async clients. > I tried a few different ALSA applications without any glitches: - aplay - mplayer - flash in firefox > We have an old test for creating a simple set of streams as a sanity > check. Maybe this could be extended to run with different combinations > of flags and attributes. > > > http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/tests/sync-playback.c > Triggering the bug requires a specific amount of data to be drained, which is difficult to achieve in any sensible manner just by being a client. :/ I added the attached test though. It doesn't test the full scope of the bug as it doesn't include the native protocol side of things, but it should verify correct minreq behaviour in the core (which in turn should avoid bugs further out). Hopefully that's sufficient for now? Rgds -- Pierre Ossman Software Development Cendio AB https://cendio.com Teknikringen 8 https://twitter.com/ThinLinc 583 30 Linköping https://facebook.com/ThinLinc Phone: +46-13-214600 https://plus.google.com/+CendioThinLinc A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
>From 52032663b7cff5a25d818485e5b97a32b3644b74 Mon Sep 17 00:00:00 2001 From: Pierre Ossman <oss...@cendio.se> Date: Wed, 8 Jun 2016 11:28:25 +0200 Subject: [PATCH] tests: add test to verify correct minreq behaviour --- src/tests/memblockq-test.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/tests/memblockq-test.c b/src/tests/memblockq-test.c index a65b097..92230e4 100644 --- a/src/tests/memblockq-test.c +++ b/src/tests/memblockq-test.c @@ -212,6 +212,85 @@ START_TEST (memblockq_test) { } END_TEST +START_TEST (pop_missing_test) { + int ret; + size_t missing; + + pa_mempool *p; + pa_memblockq *bq; + pa_memchunk chunk; + char buffer[2048]; + pa_sample_spec ss = { + .format = PA_SAMPLE_S16LE, + .rate = 48000, + .channels = 1 + }; + + pa_log_set_level(PA_LOG_DEBUG); + + bq = pa_memblockq_new("test memblockq", 0, 4096, 2048, &ss, 0, 512, 512, NULL); + fail_unless(bq != NULL); + + /* Empty buffer, so expect tlength */ + missing = pa_memblockq_pop_missing(bq); + fail_unless(missing == 2048); + + /* Everything requested, so should be satisfied */ + missing = pa_memblockq_pop_missing(bq); + fail_unless(missing == 0); + + p = pa_mempool_new(false, 0); + + chunk.memblock = pa_memblock_new_fixed(p, buffer, sizeof(buffer), 1); + fail_unless(chunk.memblock != NULL); + + chunk.index = 0; + chunk.length = sizeof(buffer); + + /* Fill buffer (i.e. satisfy earlier request) */ + ret = pa_memblockq_push(bq, &chunk); + fail_unless(ret == 0); + + /* Should still be happy */ + missing = pa_memblockq_pop_missing(bq); + fail_unless(missing == 0); + + /* Check that we don't request less than minreq */ + pa_memblockq_drop(bq, 400); + missing = pa_memblockq_pop_missing(bq); + fail_unless(missing == 0); + + missing = pa_memblockq_pop_missing(bq); + fail_unless(missing == 0); + + /* Reduce tlength under what's dropped and under previous minreq */ + pa_memblockq_set_tlength(bq, 256); + pa_memblockq_set_minreq(bq, 64); + + /* We are now overbuffered and should not request more */ + missing = pa_memblockq_pop_missing(bq); + fail_unless(missing == 0); + + /* Drop more data so we are below tlength again, but just barely */ + pa_memblockq_drop(bq, 1400); + + /* Should still honour minreq */ + missing = pa_memblockq_pop_missing(bq); + fail_unless(missing == 0); + + /* Finally drop enough to fall below minreq */ + pa_memblockq_drop(bq, 80); + + /* And expect a request */ + missing = pa_memblockq_pop_missing(bq); + fail_unless(missing == 88); + + pa_memblockq_free(bq); + pa_memblock_unref(chunk.memblock); + pa_mempool_free(p); +} +END_TEST + int main(int argc, char *argv[]) { int failed = 0; Suite *s; @@ -219,10 +298,15 @@ int main(int argc, char *argv[]) { SRunner *sr; s = suite_create("Memblock Queue"); + tc = tcase_create("memblockq"); tcase_add_test(tc, memblockq_test); suite_add_tcase(s, tc); + tc = tcase_create("pop_missing"); + tcase_add_test(tc, pop_missing_test); + suite_add_tcase(s, tc); + sr = srunner_create(s); srunner_run_all(sr, CK_NORMAL); failed = srunner_ntests_failed(sr); -- 2.5.5
_______________________________________________ pulseaudio-discuss mailing list pulseaudio-discuss@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss