10 struct core* core_new(struct mainloop *m) {
12 c = malloc(sizeof(struct core));
16 c->clients = idxset_new(NULL, NULL);
17 c->sinks = idxset_new(NULL, NULL);
18 c->sources = idxset_new(NULL, NULL);
19 c->source_outputs = idxset_new(NULL, NULL);
20 c->sink_inputs = idxset_new(NULL, NULL);
22 c->default_source_index = c->default_sink_index = IDXSET_INVALID;
29 void core_free(struct core *c) {
35 assert(idxset_isempty(c->clients));
36 idxset_free(c->clients, NULL, NULL);
38 assert(idxset_isempty(c->sinks));
39 idxset_free(c->sinks, NULL, NULL);
41 assert(idxset_isempty(c->sources));
42 idxset_free(c->sources, NULL, NULL);
44 assert(idxset_isempty(c->source_outputs));
45 idxset_free(c->source_outputs, NULL, NULL);
47 assert(idxset_isempty(c->sink_inputs));
48 idxset_free(c->sink_inputs, NULL, NULL);
53 struct sink* core_get_default_sink(struct core *c) {
57 if ((sink = idxset_get_by_index(c->sinks, c->default_sink_index)))
60 if (!(sink = idxset_first(c->sinks, &c->default_sink_index)))
63 fprintf(stderr, "core: default sink vanished, setting to %u.\n", sink->index);
67 struct source* core_get_default_source(struct core *c) {
68 struct source *source;
71 if ((source = idxset_get_by_index(c->sources, c->default_source_index)))
74 if (!(source = idxset_first(c->sources, &c->default_source_index)))
77 fprintf(stderr, "core: default source vanished, setting to %u.\n", source->index);