]> code.delx.au - pulseaudio/commitdiff
remove global exported variables:
authorLennart Poettering <lennart@poettering.net>
Thu, 15 Jul 2004 20:12:21 +0000 (20:12 +0000)
committerLennart Poettering <lennart@poettering.net>
Thu, 15 Jul 2004 20:12:21 +0000 (20:12 +0000)
  pa_memblock statistics
  pa_default_sample_spec

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

src/cli-command.c
src/core.c
src/core.h
src/memblock.c
src/memblock.h
src/modargs.c
src/module-pipe-sink.c
src/protocol-simple.c
src/sample-util.c
src/sample-util.h
src/todo

index bf3ab0c4ee6bdb0ab38557630db207d945a82041..0c754c7e6c718e386ffb35c6973f26aa04cb45b8 100644 (file)
@@ -161,7 +161,7 @@ static int pa_cli_command_source_outputs(struct pa_core *c, struct pa_tokenizer
 
 static int pa_cli_command_stat(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail, int *verbose) {
     assert(c && t);
-    pa_strbuf_printf(buf, "Memory blocks allocated: %u, total size: %u bytes.\n", pa_memblock_count, pa_memblock_total);
+    pa_strbuf_printf(buf, "Memory blocks allocated: %u, total size: %u bytes.\n", pa_memblock_get_count(), pa_memblock_get_total());
     return 0;
 }
 
index a1fe7d977a3ff934e33b73d7c8fa6488780bb33e..987bcc18c8f66f3af5f0e29287133e5a81a62bb4 100644 (file)
@@ -26,6 +26,10 @@ struct pa_core* pa_core_new(struct pa_mainloop_api *m) {
     c->modules = NULL;
     c->namereg = NULL;
 
+    c->default_sample_spec.format = PA_SAMPLE_S16NE;
+    c->default_sample_spec.rate = 44100;
+    c->default_sample_spec.channels = 2;
+    
     pa_check_for_sigpipe();
     
     return c;
index 13374e4004985ceffa78d67c7e94f77c75eaa6f5..ee5bfc413613207e51f42dfb798d123476dc081d 100644 (file)
@@ -4,6 +4,7 @@
 #include "idxset.h"
 #include "hashmap.h"
 #include "mainloop-api.h"
+#include "sample.h"
 
 struct pa_core {
     struct pa_mainloop_api *mainloop;
@@ -13,6 +14,8 @@ struct pa_core {
     struct pa_hashmap *namereg;
     
     uint32_t default_source_index, default_sink_index;
+
+    struct pa_sample_spec default_sample_spec;
 };
 
 struct pa_core* pa_core_new(struct pa_mainloop_api *m);
index 2dfa6a9c1bddda47eb034766087e3fe0734a37ec..17038861f92bf071494e5e19f4fdc0c8caab5178 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "memblock.h"
 
-unsigned pa_memblock_count = 0, pa_memblock_total = 0;
+static unsigned memblock_count = 0, memblock_total = 0;
 
 struct pa_memblock *pa_memblock_new(size_t length) {
     struct pa_memblock *b = malloc(sizeof(struct pa_memblock)+length);
@@ -13,8 +13,8 @@ struct pa_memblock *pa_memblock_new(size_t length) {
     b->ref = 1;
     b->length = length;
     b->data = b+1;
-    pa_memblock_count++;
-    pa_memblock_total += length;
+    memblock_count++;
+    memblock_total += length;
     return b;
 }
 
@@ -24,8 +24,8 @@ struct pa_memblock *pa_memblock_new_fixed(void *d, size_t length) {
     b->ref = 1;
     b->length = length;
     b->data = d;
-    pa_memblock_count++;
-    pa_memblock_total += length;
+    memblock_count++;
+    memblock_total += length;
     return b;
 }
 
@@ -35,8 +35,8 @@ struct pa_memblock *pa_memblock_new_dynamic(void *d, size_t length) {
     b->ref = 1;
     b->length = length;
     b->data = d;
-    pa_memblock_count++;
-    pa_memblock_total += length;
+    memblock_count++;
+    memblock_total += length;
     return b;
 }
 
@@ -54,8 +54,8 @@ void pa_memblock_unref(struct pa_memblock*b) {
         if (b->type == PA_MEMBLOCK_DYNAMIC)
             free(b->data);
 
-        pa_memblock_count--;
-        pa_memblock_total -= b->length;
+        memblock_count--;
+        memblock_total -= b->length;
 
         free(b);
     }
@@ -79,3 +79,10 @@ void pa_memblock_unref_fixed(struct pa_memblock *b) {
     }
 }
 
+unsigned pa_memblock_get_count(void) {
+    return memblock_count;
+}
+
+unsigned pa_memblock_get_total(void) {
+    return memblock_total;
+}
index 2635f023fbbb87862c2d30f804915a20c23a0130..647a1c8c553e8419da4616d985184836a64fa1ad 100644 (file)
@@ -22,6 +22,7 @@ struct pa_memblock* pa_memblock_ref(struct pa_memblock*b);
 
 void pa_memblock_unref_fixed(struct pa_memblock*b);
 
-extern unsigned pa_memblock_count, pa_memblock_total;
+unsigned pa_memblock_get_count(void);
+unsigned pa_memblock_get_total(void);
 
 #endif
index a716a80e162646497e6e438f712fa3c0d06e2dd1..a4ef9af79fd5b784d95bba1638b38e63aea72b14 100644 (file)
@@ -188,7 +188,7 @@ int pa_modargs_get_sample_spec(struct pa_modargs *ma, struct pa_sample_spec *rss
     struct pa_sample_spec ss;
     assert(ma && rss);
 
-    ss = pa_default_sample_spec;
+    ss = *rss;
     if ((pa_modargs_get_value_u32(ma, "rate", &ss.rate)) < 0)
         return -1;
 
index 29767ea8017187363e74f09a1e8e77234c136d35..0a24f7599f678411ec193b52cea7bc292c86897b 100644 (file)
@@ -101,6 +101,7 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
         goto fail;
     }
 
+    ss = c->default_sample_spec;
     if (pa_modargs_get_sample_spec(ma, &ss) < 0) {
         fprintf(stderr, __FILE__": invalid sample format specification\n");
         goto fail;
index 89207133c1c6305d4be45e2db354ac7937a251a6..4b52a2463204245c27097afaaaa4e8d915082c0c 100644 (file)
@@ -355,6 +355,7 @@ struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct p
     p->server = server;
     p->connections = pa_idxset_new(NULL, NULL);
 
+    p->sample_spec = core->default_sample_spec;
     if (pa_modargs_get_sample_spec(ma, &p->sample_spec) < 0) {
         fprintf(stderr, "Failed to parse sample type specification.\n");
         goto fail;
index 5344ecfad9b7950c3c0a8a91db37fcb538bb52b7..c7a7b679b94f01be3d7e7af5e23c76aac940bd7b 100644 (file)
@@ -4,12 +4,6 @@
 
 #include "sample-util.h"
 
-struct pa_sample_spec pa_default_sample_spec = {
-    .format = PA_SAMPLE_S16NE,
-    .rate = 44100,
-    .channels = 2
-};
-
 struct pa_memblock *pa_silence_memblock(struct pa_memblock* b, const struct pa_sample_spec *spec) {
     assert(b && b->data && spec);
     pa_silence_memory(b->data, b->length, spec);
index 6a593b9a459d27027640a23c775101fd10018371..4efa59a47173e02e75dc4d8c678890c3f3278a57 100644 (file)
@@ -5,10 +5,6 @@
 #include "memblock.h"
 #include "memchunk.h"
 
-#define PA_DEFAULT_SAMPLE_SPEC pa_default_sample_spec
-
-extern struct pa_sample_spec pa_default_sample_spec;
-
 #define PA_VOLUME_NORM (0x100)
 #define PA_VOLUME_MUTE (0)
 
index 963b57fda66f857da89520c7337b93b788bd906f..5eb4329d29d8f4ae6fa0daac3d8520665ea3a2ab 100644 (file)
--- a/src/todo
+++ b/src/todo
 - svn-id and license in every file
 - documentation
 
-- eliminate global variables:
-            pa_default_sample_spec
-            pa_memblock_count
-            pa_memblock_total
-
 -- post 0.1
 - future cancellation
 - client-ui
@@ -25,6 +20,7 @@
 - doxygen
 - make mcalign merge chunks
 - modinfo
+- move the global memblock statistics variables to the core
 
 drivers:
 - libao