Esempio n. 1
0
int ip_output(void *pbuf, uint16_t plen, void *dbuf, uint16_t dlen)
{
  oiph.id = htons_inc(ip_id);
  oiph.ttl = IP_TTL;
  oiph.check = 0;
  oiph.version = 4;
  /* Options not supported */
  oiph.ihl = 5;
  oiph.check = ip_checksum(&oiph, sizeof(oiph));

  output_begin();	/* Set up output buffer (space left for header) */
  output_add(&oiph, 4 * oiph.ihl);
  output_add(pbuf, plen);
  ouput_add(dbuf, dlen);
  if (LOOPBACK(oiph.daddr) || oiph.daddr == ip_addr)
    return loopback_queue();
  else
    return mac_queue();
  /* We do blocking writes, when this code returns the buffer is on the
     wire and we don't have to fret about re-use. Does mean slip has to be
     careful to buffer the receive side while queueing output */
}
Esempio n. 2
0
File: timer.c Progetto: fywtat/curie
int cmain ()
{
    int i;

    multiplex_signal();
    multiplex_sexpr();

    output_add (sx_open_stdio ());

    for (i = 1; curie_argv [i] != (char *)0; i++)
    {
        int j = 0;
        struct io *in;
        struct sexpr_io *io;
        sexpr sx;

        while (curie_argv[i][j] != (char)0) j++;
        j++;

        in = io_open_buffer (curie_argv[i], j);
        io = sx_open_i (in);

        while (!eofp (sx = sx_read (io)) && !nexp (sx))
        {
            timer_io_read (sx, (struct sexpr_io *)0, (void *)0);
        }
    }

    multiplex_add_signal (sig_alrm,   timer_signal, (void *)0);
    multiplex_add_signal (sig_vtalrm, timer_signal, (void *)0);

    multiplex_add_signal (sig_hup,    term_signal,  (void *)0);
    multiplex_add_signal (sig_segv,   term_signal,  (void *)0);
    multiplex_add_signal (sig_term,   term_signal,  (void *)0);

    while (multiplex() != mx_nothing_to_do);

    return 0;
}
Esempio n. 3
0
void
output_process(void *closure,
	char *canonical_hostname, struct sockaddr *peer_addr,
	struct gfs_client_load *load, struct gfs_connection *gfs_server,
	gfarm_error_t error)
{
	struct output o;

	o.closure = closure;
	o.canonical_hostname = canonical_hostname;
	if (peer_addr != NULL)
		o.peer_addr = *peer_addr;
	if (load != NULL)
		o.load = *load;
	o.auth_mnemonic = mnemonic(gfs_server, load);
	o.error = error;

	assert((load != NULL) == LOADAVG_AVAIL(&o));

	if (output_record)
		output_add(&o);
	else /* i.e. don't sort */
		(*output_callback)(&o);
}
Esempio n. 4
0
int mix_add(mix_t *mix, AVFrame *frame, unsigned int idx, output_t *output) {
	const char *err;

	err = "index out of range";
	if (idx >= NUM_INPUTS)
		goto err;

	err = "mixer not initialized";
	if (!mix->src_ctxs[idx])
		goto err;

	dbg("stream %i pts_off %llu in pts %llu in frame pts %llu samples %u mix out pts %llu", 
			idx,
			(unsigned long long) mix->pts_offs[idx],
			(unsigned long long) mix->in_pts[idx],
			(unsigned long long) frame->pts,
			frame->nb_samples,
			(unsigned long long) mix->out_pts);

	// adjust for media started late
	if (G_UNLIKELY(mix->pts_offs[idx] == (uint64_t) -1LL))
		mix->pts_offs[idx] = mix->out_pts - frame->pts;
	frame->pts += mix->pts_offs[idx];

	// fill missing time
	mix_silence_fill_idx_upto(mix, idx, frame->pts);

	uint64_t next_pts = frame->pts + frame->nb_samples;

	err = "failed to add frame to mixer";
	if (av_buffersrc_add_frame(mix->src_ctxs[idx], frame))
		goto err;

	// update running counters
	if (next_pts > mix->out_pts)
		mix->out_pts = next_pts;
	if (next_pts > mix->in_pts[idx])
		mix->in_pts[idx] = next_pts;

	av_frame_free(&frame);

	mix_silence_fill(mix);

	while (1) {
		int ret = av_buffersink_get_frame(mix->sink_ctx, mix->sink_frame);
		err = "failed to get frame from mixer";
		if (ret < 0) {
			if (ret == AVERROR(EAGAIN))
				break;
			else
				goto err;
		}
		frame = resample_frame(&mix->resample, mix->sink_frame, &mix->format);

		ret = output_add(output, frame);

		av_frame_unref(mix->sink_frame);
		av_frame_free(&frame);

		if (ret)
			return -1;
	}

	return 0;

err:
	ilog(LOG_ERR, "Failed to add frame to mixer: %s", err);
	av_frame_free(&frame);
	return -1;
}