Exemplo n.º 1
0
static av_cold int init(AVFilterContext *ctx)
{
    AudioEchoContext *s = ctx->priv;
    int nb_delays, nb_decays, i;

    if (!s->delays || !s->decays) {
        av_log(ctx, AV_LOG_ERROR, "Missing delays and/or decays.\n");
        return AVERROR(EINVAL);
    }

    count_items(s->delays, &nb_delays);
    count_items(s->decays, &nb_decays);

    s->delay = av_realloc_f(s->delay, nb_delays, sizeof(*s->delay));
    s->decay = av_realloc_f(s->decay, nb_decays, sizeof(*s->decay));
    if (!s->delay || !s->decay)
        return AVERROR(ENOMEM);

    fill_items(s->delays, &nb_delays, s->delay);
    fill_items(s->decays, &nb_decays, s->decay);

    if (nb_delays != nb_decays) {
        av_log(ctx, AV_LOG_ERROR, "Number of delays %d differs from number of decays %d.\n", nb_delays, nb_decays);
        return AVERROR(EINVAL);
    }

    s->nb_echoes = nb_delays;
    if (!s->nb_echoes) {
        av_log(ctx, AV_LOG_ERROR, "At least one decay & delay must be set.\n");
        return AVERROR(EINVAL);
    }

    s->samples = av_realloc_f(s->samples, nb_delays, sizeof(*s->samples));
    if (!s->samples)
        return AVERROR(ENOMEM);

    for (i = 0; i < nb_delays; i++) {
        if (s->delay[i] <= 0 || s->delay[i] > 90000) {
            av_log(ctx, AV_LOG_ERROR, "delay[%d]: %f is out of allowed range: (0, 90000]\n", i, s->delay[i]);
            return AVERROR(EINVAL);
        }
        if (s->decay[i] <= 0 || s->decay[i] > 1) {
            av_log(ctx, AV_LOG_ERROR, "decay[%d]: %f is out of allowed range: (0, 1]\n", i, s->decay[i]);
            return AVERROR(EINVAL);
        }
    }

    s->next_pts = AV_NOPTS_VALUE;

    av_log(ctx, AV_LOG_DEBUG, "nb_echoes:%d\n", s->nb_echoes);
    return 0;
}
Exemplo n.º 2
0
void menu::set_items(const std::vector<std::string>& items, bool strip_spaces, bool keep_viewport)
{

	const bool scrolled_to_max = (has_scrollbar() && get_position() == get_max_position());
	items_.clear();
	item_pos_.clear();
	itemRects_.clear();
	column_widths_.clear();
	//undrawn_items_.clear();
	max_items_ = -1; // Force recalculation of the max items.
	item_height_ = -1; // Force recalculation of the item height.

	if (!keep_viewport || selected_ >= items.size()) {
		selected_ = 0;
	}

	fill_items(items, strip_spaces);
	if(!keep_viewport) {
		set_position(0);
	} else if(scrolled_to_max) {
		set_position(get_max_position());
	}

	update_scrollbar_grip_height();

	if(!keep_viewport) {
		adjust_viewport_to_selection();
	}
	set_dirty();
}
Exemplo n.º 3
0
menu::menu(CVideo& video, const std::vector<std::string>& items,
           bool click_selects, int max_height, int max_width,
		   const sorter* sorter_obj, style *menu_style, const bool auto_join)
        : scrollarea(video, auto_join), silent_(false),
          max_height_(max_height), max_width_(max_width), max_items_(-1), item_height_(-1),
		  heading_height_(-1),
	  cur_help_(-1,-1), help_string_(-1),
	  selected_(0), click_selects_(click_selects), out_(false),
	  previous_button_(true), show_result_(false),
	  double_clicked_(false),
	  num_selects_(true),
	  ignore_next_doubleclick_(false),
	  last_was_doubleclick_(false), use_ellipsis_(false),
	  sorter_(sorter_obj), sortby_(-1), sortreversed_(false), highlight_heading_(-1)
{
	style_ = (menu_style) ? menu_style : &default_style;
	style_->init();
	fill_items(items, true);
}
Exemplo n.º 4
0
void CAI_Stalker::update_sell_info					()
{
	if (m_sell_info_actuality)
		return;

	m_sell_info_actuality	= true;

	m_temp_items.clear		();
	m_current_trader		= 0;
	m_total_money			= get_money();
	u32						money_delta = fill_items(inventory(),this,ALife::_OBJECT_ID(-1));
	m_total_money			+= money_delta;
	std::sort				(m_temp_items.begin(),m_temp_items.end());
	select_items			();

	TIItemContainer::iterator	I = inventory().m_all.begin();
	TIItemContainer::iterator	E = inventory().m_all.end();
	for ( ; I != E; ++I) {
		if (!tradable_item(*I,ID()))
			m_temp_items.push_back	(CTradeItem(*I,ID(),ID()));
	}
}
Exemplo n.º 5
0
//
// Conky update function for apcupsd data
//
int update_apcupsd(void) {

	int i;
	APCUPSD_S apc;
	int sock;

	for (i = 0; i < _APCUPSD_COUNT; ++i)
		memcpy(apc.items[i], "N/A", 4); // including \0

	do {
		struct addrinfo hints;
		struct addrinfo *ai, *rp;
		int res;
		short sz = 0;
		char portbuf[8];
		//
		// connect to apcupsd daemon
		//
		memset(&hints, 0, sizeof(struct addrinfo));
		hints.ai_family = AF_UNSPEC;
		hints.ai_socktype = SOCK_STREAM;
		hints.ai_flags = 0;
		hints.ai_protocol = 0;
		snprintf(portbuf, 8, "%d", info.apcupsd.port);
		res = getaddrinfo(info.apcupsd.host, portbuf, &hints, &ai);
		if (res != 0) {
			NORM_ERR("APCUPSD getaddrinfo: %s", gai_strerror(res));
			break;
		}
		for (rp = ai; rp != NULL; rp = rp->ai_next) {
			sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
			if (sock == -1) {
				continue;
			}
			if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) {
				break;
			}
			close(sock);
		}
		freeaddrinfo(ai);
		if (rp == NULL) {
			// no error reporting, the daemon is probably not running
			break;
		}

		//
		// send status request - "status" - 6B
		//
		sz = htons(6);
		// no waiting to become writeable is really needed
		if (send(sock, &sz, sizeof(sz), 0) != sizeof(sz) || send(sock, "status", 6, 0) != 6) {
			perror("send");
			break;
		}
	
		//
		// read the lines of output and put them into the info structure
		//
		if (!fill_items(sock, &apc)) break;

	} while (0);

	close(sock);

	//
	// "atomically" copy the data into working set
	//
	memcpy(info.apcupsd.items, apc.items, sizeof(info.apcupsd.items));
	return 0;
}