remove global exported variables:

pa_memblock statistics
  pa_default_sample_spec


git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@70 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2004-07-15 20:12:21 +00:00
parent 1a6fea24f5
commit c36dadd2bd
11 changed files with 30 additions and 27 deletions

View 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;
}

View 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;

View 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);

View 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;
}

View 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

View 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;

View 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;

View 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;

View 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);

View 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)

View file

@ -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