summaryrefslogtreecommitdiffstats
path: root/src/source.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-06-08 23:54:24 +0000
committerLennart Poettering <lennart@poettering.net>2004-06-08 23:54:24 +0000
commit9cb0b933e260008c6a03e24a4a149f726b8d86b2 (patch)
treeb54651bafe32d1a817e779f884d1628176465bf0 /src/source.c
parentb1c00dcd0ae51d201f772e7f5fa61acae436a2cf (diff)
initial commit
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@3 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/source.c')
-rw-r--r--src/source.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/source.c b/src/source.c
new file mode 100644
index 00000000..2f34c461
--- /dev/null
+++ b/src/source.c
@@ -0,0 +1,58 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "source.h"
+#include "outputstream.h"
+
+struct source* source_new(struct core *core, const char *name, const struct sample_spec *spec) {
+ struct source *s;
+ int r;
+ assert(core && spec);
+
+ s = malloc(sizeof(struct source));
+ assert(s);
+
+ s->name = name ? strdup(name) : NULL;
+ r = idxset_put(core->sources, s, &s->index);
+ assert(s->index != IDXSET_INVALID && r >= 0);
+
+ s->core = core;
+ s->sample_spec = *spec;
+ s->output_streams = idxset_new(NULL, NULL);
+
+ s->link_change_callback = NULL;
+ s->userdata = NULL;
+
+ return s;
+}
+
+static void do_free(void *p, void *userdata) {
+ struct output_stream *o = p;
+ assert(o);
+ output_stream_free(o);
+};
+
+void source_free(struct source *s) {
+ assert(s);
+
+ idxset_remove_by_data(s->core->sources, s, NULL);
+ idxset_free(s->output_streams, do_free, NULL);
+ free(s->name);
+ free(s);
+}
+
+static int do_post(void *p, uint32_t index, int *del, void*userdata) {
+ struct memchunk *chunk = userdata;
+ struct output_stream *o = p;
+ assert(o && o->memblockq && index && del && chunk);
+
+ memblockq_push(o->memblockq, chunk, 0);
+ return 0;
+}
+
+void source_post(struct source*s, struct memchunk *chunk) {
+ assert(s && chunk);
+
+ idxset_foreach(s->output_streams, do_post, chunk);
+}