Exemple #1
0
void vsx_statelist::prev_state()
{
  if ((*state_iter).engine != vxe) return;
  if (state_iter == statelist.begin()) state_iter = statelist.end();
  --state_iter;
  init_current((*state_iter).engine, &(*state_iter));
  transition_time = 2.0f;
}
Exemple #2
0
void vsx_statelist::random_state() {
  if (0 == statelist.size()) return;
  if ((*state_iter).engine != vxe) return;
  int steps = rand() % statelist.size();
  while (steps) {
    ++state_iter;
    if (state_iter == statelist.end()) state_iter = statelist.begin();
    --steps;
  }
  if ((*state_iter).engine == vxe) { random_state(); return; }
  init_current((*state_iter).engine, &(*state_iter));
  transition_time = 2.0f;
}
Exemple #3
0
void vsx_statelist::select_visual(int selection)
{
    if (0 == statelist.size()) return;
    if ((*state_iter).engine != vxe) return;
    bool change = true;
    int count = 0;
    state_iter = statelist.begin();
    while (change) {
      ++state_iter;
      count++;
      if (count >= selection) change = false;
      if (state_iter == statelist.end()) {
          state_iter = statelist.begin();
          change = false;
      }
    }
    init_current((*state_iter).engine, &(*state_iter));
    transition_time = 2.0f;
}
Exemple #4
0
lzma_index_read(lzma_index *i, lzma_index_record *info)
{
	if (i->current.group == NULL) {
		// We are at the beginning of the Record list. Set up
		// i->current point at the first Record. Return if there
		// are no Records.
		if (init_current(i))
			return true;
	} else do {
		// Try to go the next Record.
		if (i->current.record < i->current.group->last)
			++i->current.record;
		else if (i->current.group->next == NULL)
			return true;
		else
			next_group(i);
	} while (i->current.group->paddings[i->current.record]);

	// We found a new Record. Set the information to *info.
	set_info(i, info);

	return false;
}
Exemple #5
0
lzma_index_locate(lzma_index *i, lzma_index_record *info, lzma_vli target)
{
	// Check if it is possible to fullfill the request.
	if (target >= i->uncompressed_size)
		return true;

	// Now we know that we will have an answer. Initialize the current
	// read position if needed.
	if (i->current.group == NULL && init_current(i))
		return true;

	// Locate the group where the wanted Block is. First search forward.
	while (i->current.uncompressed_offset <= target) {
		// If the first uncompressed byte of the next group is past
		// the target offset, it has to be this or an earlier group.
		if (i->current.uncompressed_offset + i->current.group
				->uncompressed_sums[i->current.group->last]
				> target)
			break;

		// Go forward to the next group.
		next_group(i);
	}

	// Then search backward.
	while (i->current.uncompressed_offset > target)
		previous_group(i);

	// Now the target Block is somewhere in i->current.group. Offsets
	// in groups are relative to the beginning of the group, thus
	// we must adjust the target before starting the search loop.
	assert(target >= i->current.uncompressed_offset);
	target -= i->current.uncompressed_offset;

	// Use binary search to locate the exact Record. It is the first
	// Record whose uncompressed_sums[] value is greater than target.
	// This is because we want the rightmost Record that fullfills the
	// search criterion. It is possible that there are empty Blocks or
	// padding, we don't want to return them.
	size_t left = 0;
	size_t right = i->current.group->last;

	while (left < right) {
		const size_t pos = left + (right - left) / 2;
		if (i->current.group->uncompressed_sums[pos] <= target)
			left = pos + 1;
		else
			right = pos;
	}

	i->current.record = left;

#ifndef NDEBUG
	// The found Record must not be padding or have zero uncompressed size.
	assert(!i->current.group->paddings[i->current.record]);

	if (i->current.record == 0)
		assert(i->current.group->uncompressed_sums[0] > 0);
	else
		assert(i->current.group->uncompressed_sums[i->current.record]
				- i->current.group->uncompressed_sums[
					i->current.record - 1] > 0);
#endif

	set_info(i, info);

	return false;
}
Exemple #6
0
/**
 * monitor_tbufs - monitor the contents of tbufs
 */
static int monitor_tbufs(void)
{
    int i;

    struct t_struct *tbufs;      /* Pointer to hypervisor maps */
    struct t_buf **meta;         /* pointers to the trace buffer metadata    */
    unsigned char **data;        /* pointers to the trace buffer data areas
                                  * where they are mapped into user space.   */
    unsigned long tbufs_mfn;     /* mfn of the tbufs                         */
    unsigned int  num;           /* number of trace buffers / logical CPUS   */
    unsigned long tinfo_size;    /* size of t_info metadata map              */
    unsigned long size;          /* size of a single trace buffer            */

    unsigned long data_size, rec_size;

    /* get number of logical CPUs (and therefore number of trace buffers) */
    num = get_num_cpus();

    init_current(num);
    alloc_qos_data(num);

    printf("CPU Frequency = %7.2f\n", opts.cpu_freq);
    
    /* setup access to trace buffers */
    get_tbufs(&tbufs_mfn, &tinfo_size);
    tbufs = map_tbufs(tbufs_mfn, num, tinfo_size);

    size = tbufs->t_info->tbuf_size * XC_PAGE_SIZE;

    data_size = size - sizeof(struct t_buf);

    meta = tbufs->meta;
    data = tbufs->data;

    if ( eventchn_init() < 0 )
        fprintf(stderr, "Failed to initialize event channel; "
                "Using POLL method\r\n");

    /* now, scan buffers for events */
    while ( !interrupted )
    {
        for ( i = 0; (i < num) && !interrupted; i++ )
        {
            unsigned long start_offset, end_offset, cons, prod;

            cons = meta[i]->cons;
            prod = meta[i]->prod;
            xen_rmb(); /* read prod, then read item. */

            if ( cons == prod )
                continue;

            start_offset = cons % data_size;
            end_offset = prod % data_size;

            if ( start_offset >= end_offset )
            {
                while ( start_offset != data_size )
                {
                    rec_size = process_record(
                        i, (struct t_rec *)(data[i] + start_offset));
                    start_offset += rec_size;
                }
                start_offset = 0;
            }
            while ( start_offset != end_offset )
            {
                rec_size = process_record(
                    i, (struct t_rec *)(data[i] + start_offset));
                start_offset += rec_size;
            }
            xen_mb(); /* read item, then update cons. */
            meta[i]->cons = prod;
        }

	wait_for_event();
	wakeups++;
    }

    /* cleanup */
    free(meta);
    free(data);
    /* don't need to munmap - cleanup is automatic */

    return 0;
}
/**
 * monitor_tbufs - monitor the contents of tbufs
 */
int monitor_tbufs(void)
{
    int i;
    extern int process_record(int, struct t_rec *);
    extern void alloc_qos_data(int ncpu);

    void *tbufs_mapped;          /* pointer to where the tbufs are mapped    */
    struct t_buf **meta;         /* pointers to the trace buffer metadata    */
    char         **data;         /* pointers to the trace buffer data areas
                                  * where they are mapped into user space.   */
    unsigned long tbufs_mfn;     /* mfn of the tbufs                         */
    unsigned int  num;           /* number of trace buffers / logical CPUS   */
    unsigned long size;          /* size of a single trace buffer            */

    unsigned long data_size, rec_size;

    /* get number of logical CPUs (and therefore number of trace buffers) */
    num = get_num_cpus();

    init_current(num);
    alloc_qos_data(num);

    printf("CPU Frequency = %7.2f\n", opts.cpu_freq);
    
    /* setup access to trace buffers */
    get_tbufs(&tbufs_mfn, &size);

    tbufs_mapped = map_tbufs(tbufs_mfn, num, size);

    data_size = size - sizeof(struct t_buf);

    /* build arrays of convenience ptrs */
    meta  = init_bufs_ptrs (tbufs_mapped, num, size);
    data  = (char **)init_rec_ptrs(meta, num);

    if ( eventchn_init() < 0 )
        fprintf(stderr, "Failed to initialize event channel; "
                "Using POLL method\r\n");

    /* now, scan buffers for events */
    while ( !interrupted )
    {
        for ( i = 0; (i < num) && !interrupted; i++ )
        {
            while ( meta[i]->cons != meta[i]->prod )
            {
                rmb(); /* read prod, then read item. */
                rec_size = process_record(
                    i, (struct t_rec *)(data[i] + meta[i]->cons % data_size));
                mb(); /* read item, then update cons. */
                meta[i]->cons += rec_size;
            }
        }

	wait_for_event();
	wakeups++;
    }

    /* cleanup */
    free(meta);
    free(data);
    /* don't need to munmap - cleanup is automatic */

    return 0;
}
Exemple #8
0
void vsx_statelist::render() 
{
  if (render_first)
  {
    glewInit();
    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);
    if (tex1.has_buffer_support())
    {
      tex1.init_feedback_buffer(viewport[2], viewport[3]);
      tex_to.init_feedback_buffer(viewport[2], viewport[3]);

      get_files_recursive(own_path+"visuals_faders", &fader_file_list,"",".svn CVS");
      for (std::list<vsx_string>::iterator it = fader_file_list.begin(); it != fader_file_list.end(); ++it)
      {
        #ifdef VSXU_DEBUG
          printf("initializing fader %s\n", (*it).c_str());
        #endif
        vsx_engine* lvxe = new vsx_engine();
        lvxe->set_module_list( module_list );
        lvxe->start();
        lvxe->load_state(*it);
        faders.push_back(lvxe);
        fade_id = 0;
      }
    }
    transitioning = false;
    render_first = false;
    if ( state_iter == statelist.end() ) return;

    // mark all state_info instances volatile
    for (state_iter = statelist.begin(); state_iter != statelist.end(); state_iter++)
    {
      (*state_iter).is_volatile = true;
    }

    // go through statelist and load and validate every plugin
    std::vector<state_info> new_statelist;
    for (state_iter = statelist.begin(); state_iter != statelist.end(); state_iter++)
    {
      if (init_current((*state_iter).engine, &(*state_iter)) > 0)
      {
        continue;
      }
      new_statelist.push_back(*state_iter);
      if (option_preload_all == true)
      {
        while ( (*state_iter).engine->get_modules_left_to_load() )
        {
          (*state_iter).engine->process_message_queue( &(*state_iter).cmd_in, cmd_out = &(*state_iter).cmd_out,false, true);
          (*state_iter).engine->render();
        }
      }
    }
    statelist = new_statelist;

    // mark all state_info instances non-volatile (engine will be deleted when state_iter will be deleted)
    for (state_iter = statelist.begin(); state_iter != statelist.end(); state_iter++)
    {
      (*state_iter).is_volatile = true;
    }

    // reset state_iter to a random state
    state_iter = statelist.begin();
    int steps = rand() % statelist.size();
    while (steps) {
      ++state_iter;
      if (state_iter == statelist.end()) state_iter = statelist.begin();
      --steps;
    }

    vxe = (*state_iter).engine;
    cmd_in = &(*state_iter).cmd_in;
    cmd_out = &(*state_iter).cmd_out;
  } // render first

  // prevent from rendering by mistake
  if ( !statelist.size() ) return;

  if ((*state_iter).engine != vxe) // change is on the way
  {
    if ( tex_to.has_buffer_support() )
    {
      tex_to.begin_capture_to_buffer();
        if ((*state_iter).engine)
        {
          (*state_iter).engine->process_message_queue(&(*state_iter).cmd_in,&(*state_iter).cmd_out);
          (*state_iter).engine->render();
        }
        glColorMask(false, false, false, true);
        glClearColor(0,0,0,1);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glColorMask(true, true, true, true);
      tex_to.end_capture_to_buffer();
      if (
        (*state_iter).engine->get_modules_left_to_load() == 0 &&
        (*state_iter).engine->get_commands_internal_count() &&
        transition_time > 1.0f
      )
      {
        transition_time = 1.0f;
        timer.start();
        fade_id = rand() % (faders.size());
      }
    } else
    {
      transition_time = -1.0f;
    }

    if (transition_time <= 0.0)
    {
      vxe = (*state_iter).engine;
      cmd_in = &(*state_iter).cmd_in;
      cmd_out = &(*state_iter).cmd_out;
      transitioning = false;
      transition_time = 2.0f;
      if (cmd_out && cmd_in)
      {
        if (vxe)
        {
          vxe->process_message_queue(cmd_in,cmd_out);
        }
        cmd_out->clear(true);
      }
      if (vxe)
      {
        vxe->render();
      }
    } else
    {
      if (cmd_out && cmd_in)
      {
        if (vxe)
        {
          vxe->process_message_queue(cmd_in,cmd_out);
        }
        cmd_out->clear(true);
      }

      // begin capture
      if (tex1.has_buffer_support())
      {
        tex1.begin_capture_to_buffer();
      }

      // render
      if (vxe)
      {
        vxe->render();
      }
      glColorMask(false, false, false, true);
      glClearColor(0,0,0,1);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glColorMask(true, true, true, true);

      // end capture and send to fader
      if (tex1.has_buffer_support())
      {
        tex1.end_capture_to_buffer();
        vsx_module_param_texture* param_t_a = (vsx_module_param_texture*)faders[fade_id]->get_in_param_by_name("visual_fader", "texture_a_in");
        vsx_module_param_texture* param_t_b = (vsx_module_param_texture*)faders[fade_id]->get_in_param_by_name("visual_fader", "texture_b_in");
        vsx_module_param_float* param_pos = (vsx_module_param_float*)faders[fade_id]->get_in_param_by_name("visual_fader", "fade_pos_in");
        vsx_module_param_float* fade_pos_from_engine = (vsx_module_param_float*)faders[fade_id]->get_in_param_by_name("visual_fader", "fade_pos_from_engine");
        faders[fade_id]->process_message_queue(&l_cmd_in, &l_cmd_out);
        l_cmd_out.clear();
        if (param_t_a && param_t_b && param_pos && fade_pos_from_engine)
        {
          param_t_a->set(&tex1);
          param_t_b->set(&tex_to);
          fade_pos_from_engine->set(1.0f);
          float t = transition_time;
          if (t > 1.0f) t = 1.0f;
          if (t < 0.0f) t = 0.0f;
          param_pos->set(1.0-t);
          glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
          faders[fade_id]->render();
        }
      }

      if (transition_time <= 1.0f)
      {
        transition_time -= timer.dtime();
      }
    }
  } else
  {
    if (cmd_out && cmd_in)
    {
      vxe->process_message_queue(cmd_in, cmd_out);
      cmd_out->clear();
    }
    vxe->render();
    if (randomizer)
    {
      randomizer_time -= vxe->get_engine_info()->real_dtime;
      if (randomizer_time < 0.0f)
      {
        random_state();
        randomizer_time = (float)(rand()%1000)*0.001f*15.0f+10.0f;
      }
    }
  }
}