Device_thread_state* new_Device_thread_state( uint32_t device_id, int32_t audio_buffer_size) { rassert(audio_buffer_size >= 0); Device_thread_state* ts = memory_alloc_item(Device_thread_state); if (ts == NULL) return NULL; ts->device_id = device_id; ts->audio_buffer_size = audio_buffer_size; ts->node_state = DEVICE_NODE_STATE_NEW; ts->has_mixed_audio = false; ts->in_connected = NULL; for (Device_buffer_type buf_type = DEVICE_BUFFER_MIXED; buf_type < DEVICE_BUFFER_TYPES; ++buf_type) { for (Device_port_type port_type = DEVICE_PORT_TYPE_RECV; port_type < DEVICE_PORT_TYPES; ++port_type) ts->buffers[buf_type][port_type] = NULL; } ts->in_connected = new_Bit_array(KQT_DEVICE_PORTS_MAX); if (ts->in_connected == NULL) { del_Device_thread_state(ts); return NULL; } for (Device_buffer_type buf_type = DEVICE_BUFFER_MIXED; buf_type < DEVICE_BUFFER_TYPES; ++buf_type) { for (Device_port_type port_type = DEVICE_PORT_TYPE_RECV; port_type < DEVICE_PORT_TYPES; ++port_type) { ts->buffers[buf_type][port_type] = new_Etable(KQT_DEVICE_PORTS_MAX, (void (*)(void*))del_Work_buffer); if (ts->buffers[buf_type][port_type] == NULL) { del_Device_thread_state(ts); return NULL; } } } return ts; }
DSP_table* new_DSP_table(int size) { assert(size > 0); DSP_table* table = memory_alloc_item(DSP_table); if (table == NULL) return NULL; table->dsps = NULL; table->existents = NULL; table->dsps = new_Etable(size, (void (*)(void*))del_DSP); table->existents = new_Bit_array(size); if (table->dsps == NULL || table->existents == NULL) { del_DSP_table(table); return NULL; } table->size = size; return table; }
Pat_table* new_Pat_table(int size) { rassert(size > 0); Pat_table* table = memory_alloc_item(Pat_table); if (table == NULL) return NULL; table->pats = NULL; table->existents = NULL; table->pats = new_Etable(size, (void (*)(void*))del_Pattern); table->existents = new_Bit_array(size); if (table->pats == NULL || table->existents == NULL) { del_Pat_table(table); return NULL; } table->size = size; return table; }