void Handle_deinit(Handle* handle) { rassert(handle != NULL); del_Player(handle->length_counter); handle->length_counter = NULL; del_Player(handle->player); handle->player = NULL; del_Module(handle->module); handle->module = NULL; return; }
Module* new_Module(void) { Module* module = memory_alloc_item(Module); if (module == NULL) return NULL; if (!Device_init(&module->parent, false)) { memory_free(module); return NULL; } Device_set_existent(&module->parent, true); // Clear fields module->random_seed = 0; module->songs = NULL; module->album_is_existent = false; module->track_list = NULL; module->ch_defs = NULL; module->pats = NULL; module->au_map = NULL; module->au_controls = NULL; module->au_table = NULL; module->connections = NULL; module->is_dc_blocker_enabled = true; module->mix_vol_dB = COMP_DEFAULT_MIX_VOL; module->mix_vol = exp2(module->mix_vol_dB / 6); module->force_shift = 0; module->env = NULL; module->bind = NULL; for (int i = 0; i < KQT_SONGS_MAX; ++i) module->order_lists[i] = NULL; for (int i = 0; i < KQT_TUNING_TABLES_MAX; ++i) module->tuning_tables[i] = NULL; // Create fields module->songs = new_Song_table(); module->pats = new_Pat_table(KQT_PATTERNS_MAX); module->au_controls = new_Bit_array(KQT_CONTROLS_MAX); module->au_table = new_Au_table(KQT_AUDIO_UNITS_MAX); if (module->songs == NULL || module->pats == NULL || module->au_controls == NULL || module->au_table == NULL) { del_Module(module); return NULL; } module->env = new_Environment(); if (module->env == NULL) { del_Module(module); return NULL; } Streader* conn_sr = Streader_init(STREADER_AUTO, NULL, 0); module->connections = new_Connections_from_string(conn_sr, false, module->au_table, &module->parent); if (module->connections == NULL) { del_Module(module); return NULL; } return module; }