Connections* new_Connections_from_string( Streader* sr, Connection_level level, Au_table* au_table, Device* master) { rassert(sr != NULL); rassert(au_table != NULL); rassert(master != NULL); if (Streader_is_error_set(sr)) return NULL; Connections* graph = memory_alloc_item(Connections); if (graph == NULL) { Streader_set_memory_error( sr, "Could not allocate memory for connections"); return NULL; } graph->nodes = NULL; graph->nodes = new_AAtree( (int (*)(const void*, const void*))Device_node_cmp, (void (*)(void*))del_Device_node); mem_error_if(graph->nodes == NULL, graph, NULL, sr); Device_node* master_node = NULL; if (level == CONNECTION_LEVEL_AU) { const Device* iface = Audio_unit_get_output_interface((Audio_unit*)master); master_node = new_Device_node("", au_table, iface); } else { master_node = new_Device_node("", au_table, master); } mem_error_if(master_node == NULL, graph, NULL, sr); mem_error_if(!AAtree_ins(graph->nodes, master_node), graph, master_node, sr); if (!Streader_has_data(sr)) return graph; read_conn_data rcdata = { graph, level, au_table, master }; if (!Streader_read_list(sr, read_connection, &rcdata)) { del_Connections(graph); return NULL; } if (Connections_is_cyclic(graph)) { Streader_set_error(sr, "The connection graph contains a cycle"); del_Connections(graph); return NULL; } return graph; }
void del_Module(Module* module) { if (module == NULL) return; del_Environment(module->env); del_Song_table(module->songs); del_Pat_table(module->pats); del_Connections(module->connections); del_Au_table(module->au_table); del_Bit_array(module->au_controls); del_Input_map(module->au_map); del_Track_list(module->track_list); del_Channel_defaults_list(module->ch_defs); for (int i = 0; i < KQT_SONGS_MAX; ++i) del_Order_list(module->order_lists[i]); for (int i = 0; i < KQT_TUNING_TABLES_MAX; ++i) del_Tuning_table(module->tuning_tables[i]); del_Bind(module->bind); Device_deinit(&module->parent); memory_free(module); return; }
void Effect_set_connections(Effect* eff, Connections* graph) { assert(eff != NULL); //fprintf(stderr, "Set new connections for %p: %p\n", (void*)eff, (void*)graph); del_Connections(eff->connections); eff->connections = graph; return; }
void del_Effect(Effect* eff) { if (eff == NULL) return; del_Effect_interface(eff->out_iface); del_Effect_interface(eff->in_iface); del_Connections(eff->connections); del_DSP_table(eff->dsps); Device_deinit(&eff->parent); memory_free(eff); return; }