void undoEdit(UndoStruct *u) /* * Undo an edit of composite command */ { if (u==NULL) return; switch(u->command) { case UndoShiftRight: _shift_right( u->db, u->sequence, u->info.shift_right.num_bases, u->info.shift_right.flags ); break; case UndoShiftLeft: _shift_left( u->db, u->sequence, u->info.shift_left.num_bases, u->info.shift_left.flags ); break; case UndoDeleteBases: _delete_bases( u->db, u->sequence, u->info.delete_bases.position, u->info.delete_bases.num_bases, u->info.delete_bases.flags ); break; case UndoReplaceBases: { char *bases; int1 *conf; int2 *opos; getBCO(&u->info.replace_bases.b_c_o, &bases, &conf, &opos); _replace_bases( u->db, u->sequence, u->info.replace_bases.position, u->info.replace_bases.num_bases, bases, conf, opos, u->info.replace_bases.flags & ~DB_FLAG_TMP, u->info.replace_bases.flags & DB_FLAG_TMP_DIFF_ONLY, u->info.replace_bases.flags & DB_FLAG_TMP_CONF_ONLY ); break; } case UndoInsertBases: { char *bases; int1 *conf; int2 *opos; getBCO(&u->info.replace_bases.b_c_o, &bases, &conf, &opos); _insert_bases( u->db, u->sequence, u->info.insert_bases.position, u->info.insert_bases.num_bases, bases, conf, opos, u->info.insert_bases.flags, u->info.insert_bases.cutoff); break; } case UndoReorderSeq: _reorder_seq( u->db, u->sequence, u->info.reorder_seq.old_id, u->info.reorder_seq.new_id, u->info.reorder_seq.flags ); break; case UndoConsensusLength: _DBsetLength( u->db, 0, u->info.consensus_length.num_bases ); _DBsetLength2( u->db, 0, u->info.consensus_length.num_bases ); break; case UndoAdjustCursor: /* Only do if the EdStruct hasn't been reallocated */ if (u->info.adjust_cursor.xx->editor_id == u->info.adjust_cursor.editor_id) { setCursorPosSeq(u->info.adjust_cursor.xx, u->info.adjust_cursor.position, u->sequence); } break; case UndoAdjustDisplay: /* Only do if the EdStruct hasn't been reallocated */ if (u->info.adjust_display.xx->editor_id == u->info.adjust_display.editor_id) { u->info.adjust_display.xx->displayPos += u->info.adjust_display.position; } break; /* * Annotation manipulation */ case UndoAdjustPositionAnnotation: _adjust_position_annotation( u->db, u->sequence, u->info.adjust_position_annotation.tag, u->info.adjust_position_annotation.position, u->info.adjust_position_annotation.seq_flags, u->info.adjust_position_annotation.tag_flags ); break; case UndoAdjustLengthAnnotation: _adjust_length_annotation( u->db, u->sequence, u->info.adjust_length_annotation.tag, u->info.adjust_length_annotation.length, u->info.adjust_length_annotation.seq_flags, u->info.adjust_length_annotation.tag_flags ); break; case UndoInsertAnnotation: _insert_annotation( u->db, u->sequence, u->info.insert_annotation.tag, u->info.insert_annotation.new_tag, u->info.insert_annotation.seq_flags ); /* to unsure the following is not reclaimed during garbage collect */ u->info.insert_annotation.new_tag = NULL; break; case UndoDeleteAnnotation: _delete_annotation( u->db, u->sequence, u->info.delete_annotation.tag, u->info.delete_annotation.seq_flags ); /* garbage collect */ freeTag(u->info.delete_annotation.old_tag); break; case UndoDestroyAnnotation: _destroy_annotation( u->db, u->info.destroy_annotation.xx, u->sequence, u->info.destroy_annotation.tag, u->info.destroy_annotation.seq_flags ); break; /* * Edit manipulation */ case UndoAdjustEnds: _adjust_ends( u->db, u->sequence, u->info.adjust_ends.start_bases, u->info.adjust_ends.end_bases, u->info.adjust_ends.seq_flags ); break; case UndoAdjustBaseConf: _adjust_base_conf( u->db, u->sequence, u->info.adjust_base_conf.position, u->info.adjust_base_conf.conf, u->info.adjust_base_conf.opos, u->info.adjust_base_conf.flags ); break; case UndoTransposeBases: _transpose_bases( u->db, u->sequence, u->info.transpose_bases.position, u->info.transpose_bases.flags ); break; case UndoSetFlags: _set_flags( u->db, u->sequence, u->info.set_flags.flags ); break; case UndoSetReferenceSeq: _set_reference_seq( u->db, u->sequence, u->info.set_reference_seq.flags, u->info.set_reference_seq.refseq, u->info.set_reference_seq.length, u->info.set_reference_seq.offset ); break; default: break; } }
input_module_t *roar_open_module(module_param_t *params) { input_module_t *mod = calloc(1, sizeof(input_module_t)); im_roar_state *s; module_param_t *current; const char * server = NULL; int dir = ROAR_DIR_MONITOR; enum { MD_NONE = 0, MD_FILE = 1, MD_STREAM = 2 } use_metadata = MD_STREAM; int err; mod->getdata = roar_read; mod->handle_event = event_handler; mod->metadata_update = metadata_update; mod->internal = calloc(1, sizeof(im_roar_state)); s = mod->internal; if(roar_profile2info(&s->info, "default") == -1) { LOG_ERROR1("Failed to get default audio profile: %s", roar_error2str(roar_error)); return NULL; } s->info.bits = 16; s->vss = NULL; s->plugins = roar_plugincontainer_new_simple(IM_ROAR_APPNAME, IM_ROAR_ABIVERSION); if (!s->plugins) { LOG_ERROR1("Failed to create plugin container: %s", roar_error2str(roar_error)); return NULL; } thread_mutex_create(&s->metadatalock); current = params; while(current) { if(!strcmp(current->name, "rate")) s->info.rate = roar_str2rate(current->value); else if(!strcmp(current->name, "channels")) s->info.channels = roar_str2channels(current->value); else if(!strcmp(current->name, "codec")) s->info.codec = roar_str2codec(current->value); else if(!strcmp(current->name, "aiprofile")) { if (roar_profile2info(&s->info, current->value) == -1) { LOG_WARN2("Can not get audio info profile %s: %s", current->value, roar_error2str(roar_error)); } s->info.bits = 16; } else if(!strcmp(current->name, "dir")) { if ( !strcasecmp(current->value, "monitor") ) { dir = ROAR_DIR_MONITOR; } else if ( !strcasecmp(current->value, "record") ) { dir = ROAR_DIR_RECORD; } else { LOG_WARN2("Unknown value %s for parameter %s for roar module", current->value, current->name); } } else if(!strcmp(current->name, "device") || !strcmp(current->name, "server")) server = current->value; else if(!strcmp(current->name, "metadata")) { if ( !strcasecmp(current->value, "none") ) { use_metadata = MD_NONE; } else if ( !strcasecmp(current->value, "file") ) { use_metadata = MD_FILE; } else if ( !strcasecmp(current->value, "stream") ) { use_metadata = MD_STREAM; } else { use_metadata = atoi(current->value); } } else if(!strcmp(current->name, "metadatafilename")) { ices_config->metadata_filename = current->value; use_metadata = MD_FILE; } else if(!strcmp(current->name, "plugin")) { roar_plugin_load(mod, current->value); } else LOG_WARN1("Unknown parameter %s for roar module", current->name); current = current->next; } mod->type = ICES_INPUT_PCM; switch (s->info.codec) { case ROAR_CODEC_PCM_LE: mod->subtype = INPUT_PCM_LE_16; break; case ROAR_CODEC_PCM_BE: mod->subtype = INPUT_PCM_BE_16; break; case ROAR_CODEC_OGG_GENERAL: LOG_WARN0("Codec may not work, specify ogg_vorbis for Vorbis streaming"); case ROAR_CODEC_OGG_VORBIS: mod->type = ICES_INPUT_VORBIS; // we do not set mod->subtype here, strange design ices2 has... break; case -1: LOG_ERROR0("Unknown Codec"); return NULL; default: LOG_ERROR1("Unsupported Codec: %s", roar_codec2str(s->info.codec)); return NULL; } roar_plugincontainer_appsched_trigger(s->plugins, ROAR_DL_APPSCHED_INIT); /* Open the VS connection */ if ( (s->vss = roar_vs_new(server, IM_ROAR_PROGNAME, &err)) == NULL ) { LOG_ERROR2("Failed to open sound server %s: %s", server, roar_vs_strerr(err)); goto fail; } /* Now, set the required parameters on that device */ if ( roar_vs_stream(s->vss, &s->info, dir, &err) == -1 ) { LOG_ERROR2("Failed to create a new stream on sound server %s: %s", server, roar_vs_strerr(err)); goto fail; } if ( _set_flags(roar_vs_connection_obj(s->vss, NULL), roar_vs_stream_obj(s->vss, NULL), ROAR_FLAG_META, ROAR_RESET_FLAG) != 0 ) { LOG_WARN0("Can not reset metadata flag from stream"); } /* We're done, and we didn't fail! */ LOG_INFO3("Opened sound server at %s at %d channel(s), %d Hz", server, s->info.channels, s->info.rate); switch (use_metadata) { case MD_NONE: break; case MD_FILE: LOG_INFO0("Starting metadata update thread"); if(ices_config->metadata_filename) thread_create("im_roar-metadata", metadata_thread_signal, mod, 1); else thread_create("im_roar-metadata", metadata_thread_stdin, mod, 1); break; case MD_STREAM: if ( _set_flags(roar_vs_connection_obj(s->vss, NULL), roar_vs_stream_obj(s->vss, NULL), ROAR_FLAG_META, ROAR_SET_FLAG) != 0 ) { LOG_WARN0("Can not set metadata flag from stream"); } break; } return mod; fail: close_module(mod); /* safe, this checks for valid contents */ return NULL; }