From bb0b105b83c0f4ee56b4c7e9a179606aee296aa9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Jul 2004 01:07:06 +0000 Subject: sample cache work git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@98 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/clitext.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'polyp/clitext.c') diff --git a/polyp/clitext.c b/polyp/clitext.c index c1b9953b..d0c3f9a7 100644 --- a/polyp/clitext.c +++ b/polyp/clitext.c @@ -24,6 +24,7 @@ #endif #include +#include #include "clitext.h" #include "module.h" @@ -34,6 +35,7 @@ #include "source-output.h" #include "strbuf.h" #include "sample-util.h" +#include "scache.h" char *pa_module_list_to_string(struct pa_core *c) { struct pa_strbuf *s; @@ -201,3 +203,36 @@ char *pa_sink_input_list_to_string(struct pa_core *c) { return pa_strbuf_tostring_free(s); } + +char *pa_scache_list_to_string(struct pa_core *c) { + struct pa_scache_entry *e; + void *state = NULL; + struct pa_strbuf *s; + assert(c); + + s = pa_strbuf_new(); + assert(s); + + pa_strbuf_printf(s, "%u cache entries available.\n", c->scache_hashmap ? pa_hashmap_ncontents(c->scache_hashmap) : 0); + + if (c->scache_hashmap) { + + while ((e = pa_hashmap_iterate(c->scache_hashmap, &state))) { + double l; + char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; + pa_sample_snprint(ss, sizeof(ss), &e->sample_spec); + + l = (double) e->memchunk.length / pa_bytes_per_second(&e->sample_spec); + + pa_strbuf_printf( + s, " name: <%s>\n\tindex: <%i>\n\tsample_spec: <%s>\n\tlength: <%u>\n\tduration: <%0.1fs>\n", + e->name, + e->index, + ss, + e->memchunk.length, + l); + } + } + + return pa_strbuf_tostring_free(s); +} -- cgit