diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cli-command.c | 2 | ||||
-rw-r--r-- | src/core.c | 4 | ||||
-rw-r--r-- | src/core.h | 3 | ||||
-rw-r--r-- | src/memblock.c | 25 | ||||
-rw-r--r-- | src/memblock.h | 3 | ||||
-rw-r--r-- | src/modargs.c | 2 | ||||
-rw-r--r-- | src/module-pipe-sink.c | 1 | ||||
-rw-r--r-- | src/protocol-simple.c | 1 | ||||
-rw-r--r-- | src/sample-util.c | 6 | ||||
-rw-r--r-- | src/sample-util.h | 4 | ||||
-rw-r--r-- | src/todo | 6 |
11 files changed, 30 insertions, 27 deletions
diff --git a/src/cli-command.c b/src/cli-command.c index bf3ab0c4..0c754c7e 100644 --- a/src/cli-command.c +++ b/src/cli-command.c @@ -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; } @@ -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; @@ -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); diff --git a/src/memblock.c b/src/memblock.c index 2dfa6a9c..17038861 100644 --- a/src/memblock.c +++ b/src/memblock.c @@ -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; +} diff --git a/src/memblock.h b/src/memblock.h index 2635f023..647a1c8c 100644 --- a/src/memblock.h +++ b/src/memblock.h @@ -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 diff --git a/src/modargs.c b/src/modargs.c index a716a80e..a4ef9af7 100644 --- a/src/modargs.c +++ b/src/modargs.c @@ -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; diff --git a/src/module-pipe-sink.c b/src/module-pipe-sink.c index 29767ea8..0a24f759 100644 --- a/src/module-pipe-sink.c +++ b/src/module-pipe-sink.c @@ -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; diff --git a/src/protocol-simple.c b/src/protocol-simple.c index 89207133..4b52a246 100644 --- a/src/protocol-simple.c +++ b/src/protocol-simple.c @@ -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; diff --git a/src/sample-util.c b/src/sample-util.c index 5344ecfa..c7a7b679 100644 --- a/src/sample-util.c +++ b/src/sample-util.c @@ -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); diff --git a/src/sample-util.h b/src/sample-util.h index 6a593b9a..4efa59a4 100644 --- a/src/sample-util.h +++ b/src/sample-util.h @@ -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) @@ -11,11 +11,6 @@ - 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 |