2004-06-08 23:54:24 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2004-06-15 17:05:03 +00:00
|
|
|
#include "sinkinput.h"
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-06-15 17:05:03 +00:00
|
|
|
struct sink_input* sink_input_new(struct sink *s, struct sample_spec *spec, const char *name) {
|
|
|
|
|
struct sink_input *i;
|
2004-06-08 23:54:24 +00:00
|
|
|
int r;
|
|
|
|
|
assert(s && spec);
|
|
|
|
|
|
2004-06-15 17:05:03 +00:00
|
|
|
i = malloc(sizeof(struct sink_input));
|
2004-06-08 23:54:24 +00:00
|
|
|
assert(i);
|
|
|
|
|
i->name = name ? strdup(name) : NULL;
|
|
|
|
|
i->sink = s;
|
|
|
|
|
i->spec = *spec;
|
2004-06-15 00:29:01 +00:00
|
|
|
|
2004-06-15 17:05:03 +00:00
|
|
|
i->peek = NULL;
|
|
|
|
|
i->drop = NULL;
|
2004-06-14 20:30:50 +00:00
|
|
|
i->kill = NULL;
|
2004-06-15 17:05:03 +00:00
|
|
|
i->userdata = NULL;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
|
|
|
|
assert(s->core);
|
2004-06-15 17:05:03 +00:00
|
|
|
r = idxset_put(s->core->sink_inputs, i, &i->index);
|
2004-06-08 23:54:24 +00:00
|
|
|
assert(r == 0 && i->index != IDXSET_INVALID);
|
2004-06-15 17:05:03 +00:00
|
|
|
r = idxset_put(s->inputs, i, NULL);
|
2004-06-08 23:54:24 +00:00
|
|
|
assert(r == 0);
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-15 17:05:03 +00:00
|
|
|
void sink_input_free(struct sink_input* i) {
|
2004-06-08 23:54:24 +00:00
|
|
|
assert(i);
|
|
|
|
|
|
|
|
|
|
assert(i->sink && i->sink->core);
|
2004-06-15 17:05:03 +00:00
|
|
|
idxset_remove_by_data(i->sink->core->sink_inputs, i, NULL);
|
|
|
|
|
idxset_remove_by_data(i->sink->inputs, i, NULL);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
|
|
|
|
free(i->name);
|
|
|
|
|
free(i);
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-15 17:05:03 +00:00
|
|
|
void sink_input_kill(struct sink_input*i) {
|
2004-06-14 20:30:50 +00:00
|
|
|
assert(i);
|
|
|
|
|
|
|
|
|
|
if (i->kill)
|
2004-06-15 17:05:03 +00:00
|
|
|
i->kill(i);
|
2004-06-15 00:29:01 +00:00
|
|
|
}
|