static void move_selected_input_down (GtkButton *button, gpointer data) { GtkBuilder *builder = data; GtkTreeModel *model; GtkTreeIter iter, next; GtkTreePath *path; g_debug ("move selected input source down"); if (!get_selected_iter (builder, &model, &iter)) return; next = iter; if (!gtk_tree_model_iter_next (model, &next)) return; path = gtk_tree_model_get_path (model, &next); gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &next); set_selected_path (builder, path); gtk_tree_path_free (path); update_button_sensitivity (builder); update_configuration (model); }
void replica::on_config_sync(const partition_configuration& config) { ddebug( "%s: configuration sync", name()); // no outdated update if (config.ballot < get_ballot()) return; if (status() == PS_PRIMARY || nullptr != _primary_states.reconfiguration_task) { // nothing to do as pirmary always holds the truth } else { update_configuration(config); if (status() == PS_INACTIVE && !_inactive_is_transient) { if (config.primary == primary_address() // dead primary || config.primary.is_invalid() // primary is dead (otherwise let primary remove this) ) { _stub->remove_replica_on_meta_server(config); } } } }
static void remove_selected_input (GtkButton *button, gpointer data) { GtkBuilder *builder = data; GtkTreeModel *model; GtkTreeIter iter; GtkTreePath *path; g_debug ("remove selected input source"); if (get_selected_iter (builder, &model, &iter) == FALSE) return; path = gtk_tree_model_get_path (model, &iter); gtk_list_store_remove (GTK_LIST_STORE (model), &iter); if (!gtk_tree_model_get_iter (model, &iter, path)) gtk_tree_path_prev (path); set_selected_path (builder, path); gtk_tree_path_free (path); update_button_sensitivity (builder); update_configuration (model); }
void meta_service::on_log_completed(error_code err, size_t size, blob buffer, std::shared_ptr<configuration_update_request> req, dsn_message_t resp) { dassert(err == ERR_OK, "log operation failed, cannot proceed, err = %s", err.to_string()); dassert(buffer.length() == size, "log size must equal to the specified buffer size"); configuration_update_response response; update_configuration(*req, response); if (resp != nullptr) { meta_response_header rhdr; rhdr.err = err; rhdr.primary_address = primary_address(); marshall(resp, rhdr); marshall(resp, response); dsn_rpc_reply(resp); } else { err.end_tracking(); } }
static void chooser_response (GtkWidget *chooser, gint response_id, gpointer data) { GtkBuilder *builder = data; if (response_id == GTK_RESPONSE_OK) { GtkTreeModel *model; GtkTreeIter iter; if (input_chooser_get_selected (chooser, &model, &iter)) { GtkTreeView *tv; GtkListStore *my_model; GtkTreeIter child_iter; gchar *name; gchar *type; gchar *id; GDesktopAppInfo *app_info = NULL; gtk_tree_model_get (model, &iter, NAME_COLUMN, &name, TYPE_COLUMN, &type, ID_COLUMN, &id, -1); #ifdef HAVE_IBUS if (g_str_equal (type, INPUT_SOURCE_TYPE_IBUS)) app_info = setup_app_info_for_id (id); #endif tv = GTK_TREE_VIEW (WID ("active_input_sources")); my_model = GTK_LIST_STORE (gtk_tree_view_get_model (tv)); gtk_list_store_insert_with_values (my_model, &child_iter, -1, NAME_COLUMN, name, TYPE_COLUMN, type, ID_COLUMN, id, SETUP_COLUMN, app_info, -1); g_free (name); g_free (type); g_free (id); if (app_info) g_object_unref (app_info); gtk_tree_selection_select_iter (gtk_tree_view_get_selection (tv), &child_iter); update_button_sensitivity (builder); update_configuration (GTK_TREE_MODEL (my_model)); } else { g_debug ("nothing selected, nothing added"); } } gtk_widget_destroy (GTK_WIDGET (chooser)); }
//----------------------------------------------------------------------------------------------------------------------- void in_received_handler(DictionaryIterator *received, void *ctx) { app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__, "enter in_received_handler"); Tuple *akt_tuple = dict_read_first(received); while (akt_tuple) { app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__, "KEY %d=%s", (int16_t)akt_tuple->key, akt_tuple->value->cstring); if (akt_tuple->key == CONFIG_KEY_THEME) persist_write_int(CONFIG_KEY_THEME, strcmp(akt_tuple->value->cstring, "circle") == 0 ? 0 : 1); if (akt_tuple->key == CONFIG_KEY_FSM) persist_write_bool(CONFIG_KEY_FSM, strcmp(akt_tuple->value->cstring, "yes") == 0); if (akt_tuple->key == CONFIG_KEY_INV) persist_write_bool(CONFIG_KEY_INV, strcmp(akt_tuple->value->cstring, "yes") == 0); if (akt_tuple->key == CONFIG_KEY_ANIM) persist_write_bool(CONFIG_KEY_ANIM, strcmp(akt_tuple->value->cstring, "yes") == 0); if (akt_tuple->key == CONFIG_KEY_SEP) persist_write_bool(CONFIG_KEY_SEP, strcmp(akt_tuple->value->cstring, "yes") == 0); if (akt_tuple->key == CONFIG_KEY_DATEFMT) persist_write_int(CONFIG_KEY_DATEFMT, strcmp(akt_tuple->value->cstring, "fra") == 0 ? 1 : strcmp(akt_tuple->value->cstring, "eng") == 0 ? 2 : strcmp(akt_tuple->value->cstring, "usa") == 0 ? 3 : strcmp(akt_tuple->value->cstring, "iso") == 0 ? 4 : strcmp(akt_tuple->value->cstring, "gers") == 0 ? 5 : strcmp(akt_tuple->value->cstring, "fras") == 0 ? 6 : strcmp(akt_tuple->value->cstring, "engs") == 0 ? 7 : strcmp(akt_tuple->value->cstring, "usas") == 0 ? 8 : strcmp(akt_tuple->value->cstring, "isos") == 0 ? 9 : strcmp(akt_tuple->value->cstring, "cus1") == 0 ? 10 : strcmp(akt_tuple->value->cstring, "cus2") == 0 ? 11 : 0); if (akt_tuple->key == CONFIG_KEY_SMART) persist_write_bool(CONFIG_KEY_SMART, strcmp(akt_tuple->value->cstring, "yes") == 0); if (akt_tuple->key == CONFIG_KEY_VIBR) persist_write_bool(CONFIG_KEY_VIBR, strcmp(akt_tuple->value->cstring, "yes") == 0); akt_tuple = dict_read_next(received); } update_configuration(); }
void meta_service::on_request(message_ptr& msg) { meta_request_header hdr; unmarshall(msg, hdr); meta_response_header rhdr; bool is_primary = _state->get_meta_server_primary(rhdr.primary_address); if (is_primary) is_primary = (primary_address() == rhdr.primary_address); rhdr.err = ERR_SUCCESS; message_ptr resp = msg->create_response(); if (!is_primary) { rhdr.err = ERR_TALK_TO_OTHERS; marshall(resp, rhdr); } else if (hdr.rpc_tag == RPC_CM_QUERY_NODE_PARTITIONS) { configuration_query_by_node_request request; configuration_query_by_node_response response; unmarshall(msg, request); query_configuration_by_node(request, response); marshall(resp, rhdr); marshall(resp, response); } else if (hdr.rpc_tag == RPC_CM_QUERY_PARTITION_CONFIG_BY_INDEX) { configuration_query_by_index_request request; configuration_query_by_index_response response; unmarshall(msg, request); query_configuration_by_index(request, response); marshall(resp, rhdr); marshall(resp, response); } else if (hdr.rpc_tag == RPC_CM_UPDATE_PARTITION_CONFIGURATION) { update_configuration(msg, resp); return; } else { dassert(false, "unknown rpc tag %x (%s)", hdr.rpc_tag, task_code(hdr.rpc_tag).to_string()); } rpc::reply(resp); }
rs2::frame hole_filling_filter::process_frame(const rs2::frame_source& source, const rs2::frame& f) { update_configuration(f); auto tgt = prepare_target_frame(f, source); // Hole filling pass if (_extension_type == RS2_EXTENSION_DISPARITY_FRAME) apply_hole_filling<float>(const_cast<void*>(tgt.get_data())); else apply_hole_filling<uint16_t>(const_cast<void*>(tgt.get_data())); return tgt; }
void meta_service::on_log_completed(error_code err, int size, char* buffer, message_ptr req, message_ptr resp) { free(buffer); dassert(err == ERR_SUCCESS, "log operation failed, cannot proceed, err = %s", err.to_string()); configuration_update_request request; configuration_update_response response; unmarshall(req, request); update_configuration(request, response); meta_response_header rhdr; rhdr.err = err; rhdr.primary_address = primary_address(); marshall(resp, rhdr); marshall(resp, response); rpc::reply(resp); }
/* This function returns the number of the next sample. */ static uint32_t seek_video ( libavsmash_video_decode_handler_t *vdhp, AVFrame *picture, uint32_t composition_sample_number, uint32_t rap_number, int error_ignorance ) { /* Prepare to decode from random accessible sample. */ codec_configuration_t *config = &vdhp->config; if( config->update_pending ) /* Update the decoder configuration. */ update_configuration( vdhp->root, vdhp->track_id, config ); else libavsmash_flush_buffers( config ); if( config->error ) return 0; int got_picture; int output_ready = 0; uint64_t rap_cts = 0; uint32_t i; uint32_t decoder_delay = get_decoder_delay( config->ctx ); uint32_t goal = composition_sample_number + decoder_delay; for( i = rap_number; i < goal; i++ ) { if( config->index == config->queue.index ) config->delay_count = MIN( decoder_delay, i - rap_number ); int ret = decode_video_sample( vdhp, picture, &got_picture, i ); if( got_picture ) { output_ready = 1; if( decoder_delay > config->delay_count ) { /* Shorten the distance to the goal if we got a frame earlier than expected. */ uint32_t new_decoder_delay = config->delay_count; goal -= decoder_delay - new_decoder_delay; decoder_delay = new_decoder_delay; } } else if( output_ready ) { /* More input samples are required to output and the goal become more distant. */ ++decoder_delay; ++goal; } /* Some decoders return -1 when feeding a leading sample. * We don't consider as an error if the return value -1 is caused by a leading sample since it's not fatal at all. */ if( i == vdhp->last_rap_number ) rap_cts = picture->pts; if( ret == -1 && (uint64_t)picture->pts >= rap_cts && !error_ignorance ) { lw_log_show( &config->lh, LW_LOG_WARNING, "Failed to decode a video frame." ); return 0; } else if( ret >= 1 ) /* No decoding occurs. */ break; } if( config->index == config->queue.index ) config->delay_count = MIN( decoder_delay, i - rap_number ); return i; }
uint64_t libavsmash_get_pcm_audio_samples ( libavsmash_audio_decode_handler_t *adhp, libavsmash_audio_output_handler_t *aohp, void *buf, int64_t start, int64_t wanted_length ) { codec_configuration_t *config = &adhp->config; if( config->error ) return 0; uint32_t frame_number; uint64_t output_length = 0; enum audio_output_flag output_flags; aohp->request_length = wanted_length; if( start > 0 && start == adhp->next_pcm_sample_number ) { frame_number = adhp->last_frame_number; output_flags = AUDIO_OUTPUT_NO_FLAGS; output_length += output_pcm_samples_from_buffer( aohp, adhp->frame_buffer, (uint8_t **)&buf, &output_flags ); if( output_flags & AUDIO_OUTPUT_ENOUGH ) goto audio_out; if( adhp->packet.size <= 0 ) ++frame_number; aohp->output_sample_offset = 0; } else { /* Seek audio stream. */ if( flush_resampler_buffers( aohp->avr_ctx ) < 0 ) { config->error = 1; if( config->lh.show_log ) config->lh.show_log( &config->lh, LW_LOG_FATAL, "Failed to flush resampler buffers.\n" "It is recommended you reopen the file." ); return 0; } libavsmash_flush_buffers( config ); if( config->error ) return 0; adhp->next_pcm_sample_number = 0; adhp->last_frame_number = 0; uint64_t start_frame_pos; if( start >= 0 ) start_frame_pos = start; else { uint64_t silence_length = -start; put_silence_audio_samples( (int)(silence_length * aohp->output_block_align), aohp->output_bits_per_sample == 8, (uint8_t **)&buf ); output_length += silence_length; aohp->request_length -= silence_length; start_frame_pos = 0; } start_frame_pos += aohp->skip_decoded_samples; frame_number = find_start_audio_frame( adhp, aohp->output_sample_rate, aohp->skip_decoded_samples, start_frame_pos, &aohp->output_sample_offset ); } do { AVPacket *pkt = &adhp->packet; if( frame_number > adhp->frame_count ) { if( config->delay_count ) { /* Null packet */ av_init_packet( pkt ); pkt->data = NULL; pkt->size = 0; -- config->delay_count; } else goto audio_out; } else if( pkt->size <= 0 ) /* Getting an audio packet must be after flushing all remaining samples in resampler's FIFO buffer. */ while( get_sample( adhp->root, adhp->track_ID, frame_number, config, pkt ) == 2 ) if( config->update_pending ) /* Update the decoder configuration. */ update_configuration( adhp->root, adhp->track_ID, config ); /* Decode and output from an audio packet. */ output_flags = AUDIO_OUTPUT_NO_FLAGS; output_length += output_pcm_samples_from_packet( aohp, config->ctx, pkt, adhp->frame_buffer, (uint8_t **)&buf, &output_flags ); if( output_flags & AUDIO_DECODER_DELAY ) ++ config->delay_count; if( output_flags & AUDIO_RECONFIG_FAILURE ) { config->error = 1; if( config->lh.show_log ) config->lh.show_log( &config->lh, LW_LOG_FATAL, "Failed to reconfigure resampler.\n" "It is recommended you reopen the file." ); goto audio_out; } if( output_flags & AUDIO_OUTPUT_ENOUGH ) goto audio_out; ++frame_number; } while( 1 ); audio_out: adhp->next_pcm_sample_number = start + output_length; adhp->last_frame_number = frame_number; return output_length; }
//----------------------------------------------------------------------------------------------------------------------- static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); digitS = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITAL_23)); bmp_mask = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MASK); // Init layers face_layer = layer_create(GRect(0, 0, bounds.size.w, bounds.size.w)); layer_set_update_proc(face_layer, face_update_proc); date_layer = text_layer_create(GRect(-bounds.size.w, bounds.size.h-n_bottom_margin-2, bounds.size.w, n_bottom_margin)); text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); text_layer_set_font(date_layer, digitS); //Init bluetooth radio radio_layer = bitmap_layer_create(GRect(1, bounds.size.h, 10, 20)); bitmap_layer_set_background_color(radio_layer, GColorClear); //Init battery battery_layer = bitmap_layer_create(GRect(bounds.size.w-11, bounds.size.h, 10, 20)); bitmap_layer_set_background_color(battery_layer, GColorClear); //Update Configuration update_configuration(); //Start|Skip Animation if (CfgData.anim) { aktHH = aktMM = 0; timer_face = app_timer_register(500, timerCallback, (void*)TIMER_ANIM_FACE); //Animate Date GRect rc_from = layer_get_frame(text_layer_get_layer(date_layer)); GRect rc_to = rc_from; rc_to.origin.x = 0; s_prop_anim_date = property_animation_create_layer_frame(text_layer_get_layer(date_layer), &rc_from, &rc_to); animation_set_curve((Animation*)s_prop_anim_date, AnimationCurveEaseOut); animation_set_delay((Animation*)s_prop_anim_date, 500); animation_set_duration((Animation*)s_prop_anim_date, 1000); animation_schedule((Animation*)s_prop_anim_date); //Animate Bluetooth rc_from = layer_get_frame(bitmap_layer_get_layer(radio_layer)); #if defined(PBL_RECT) rc_to = rc_from; rc_to.origin.y -= rc_from.size.h+1; #elif defined(PBL_ROUND) rc_from = GRect(-rc_from.size.w, bounds.size.h/2-rc_from.size.h/2, rc_from.size.w, rc_from.size.h); rc_to = rc_from; rc_to.origin.x = 4; #endif s_prop_anim_bt = property_animation_create_layer_frame(bitmap_layer_get_layer(radio_layer), &rc_from, &rc_to); animation_set_curve((Animation*)s_prop_anim_bt, AnimationCurveEaseOut); animation_set_delay((Animation*)s_prop_anim_bt, 1500); animation_set_duration((Animation*)s_prop_anim_bt, 1000); animation_schedule((Animation*)s_prop_anim_bt); //Animate Battery rc_from = layer_get_frame(bitmap_layer_get_layer(battery_layer)); #if defined(PBL_RECT) rc_to = rc_from; rc_to.origin.y -= rc_from.size.h+1; #elif defined(PBL_ROUND) rc_from = GRect(bounds.size.w, bounds.size.h/2-rc_from.size.h/2, rc_from.size.w, rc_from.size.h); rc_to = rc_from; rc_to.origin.x = bounds.size.w-rc_from.size.w-4; #endif s_prop_anim_batt = property_animation_create_layer_frame(bitmap_layer_get_layer(battery_layer), &rc_from, &rc_to); animation_set_curve((Animation*)s_prop_anim_batt, AnimationCurveEaseOut); animation_set_delay((Animation*)s_prop_anim_batt, 2000); animation_set_duration((Animation*)s_prop_anim_batt, 1000); animation_schedule((Animation*)s_prop_anim_batt); } else { GRect rc = layer_get_frame(text_layer_get_layer(date_layer)); rc.origin.x = 0; layer_set_frame(text_layer_get_layer(date_layer), rc); rc = layer_get_frame(bitmap_layer_get_layer(radio_layer)); #if defined(PBL_RECT) rc.origin.y -= rc.size.h+1; #elif defined(PBL_ROUND) rc = GRect(4, bounds.size.h/2-rc.size.h/2, rc.size.w, rc.size.h); #endif layer_set_frame(bitmap_layer_get_layer(radio_layer), rc); rc = layer_get_frame(bitmap_layer_get_layer(battery_layer)); #if defined(PBL_RECT) rc.origin.y -= rc.size.h+1; #elif defined(PBL_ROUND) rc = GRect(bounds.size.w-rc.size.w-4, bounds.size.h/2-rc.size.h/2, rc.size.w, rc.size.h); #endif layer_set_frame(bitmap_layer_get_layer(battery_layer), rc); b_initialized = true; } }
void replica::on_config_proposal(configuration_update_request& proposal) { check_hashed_access(); ddebug( "%s: on_config_proposal %s for %s", name(), enum_to_string(proposal.type), proposal.node.to_string() ); if (proposal.config.ballot < get_ballot()) { dwarn( "%s: on_config_proposal is out-dated, %lld vs %lld", name(), proposal.config.ballot, get_ballot() ); return; } if (_primary_states.reconfiguration_task != nullptr) { dinfo( "%s: reconfiguration on the way, skip the incoming proposal", name() ); return; } if (proposal.config.ballot > get_ballot()) { if (!update_configuration(proposal.config)) { // is closing or update failed return; } } switch (proposal.type) { case CT_ASSIGN_PRIMARY: case CT_UPGRADE_TO_PRIMARY: assign_primary(proposal); break; case CT_ADD_SECONDARY: add_potential_secondary(proposal); break; case CT_DOWNGRADE_TO_SECONDARY: downgrade_to_secondary_on_primary(proposal); break; case CT_DOWNGRADE_TO_INACTIVE: downgrade_to_inactive_on_primary(proposal); break; case CT_REMOVE: remove(proposal); break; default: dassert (false, ""); } }
void replica::on_update_configuration_on_meta_server_reply(error_code err, dsn_message_t request, dsn_message_t response, std::shared_ptr<configuration_update_request> req) { check_hashed_access(); if (PS_INACTIVE != status() || _stub->is_connected() == false) { _primary_states.reconfiguration_task = nullptr; err.end_tracking(); return; } configuration_update_response resp; if (err == ERR_OK) { ::unmarshall(response, resp); err = resp.err; } if (err != ERR_OK) { ddebug( "%s: update configuration reply with err %s, request ballot %lld", name(), err.to_string(), req->config.ballot ); if (err != ERR_INVALID_VERSION) { rpc_address target(_stub->_failure_detector->get_servers()); dsn_msg_add_ref(request); // added for another round of rpc::call _primary_states.reconfiguration_task = rpc::call( target, request, this, std::bind(&replica::on_update_configuration_on_meta_server_reply, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, req), gpid_to_hash(get_gpid()) ); return; } } ddebug( "%s: update configuration reply with err %s, ballot %lld, local %lld", name(), resp.err.to_string(), resp.config.ballot, get_ballot() ); if (resp.config.ballot < get_ballot()) { _primary_states.reconfiguration_task = nullptr; return; } // post-update work items? if (resp.err == ERR_OK) { dassert (req->config.gpid == resp.config.gpid, ""); dassert (req->config.app_type == resp.config.app_type, ""); dassert (req->config.primary == resp.config.primary, ""); dassert (req->config.secondaries == resp.config.secondaries, ""); switch (req->type) { case CT_UPGRADE_TO_PRIMARY: _primary_states.last_prepare_decree_on_new_primary = _prepare_list->max_decree(); break; case CT_ASSIGN_PRIMARY: case CT_DOWNGRADE_TO_SECONDARY: case CT_DOWNGRADE_TO_INACTIVE: case CT_UPGRADE_TO_SECONDARY: break; case CT_REMOVE: if (req->node != primary_address()) { replica_configuration rconfig; replica_helper::get_replica_config(resp.config, req->node, rconfig); rpc::call_one_way_typed(req->node, RPC_REMOVE_REPLICA, rconfig, gpid_to_hash(get_gpid())); } break; default: dassert (false, ""); } } update_configuration(resp.config); _primary_states.reconfiguration_task = nullptr; }
void meta_service::on_request(dsn_message_t msg) { meta_request_header hdr; ::unmarshall(msg, hdr); meta_response_header rhdr; bool is_primary = _state->get_meta_server_primary(rhdr.primary_address); if (is_primary) is_primary = (primary_address() == rhdr.primary_address); rhdr.err = ERR_OK; ::dsn::rpc_address faddr; dsn_msg_from_address(msg, faddr.c_addr_ptr()); dinfo("recv meta request %s from %s:%hu", dsn_task_code_to_string(hdr.rpc_tag), faddr.name(), faddr.port() ); dsn_message_t resp = dsn_msg_create_response(msg); if (!is_primary) { rhdr.err = ERR_TALK_TO_OTHERS; ::marshall(resp, rhdr); } else if (!_started) { rhdr.err = ERR_SERVICE_NOT_ACTIVE; ::marshall(resp, rhdr); } else if (hdr.rpc_tag == RPC_CM_QUERY_NODE_PARTITIONS) { configuration_query_by_node_request request; configuration_query_by_node_response response; ::unmarshall(msg, request); query_configuration_by_node(request, response); ::marshall(resp, rhdr); ::marshall(resp, response); } else if (hdr.rpc_tag == RPC_CM_QUERY_PARTITION_CONFIG_BY_INDEX) { configuration_query_by_index_request request; configuration_query_by_index_response response; unmarshall(msg, request); query_configuration_by_index(request, response); ::marshall(resp, rhdr); ::marshall(resp, response); } else if (hdr.rpc_tag == RPC_CM_UPDATE_PARTITION_CONFIGURATION) { update_configuration(msg, resp); rhdr.err.end_tracking(); return; } else { dassert(false, "unknown rpc tag %x (%s)", hdr.rpc_tag, dsn_task_code_to_string(hdr.rpc_tag)); } dsn_rpc_reply(resp); }