blob: d4e7a50f266213135d2ed07fc9c08bc34a5917e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "sourceoutput.h"
struct source_output* source_output_new(struct source *s, struct sample_spec *spec, const char *name) {
struct source_output *o;
int r;
assert(s && spec);
o = malloc(sizeof(struct source_output));
assert(o);
o->name = name ? strdup(name) : NULL;
o->source = s;
o->spec = *spec;
o->push = NULL;
o->kill = NULL;
o->userdata = NULL;
assert(s->core);
r = idxset_put(s->core->source_outputs, o, &o->index);
assert(r == 0 && o->index != IDXSET_INVALID);
r = idxset_put(s->outputs, o, NULL);
assert(r == 0);
return o;
}
void source_output_free(struct source_output* o) {
assert(o);
assert(o->source && o->source->core);
idxset_remove_by_data(o->source->core->source_outputs, o, NULL);
idxset_remove_by_data(o->source->outputs, o, NULL);
free(o->name);
free(o);
}
void source_output_kill(struct source_output*i) {
assert(i);
if (i->kill)
i->kill(i);
}
|