Compare commits
No commits in common. "9f876162e5e0f979dc93eb7f7e9de83b86d148bd" and "245563ec8b165b03bdf733f6bbf5519bab4d3c71" have entirely different histories.
9f876162e5
...
245563ec8b
2
Makefile
2
Makefile
|
@ -12,7 +12,7 @@ CPPFLAGS += $(shell pkg-config --cflags $(DEPS))
|
||||||
LDLIBS += $(shell pkg-config --libs $(DEPS))
|
LDLIBS += $(shell pkg-config --libs $(DEPS))
|
||||||
INTERP ?=
|
INTERP ?=
|
||||||
MAIN = main
|
MAIN = main
|
||||||
OBJS = main.o events.o processing.o graph.o config.o hash_table.o module_registry.o nodes/getchar.o nodes/print.o nodes/evdev.o nodes/tee.o
|
OBJS = main.o events.o processing.o graph.o config.o hash_table.o module_registry.o nodes/getchar.o nodes/print.o nodes/evdev.o
|
||||||
|
|
||||||
all: $(MAIN)
|
all: $(MAIN)
|
||||||
|
|
||||||
|
|
18
config.c
18
config.c
|
@ -135,21 +135,3 @@ load_config(const config_setting_t *config_root, FullConfig *config)
|
||||||
config->channels = load_channels_section(channel_config);
|
config->channels = load_channels_section(channel_config);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
reset_config(FullConfig *config)
|
|
||||||
{
|
|
||||||
if (!config) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (config->nodes.items) {
|
|
||||||
free(config->nodes.items);
|
|
||||||
config->nodes.items = NULL;
|
|
||||||
config->nodes.length = 0;
|
|
||||||
}
|
|
||||||
if (config->channels.items) {
|
|
||||||
free(config->channels.items);
|
|
||||||
config->channels.items = NULL;
|
|
||||||
config->channels.length = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
1
config.h
1
config.h
|
@ -33,6 +33,5 @@ typedef struct {
|
||||||
} FullConfig;
|
} FullConfig;
|
||||||
|
|
||||||
bool load_config(const config_setting_t *config_root, FullConfig *config);
|
bool load_config(const config_setting_t *config_root, FullConfig *config);
|
||||||
void reset_config(FullConfig *config);
|
|
||||||
|
|
||||||
#endif /* end of include guard: CONFIG_H_ */
|
#endif /* end of include guard: CONFIG_H_ */
|
||||||
|
|
14
events.c
14
events.c
|
@ -25,7 +25,7 @@ event_replicate(EventNode * source, size_t count)
|
||||||
replica->data.modifiers = modifier_set_copy(source->data.modifiers);
|
replica->data.modifiers = modifier_set_copy(source->data.modifiers);
|
||||||
replica->prev = source;
|
replica->prev = source;
|
||||||
replica->next = source->next;
|
replica->next = source->next;
|
||||||
source->next->prev = replica;
|
source->next->next->prev = replica;
|
||||||
source->next = replica;
|
source->next = replica;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
@ -72,15 +72,3 @@ event_destroy(EventNode * self)
|
||||||
self->next = NULL;
|
self->next = NULL;
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_destroy_all()
|
|
||||||
{
|
|
||||||
EventNode *ev;
|
|
||||||
while ((ev = FIRST_EVENT) != &END_EVENTS) {
|
|
||||||
event_destroy(ev);
|
|
||||||
if (ev == FIRST_EVENT) {
|
|
||||||
fprintf(stderr, "Broken doubly linked event list invariant\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
1
events.h
1
events.h
|
@ -47,6 +47,5 @@ extern EventNode END_EVENTS;
|
||||||
size_t event_replicate(EventNode * source, size_t count);
|
size_t event_replicate(EventNode * source, size_t count);
|
||||||
EventNode * event_create(const EventData * content);
|
EventNode * event_create(const EventData * content);
|
||||||
void event_destroy(EventNode * self);
|
void event_destroy(EventNode * self);
|
||||||
void event_destroy_all();
|
|
||||||
|
|
||||||
#endif /* end of include guard: EVENTS_H_ */
|
#endif /* end of include guard: EVENTS_H_ */
|
||||||
|
|
2
main.c
2
main.c
|
@ -82,11 +82,9 @@ main(int argc, char ** argv)
|
||||||
for (ssize_t i = loaded_config.nodes.length - 1; i >= 0; --i) {
|
for (ssize_t i = loaded_config.nodes.length - 1; i >= 0; --i) {
|
||||||
graph_node_delete(nodes[i]);
|
graph_node_delete(nodes[i]);
|
||||||
}
|
}
|
||||||
event_destroy_all();
|
|
||||||
free(channels);
|
free(channels);
|
||||||
free(nodes);
|
free(nodes);
|
||||||
|
|
||||||
reset_config(&loaded_config);
|
|
||||||
config_destroy(&config_tree);
|
config_destroy(&config_tree);
|
||||||
|
|
||||||
io_subscription_list_deinit(&state.wait_output);
|
io_subscription_list_deinit(&state.wait_output);
|
||||||
|
|
60
nodes/tee.c
60
nodes/tee.c
|
@ -1,60 +0,0 @@
|
||||||
#include "../graph.h"
|
|
||||||
#include "../module_registry.h"
|
|
||||||
|
|
||||||
static bool
|
|
||||||
handle_event(EventPositionBase * self, EventNode * event)
|
|
||||||
{
|
|
||||||
GraphNode *node = DOWNCAST(GraphNode, EventPositionBase, self);
|
|
||||||
size_t count = node->outputs.length;
|
|
||||||
if (!count) {
|
|
||||||
event_destroy(event);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (count > 1) {
|
|
||||||
count = event_replicate(event, count - 1) + 1;
|
|
||||||
}
|
|
||||||
for (size_t i = 0; i < count; ++i) {
|
|
||||||
event->position = &node->outputs.elements[i]->as_EventPositionBase;
|
|
||||||
event = event->next;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GraphNode *
|
|
||||||
create(GraphNodeSpecification * spec, GraphNodeConfig * config)
|
|
||||||
{
|
|
||||||
(void) config;
|
|
||||||
GraphNode * node = T_ALLOC(1, GraphNode);
|
|
||||||
if (!node) {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
*node = (GraphNode) {
|
|
||||||
.as_EventPositionBase = {
|
|
||||||
.handle_event = &handle_event,
|
|
||||||
.waiting_new_event = false,
|
|
||||||
},
|
|
||||||
.specification = spec,
|
|
||||||
.inputs = EMPTY_GRAPH_CHANNEL_LIST,
|
|
||||||
.outputs = EMPTY_GRAPH_CHANNEL_LIST,
|
|
||||||
};
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void destroy
|
|
||||||
(GraphNodeSpecification * self, GraphNode * target)
|
|
||||||
{
|
|
||||||
(void) self;
|
|
||||||
free(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
GraphNodeSpecification nodespec_tee = (GraphNodeSpecification) {
|
|
||||||
.create = &create,
|
|
||||||
.destroy = &destroy,
|
|
||||||
.register_io = NULL,
|
|
||||||
.name = "tee",
|
|
||||||
};
|
|
||||||
|
|
||||||
MODULE_CONSTRUCTOR(init)
|
|
||||||
{
|
|
||||||
register_graph_node_specification(&nodespec_tee);
|
|
||||||
}
|
|
Loading…
Reference in New Issue