summaryrefslogtreecommitdiffstats
path: root/polyp/source.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-08-04 16:39:30 +0000
committerLennart Poettering <lennart@poettering.net>2004-08-04 16:39:30 +0000
commit46091a9237f17f4295dca7140d8d70b4fce8b357 (patch)
tree1c600cd6e1801586abfb66d767f2cd96e15c819c /polyp/source.c
parent24291aff27c671c11619684cb10d3b36fdf87c0d (diff)
introduce pa_xmalloc() and friends
implement module auto loading git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@103 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/source.c')
-rw-r--r--polyp/source.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/polyp/source.c b/polyp/source.c
index 13635414..65c90e9a 100644
--- a/polyp/source.c
+++ b/polyp/source.c
@@ -31,6 +31,7 @@
#include "source.h"
#include "source-output.h"
#include "namereg.h"
+#include "xmalloc.h"
struct pa_source* pa_source_new(struct pa_core *core, const char *name, int fail, const struct pa_sample_spec *spec) {
struct pa_source *s;
@@ -38,15 +39,14 @@ struct pa_source* pa_source_new(struct pa_core *core, const char *name, int fail
int r;
assert(core && spec && name && *name);
- s = malloc(sizeof(struct pa_source));
- assert(s);
+ s = pa_xmalloc(sizeof(struct pa_source));
if (!(name = pa_namereg_register(core, name, PA_NAMEREG_SOURCE, s, fail))) {
- free(s);
+ pa_xfree(s);
return NULL;
}
- s->name = strdup(name);
+ s->name = pa_xstrdup(name);
s->description = NULL;
s->owner = NULL;
@@ -84,9 +84,9 @@ void pa_source_free(struct pa_source *s) {
fprintf(stderr, "source: freed %u \"%s\"\n", s->index, s->name);
- free(s->name);
- free(s->description);
- free(s);
+ pa_xfree(s->name);
+ pa_xfree(s->description);
+ pa_xfree(s);
}
void pa_source_notify(struct pa_source*s) {
@@ -111,20 +111,6 @@ void pa_source_post(struct pa_source*s, struct pa_memchunk *chunk) {
pa_idxset_foreach(s->outputs, do_post, chunk);
}
-struct pa_source* pa_source_get_default(struct pa_core *c) {
- struct pa_source *source;
- assert(c);
-
- if ((source = pa_idxset_get_by_index(c->sources, c->default_source_index)))
- return source;
-
- if (!(source = pa_idxset_first(c->sources, &c->default_source_index)))
- return NULL;
-
- fprintf(stderr, "core: default source vanished, setting to %u.\n", source->index);
- return source;
-}
-
void pa_source_set_owner(struct pa_source *s, struct pa_module *m) {
assert(s);
s->owner = m;