Example #1
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym,
	    enum wl_keyboard_key_state state, void *data)
{
	struct demoapp *app = data;
	struct rectangle winrect;

	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
		return;

	switch (sym) {
	case XKB_KEY_space:
		app->animate = !app->animate;
		window_schedule_redraw(window);
		break;
	case XKB_KEY_Up:
		window_get_allocation(window, &winrect);
		winrect.height -= 100;
		if (winrect.height < 150)
			winrect.height = 150;
		window_schedule_resize(window, winrect.width, winrect.height);
		break;
	case XKB_KEY_Down:
		window_get_allocation(window, &winrect);
		winrect.height += 100;
		if (winrect.height > 600)
			winrect.height = 600;
		window_schedule_resize(window, winrect.width, winrect.height);
		break;
	case XKB_KEY_Escape:
		display_exit(app->display);
		break;
	}
}
Example #2
0
static void error(const char *p)
{
  display_exit();
  write(2, p, strlen(p));
  write(2, "\n", 1);
  exit(1);
}
Example #3
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym, enum wl_keyboard_key_state state,
	    void *data)
{
	struct resizor *resizor = data;
	struct rectangle allocation;

	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
		return;

	window_get_allocation(resizor->window, &allocation);
	resizor->width.current = allocation.width;
	if (spring_done(&resizor->width))
		resizor->width.target = allocation.width;
	resizor->height.current = allocation.height;
	if (spring_done(&resizor->height))
		resizor->height.target = allocation.height;

	switch (sym) {
	case XKB_KEY_Up:
		if (allocation.height < 400)
			break;

		resizor->height.target = allocation.height - 200;
		break;

	case XKB_KEY_Down:
		if (allocation.height > 1000)
			break;

		resizor->height.target = allocation.height + 200;
		break;

	case XKB_KEY_Left:
		if (allocation.width < 400)
			break;

		resizor->width.target = allocation.width - 200;
		break;

	case XKB_KEY_Right:
		if (allocation.width > 1000)
			break;

		resizor->width.target = allocation.width + 200;
		break;

	case XKB_KEY_Escape:
		display_exit(resizor->display);
		break;
	}

	if (!resizor->frame_callback)
		frame_callback(resizor, NULL, 0);
}
Example #4
0
static void
close_handler(struct window *window, void *data)
{
	struct image *image = data;

	*image->image_counter -= 1;

	if (*image->image_counter == 0)
		display_exit(image->display);

	widget_destroy(image->widget);
	window_destroy(image->window);

	free(image);
}
Example #5
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym,
	    enum wl_keyboard_key_state state, void *data)
{
	struct clickdot *clickdot = data;

	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
		return;

	switch (sym) {
	case XKB_KEY_Escape:
		display_exit(clickdot->display);
		break;
	}
}
Example #6
0
static void
close_handler(struct window *window, void *data)
{
	struct view *view = data;

	*view->view_counter -= 1;
	if (*view->view_counter == 0)
		display_exit(view->display);

	widget_destroy(view->widget);
	window_destroy(view->window);
	if (view->document)
		g_object_unref(view->document);

	free(view);
}
Example #7
0
static void
process_smpl_buf(perf_event_desc_t *hw)
{
	struct perf_event_header ehdr;
	int ret;

	for(;;) {
		ret = perf_read_buffer(hw, &ehdr, sizeof(ehdr));
		if (ret)
			return; /* nothing to read */

		if (options.opt_no_show) {
			perf_skip_buffer(hw, ehdr.size - sizeof(ehdr));
			continue;
		}

		switch(ehdr.type) {
			case PERF_RECORD_SAMPLE:
				collected_samples++;
				ret = perf_display_sample(fds, num_fds, hw - fds, &ehdr, options.output_file);
				if (ret)
					errx(1, "cannot parse sample");
				break;
			case PERF_RECORD_EXIT:
				display_exit(hw, options.output_file);
				break;
			case PERF_RECORD_LOST:
				lost_samples += display_lost(hw, fds, num_fds, options.output_file);
				break;
			case PERF_RECORD_THROTTLE:
				display_freq(1, hw, options.output_file);
				break;
			case PERF_RECORD_UNTHROTTLE:
				display_freq(0, hw, options.output_file);
				break;
			default:
				printf("unknown sample type %d\n", ehdr.type);
				perf_skip_buffer(hw, ehdr.size - sizeof(ehdr));
		}
	}
}
Example #8
0
static void
process_smpl_buf(perf_event_desc_t *hw)
{
	struct perf_event_header ehdr;
	int ret;

	for(;;) {
		ret = perf_read_buffer(hw->buf, hw->pgmsk, &ehdr, sizeof(ehdr));
		if (ret)
			return; /* nothing to read */

		switch(ehdr.type) {
			case PERF_RECORD_SAMPLE:
				ret = perf_display_sample(fds, num_fds, hw - fds, &ehdr, stdout);
				if (ret)
					errx(1, "cannot parse sample");
				collected_samples++;
				break;
			case PERF_RECORD_EXIT:
				display_exit(hw);
				break;
			case PERF_RECORD_LOST:
				display_lost(hw);
				break;
			case PERF_RECORD_THROTTLE:
				display_freq(1, hw);
				break;
			case PERF_RECORD_UNTHROTTLE:
				display_freq(0, hw);
				break;
			default:
				printf("unknown sample type %d\n", ehdr.type);
				perf_skip_buffer(hw->buf, ehdr.size - sizeof(ehdr));
		}
	}
}
Example #9
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym,
	    enum wl_keyboard_key_state state, void *data)
{
	struct cliptest *cliptest = data;
	struct geometry *g = &cliptest->geometry;

	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
		return;

	switch (sym) {
	case XKB_KEY_Escape:
		display_exit(cliptest->display);
		return;
	case XKB_KEY_w:
		g->clip.y1 -= 1;
		g->clip.y2 -= 1;
		break;
	case XKB_KEY_a:
		g->clip.x1 -= 1;
		g->clip.x2 -= 1;
		break;
	case XKB_KEY_s:
		g->clip.y1 += 1;
		g->clip.y2 += 1;
		break;
	case XKB_KEY_d:
		g->clip.x1 += 1;
		g->clip.x2 += 1;
		break;
	case XKB_KEY_i:
		g->clip.y2 -= 1;
		break;
	case XKB_KEY_j:
		g->clip.x2 -= 1;
		break;
	case XKB_KEY_k:
		g->clip.y2 += 1;
		break;
	case XKB_KEY_l:
		g->clip.x2 += 1;
		break;
	case XKB_KEY_n:
		geometry_set_phi(g, g->phi + (M_PI / 24.0));
		cliptest->view.transform.enabled = 1;
		break;
	case XKB_KEY_m:
		geometry_set_phi(g, g->phi - (M_PI / 24.0));
		cliptest->view.transform.enabled = 1;
		break;
	case XKB_KEY_r:
		geometry_set_phi(g, 0.0);
		cliptest->view.transform.enabled = 0;
		break;
	default:
		return;
	}

	widget_schedule_redraw(cliptest->widget);
}
Example #10
0
int
main(int argc, char **argv)
{
	int ch;
	const char *conffile;

	conffile = CONFFILE;

	while ((ch = getopt(argc, argv, "f:v")) != -1) {
		switch (ch) {
			case 'f':
				conffile = optarg;
				break;
			case 'v':
				verbose++;
				break;
			default:
				usage();
				/* NOTREACHED */
		}
	}

	bzero(&config, sizeof(config));
	config.print.feedlines = -1;
	config.print.cchide_customer = 1;
	config.print.ccsig_customer = 1;
	bzero(&header, sizeof(header));
	if (parse_config(conffile))
		exit(1);

	/* set database files */
	if (config.database.custdb == NULL)
		if ((config.database.custdb = strdup(config.database.alldb
				? config.database.alldb : CUSTDBFILE)) == NULL)
			err(1, "cannot set customer database file");
	if (config.database.menudb == NULL)
		if ((config.database.menudb = strdup(config.database.alldb
				? config.database.alldb : MENUDBFILE)) == NULL)
			err(1, "cannot set menu database file");
	if (config.database.orderdb == NULL)
		if ((config.database.orderdb = strdup(config.database.alldb
				? config.database.alldb : ORDERDBFILE)) == NULL)
			err(1, "cannot set order database file");
	if (config.print.feedlines < 0)
		config.print.feedlines = PRINT_FEED_LINES;

	if (licence_init() == -1)
		errx(1, "cannot proceed without licence");

	event_init();

	module_init();
	rule_init();

	input_init();
	print_init();
	form_init();
	display_init();
	status_init();
	menu_init();
	customer_init();
	special_init();
	payment_init();
	window_init();
	order_init();

	display_refresh();

	signal(SIGPIPE, SIG_IGN);
	if (event_dispatch() == -1)
		err(1, "terminated abnormally");

	if (exitcode != 0 && exitmsg == NULL)
		exitmsg = strdup(status.status);

	order_exit();
	window_exit();
	payment_exit();
	special_exit();
	customer_exit();
	menu_exit();
	status_exit();
	display_exit();
	form_exit();
	print_exit();
	input_exit();

	rule_exit();
	module_exit();

	if (exitcode && exitmsg != NULL)
		errx(exitcode, "%s", exitmsg);
	else
		fprintf(stdout, "exiting normally\n");

	exit(0);
}
Example #11
0
int main(int argc, char *argv[])
{
	int idx, tus, fsize;
	char capdev_str[128];
	unsigned long ss;
	struct timeval ts, te;

	if(argc > 1) {
		// printf("  Usage : %s [file_path]\n", argv[0]);
		strcpy(capdev_str, argv[1]);
	} else {
		strcpy(capdev_str, dev_cap);
	}

	signal(SIGQUIT, exit_signal);
	signal(SIGINT,  exit_signal);
	signal(SIGPIPE, SIG_IGN);

	if(display_init() < 0) {
		printf("display init error\n");
		return 0;
	}

	if(dec_init(CAP_WIDTH, CAP_HEIGHT, VPU_V_MJPG) < 0) {
		printf("decodec init error\n");
		goto err;
	}

	if ((fd_cap = open(capdev_str, O_RDWR)) < 0) {
		printf("Unable to open [%s]\n", capdev_str);
		goto err0;
	}

	if (setup_cap() < 0) {
		printf("Unable to setup capture\n");
		goto err1;
	}

	printf("capture device setup done\n");

	if (map_buffers() < 0) {
		printf("Unable to map I/O memory\n");
		goto err1;
	}

	printf("buffers mapping done\n");

	if (stream_start() < 0) {
		printf("Unable to start stream\n");
		goto err2;
	}

	printf("Stream starting... with fps=%d\n", FPS_VIDEO);

	gettimeofday(&ts, 0);

	do {
		idx = frame_get(&fsize);
		frame_render(idx, fsize);
		frame_put(idx);
		gettimeofday(&te, 0);
		tus = (te.tv_sec - ts.tv_sec) * 1000000 + (te.tv_usec - ts.tv_usec);
		if(tus <= FRAME_DURATION) {
			if(!exitflag) usleep(FRAME_DURATION - tus);
		} else {
			// printf("rander a frame with %.3fms\n", tus / 1000.0);
		}

		printf("Rander a frame sz = %d, takes %.3fms\n", fsize, tus / 1000.0);

		gettimeofday(&ts, 0);

	} while(!exitflag);

	printf("Stopping stream...\n");

	stream_stop();
err2:
	umap_buffers();
err1:
	close(fd_cap);
err0:
	dec_exit();
err:
	display_exit();

	return 0;
}
Example #12
0
int main(int argc, char *argv[])
{
	int idx, tus;
	unsigned long ss;
	struct timeval ts, te;
	char cappath[128];

	if(argc >= 2) {
		strcpy(cappath, argv[1]);
	} else {
		strcpy(cappath, dev_cap);
	}

	signal(SIGQUIT, exit_signal);
	signal(SIGINT,  exit_signal);
	signal(SIGPIPE, SIG_IGN);

	if(enc_init(CAP_WIDTH, CAP_HEIGHT, FPS_VIDEO, VPU_V_AVC) < 0) {
		printf("enc_init error\n");
		return -1;
	}

	if ((fd_cap = open(cappath, O_RDWR)) < 0) {
		printf("Unable to open [%s]\n", cappath);
		goto err;
	}

	if (setup_cap() < 0) {
		printf("Unable to setup capture\n");
		goto err0;
	}

	printf("capture device setup done\n");

	if(display_init(dev_out) < 0) {
		printf("display_init err\n");
		goto err0;
	}

	if (map_buffers() < 0) {
		printf("Unable to map v4l2 memory\n");
		goto err1;
	}

	printf("buffers mapping done\n");

	if (stream_start() < 0) {
		printf("Unable to start stream\n");
		goto err2;
	}

	printf("Stream starting... with fps=%d\n", FPS_VIDEO);

	static int xxx = 0;

	gettimeofday(&ts, 0);

	fd_enc = open("myenc.h264", O_RDWR | O_CREAT | O_TRUNC, 0666);

	do {
		idx = frame_get();
		frame_render(idx);
		frame_put(idx);
		gettimeofday(&te, 0);
		tus = (te.tv_sec - ts.tv_sec) * 1000000 + (te.tv_usec - ts.tv_usec);

		if(tus <= FRAME_DURATION) {
			if(!exitflag) usleep(FRAME_DURATION - tus);
		} else {
			printf("rander a frame with %.3fms\n", tus / 1000.0);
		}
		// printf("rander a frame with %.3fms\n", tus / 1000.0);

		gettimeofday(&ts, 0);

	} while(!exitflag);

	close(fd_enc);

	printf("Stopping stream...\n");

	stream_stop();
err2:
	umap_buffers();
err1:
	display_exit();
err0:
	close(fd_cap);
err:
	enc_exit();

	return 0;
}