Exemplo n.º 1
0
int main(int argc, char *argv[])
{
	init_mdata();
	init_adata();

	printf("Loading file 'bytecode'\n");
	pc_t* pc = pc_new("bytecode");

	while (pc_safe(pc))
	{
		printf("ADDR: %x, OP: %x\n", pc->address, pc->line->op);
		pc_inc(pc, 1);
		pc_update(pc);
	}
	pc_inc(pc, -1);
	pc_branch(pc, 1);
	pc_update(pc);

	while (pc_safe(pc))
	{
		printf("ADDR: %x, OP: %x\n", pc->address, pc->line->op);
		pc_inc(pc, 1);
		pc_update(pc);
	}

	pc_return(pc);
	pc_update(pc);
	printf("ADDR: %x, OP: %x\n", pc->address, pc->line->op);

	pc_del(pc);
	return 0;
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: andrewrk/mpd
/**
 * Initialize the decoder and player core, including the music pipe.
 */
static void
initialize_decoder_and_player(void)
{
	const struct config_param *param;
	char *test;
	size_t buffer_size;
	float perc;
	unsigned buffered_chunks;
	unsigned buffered_before_play;

	param = config_get_param(CONF_AUDIO_BUFFER_SIZE);
	if (param != NULL) {
		long tmp = strtol(param->value, &test, 10);
		if (*test != '\0' || tmp <= 0 || tmp == LONG_MAX)
			MPD_ERROR("buffer size \"%s\" is not a positive integer, "
				  "line %i\n", param->value, param->line);
		buffer_size = tmp;
	} else
		buffer_size = DEFAULT_BUFFER_SIZE;

	buffer_size *= 1024;

	buffered_chunks = buffer_size / CHUNK_SIZE;

	if (buffered_chunks >= 1 << 15)
		MPD_ERROR("buffer size \"%li\" is too big\n", (long)buffer_size);

	param = config_get_param(CONF_BUFFER_BEFORE_PLAY);
	if (param != NULL) {
		perc = strtod(param->value, &test);
		if (*test != '%' || perc < 0 || perc > 100) {
			MPD_ERROR("buffered before play \"%s\" is not a positive "
				  "percentage and less than 100 percent, line %i",
				  param->value, param->line);
		}
	} else
		perc = DEFAULT_BUFFER_BEFORE_PLAY;

	buffered_before_play = (perc / 100) * buffered_chunks;
	if (buffered_before_play > buffered_chunks)
		buffered_before_play = buffered_chunks;

	global_player_control = pc_new(buffered_chunks, buffered_before_play);
}
iwdp_status iwdpm_select_port(iwdp_t iwdp, const char *device_id,
    int *to_port, int *to_min_port, int *to_max_port) {
  iwdpm_t self = (iwdpm_t)iwdp->state;
  int ret = 0;
  // reparse every time, in case the file has changed
  int is_file = 0;
  if (!self->pc) {
    self->pc = pc_new();
    if (pc_add_line(self->pc, self->config, strlen(self->config))) {
      pc_clear(self->pc);
      pc_add_file(self->pc, self->config);
      is_file = 1;
    }
  }
  ret = pc_select_port(self->pc, device_id, to_port, to_min_port,to_max_port);
  if (is_file) {
    pc_free(self->pc);
    self->pc = NULL;
  }
  return (ret ? IWDP_ERROR : IWDP_SUCCESS);
}