]> code.delx.au - pulseaudio/commitdiff
add total sample cache size to statistics
authorLennart Poettering <lennart@poettering.net>
Wed, 1 Sep 2004 22:46:27 +0000 (22:46 +0000)
committerLennart Poettering <lennart@poettering.net>
Wed, 1 Sep 2004 22:46:27 +0000 (22:46 +0000)
add size to sample cache entry info

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@175 fefdeb5f-60dc-0310-8127-8f9354f1896f

doc/todo
polyp/polyplib-introspect.c
polyp/polyplib-introspect.h
polyp/protocol-native.c
polyp/scache.c
polyp/scache.h

index 7c1cf71e0fd03b7ef3c2b133b481c34d0198b4c9..49e9a88d080177b4950be9e71ece2c8fb46b58f9 100644 (file)
--- a/doc/todo
+++ b/doc/todo
 - more complete pactl
 - cleanup tagstruct and modargs (add s32, pa_volume_t, pa_usec_t)
 - remove all gcc warnings
-- add total sample cache size to stat
 - make fragments settings runtime configurable
 - logging
 - automatic termination of daemon if unused
 - add sample directory
+- paman: show scache and sample size
 
 ** later ***
 - xmlrpc/http
index e650fb9fe3f70707e0291572dc59dde075345630..a4ecf5ee63fae28bd3722141070c5eee94262d40 100644 (file)
@@ -46,6 +46,7 @@ static void context_stat_callback(struct pa_pdispatch *pd, uint32_t command, uin
                pa_tagstruct_getu32(t, &i.memblock_total_size) < 0 ||
                pa_tagstruct_getu32(t, &i.memblock_allocated) < 0 ||
                pa_tagstruct_getu32(t, &i.memblock_allocated_size) < 0 ||
+               pa_tagstruct_getu32(t, &i.scache_size) < 0 ||
                !pa_tagstruct_eof(t)) {
         pa_context_fail(o->context, PA_ERROR_PROTOCOL);
         goto finish;
@@ -603,7 +604,8 @@ static void context_get_sample_info_callback(struct pa_pdispatch *pd, uint32_t c
                 pa_tagstruct_gets(t, &i.name) < 0 ||
                 pa_tagstruct_getu32(t, &i.volume) < 0 ||
                 pa_tagstruct_getu32(t, &i.duration) < 0 ||
-                pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0) {
+                pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
+                pa_tagstruct_getu32(t, &i.bytes) < 0) {
                 pa_context_fail(o->context, PA_ERROR_PROTOCOL);
                 goto finish;
             }
index 25a2db5e99b29a20b44d613e7eb21de68e76fbe8..1cc79d0fdce18c1bedcc4beb09ff413c0b84bca1 100644 (file)
@@ -180,6 +180,7 @@ struct pa_stat_info {
     uint32_t memblock_total_size;      /**< Currentl total size of allocated memory blocks */
     uint32_t memblock_allocated;       /**< Allocated memory blocks during the whole lifetime of the daemon */
     uint32_t memblock_allocated_size;  /**< Total size of all memory blocks allocated during the whole lifetime of the daemon */
+    uint32_t scache_size;              /**< Total size of all sample cache entries. \since 0.4 */ 
 };
 
 /** Get daemon memory block statistics */
@@ -192,6 +193,7 @@ struct pa_sample_info {
     pa_volume_t volume;                   /**< Default volume of this entry */
     struct pa_sample_spec sample_spec;    /**< Sample specification of the sampel */
     pa_usec_t duration;                   /**< Duration of this entry */
+    uint32_t bytes;                       /**< Length of this sample in bytes. \since 0.4 */
 };
 
 /** Get information about a sample by its name */
index 9dddf9a10f5c251652331588b2c3cdb5f81504e7..cce6cc6ca31dccdf6b48acc98bcadf27895564f7 100644 (file)
@@ -797,6 +797,7 @@ static void command_stat(struct pa_pdispatch *pd, uint32_t command, uint32_t tag
     pa_tagstruct_putu32(reply, c->protocol->core->memblock_stat->total_size);
     pa_tagstruct_putu32(reply, c->protocol->core->memblock_stat->allocated);
     pa_tagstruct_putu32(reply, c->protocol->core->memblock_stat->allocated_size);
+    pa_tagstruct_putu32(reply, pa_scache_total_size(c->protocol->core));
     pa_pstream_send_tagstruct(c->pstream, reply);
 }
 
@@ -1044,6 +1045,7 @@ static void scache_fill_tagstruct(struct pa_tagstruct *t, struct pa_scache_entry
     pa_tagstruct_putu32(t, e->volume);
     pa_tagstruct_putu32(t, pa_bytes_to_usec(e->memchunk.length, &e->sample_spec));
     pa_tagstruct_put_sample_spec(t, &e->sample_spec);
+    pa_tagstruct_putu32(t, e->memchunk.length);
 }
 
 static void command_get_info(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
index 311d68a42172a83c43822f614d58e306718ee36c..b7a8ff026185df8180e368330e68bc32dfdb91f1 100644 (file)
@@ -168,3 +168,18 @@ uint32_t pa_scache_get_id_by_name(struct pa_core *c, const char *name) {
 
     return e->index;
 }
+
+uint32_t pa_scache_total_size(struct pa_core *c) {
+    struct pa_scache_entry *e;
+    uint32_t index;
+    uint32_t sum;
+
+    if (!c->scache)
+        return 0;
+    
+    for (e = pa_idxset_first(c->scache, &index); e; e = pa_idxset_next(c->scache, &index))
+        sum += e->memchunk.length;
+
+
+    return sum;
+}
index 959067f3795f6fc5ae2b09437bcf8ccfb9051911..cfd479b57f9ace09e8dba68c4d339a5aa0971fd9 100644 (file)
@@ -44,4 +44,6 @@ void pa_scache_free(struct pa_core *c);
 const char *pa_scache_get_name_by_id(struct pa_core *c, uint32_t id);
 uint32_t pa_scache_get_id_by_name(struct pa_core *c, const char *name);
 
+uint32_t pa_scache_total_size(struct pa_core *c);
+
 #endif