Exemplo n.º 1
0
static int hashlist_destroy (VisCollection *collection)
{
	VisHashlist *hashlist = VISUAL_HASHLIST (collection);
	VisListEntry *le = NULL;

	/* Destroy all entries in hashlist first */
	while (visual_list_next (hashlist->list, &le) != NULL) {
		VisListEntry *prev = le;
		VisListEntry *next = le;

		visual_list_prev (hashlist->list, &prev);
		visual_list_next (hashlist->list, &next);

		visual_hashlist_remove_list_entry (hashlist, le);

		if (next == NULL)
			break;

		le = prev;
	}

	/* Destroy the rest */
	if (hashlist->list != NULL)
		visual_object_unref (VISUAL_OBJECT (hashlist->list));

	if (hashlist->index != NULL)
		visual_object_unref (VISUAL_OBJECT (hashlist->index));

	hashlist->list = NULL;
	hashlist->index = NULL;

	return VISUAL_OK;
}
Exemplo n.º 2
0
/**
 * Clones the source VisParamContainer into the destination VisParamContainer. When an entry with a certain name
 * already exists in the destination container, it will be overwritten with a new value.
 *
 * @param destcont A pointer to the VisParamContainer in which the VisParamEntry values are copied.
 * @param srccont A pointer to the VisParamContainer from which the VisParamEntry values are copied.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_CONTAINER_NULL, on failure.
 */
int visual_param_container_copy (VisParamContainer *destcont, VisParamContainer *srccont)
{
	VisListEntry *le = NULL;
	VisParamEntry *destparam;
	VisParamEntry *srcparam;
	VisParamEntry *tempparam;

	visual_log_return_val_if_fail (destcont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);
	visual_log_return_val_if_fail (srccont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);

	while ((srcparam = visual_list_next (&srccont->entries, &le)) != NULL) {
		tempparam = visual_param_container_get (destcont, visual_param_entry_get_name (srcparam));

		/* Already exists, overwrite */
		if (tempparam != NULL) {
			visual_param_entry_set_from_param (tempparam, srcparam);

			continue;
		}

		/* Does not yet exist, create a new entry */
		destparam = visual_param_entry_new (visual_param_entry_get_name (srcparam));
		visual_param_entry_set_from_param (destparam, srcparam);

		visual_param_container_add (destcont, destparam);
	}

	return VISUAL_OK;
}
Exemplo n.º 3
0
// FIXME: This function is entirely broken from the looks of it.
int visual_audio_get_sample_mixed_all (VisAudio *audio, VisBuffer *buffer, int divide)
{
	VisListEntry *le = NULL;
	VisAudioSamplePool *samplepool;
	VisAudioSamplePoolChannel *channel;
	VisBuffer temp;
	int first = TRUE;

	visual_return_val_if_fail (audio != NULL, -VISUAL_ERROR_AUDIO_NULL);
	visual_return_val_if_fail (buffer != NULL, -VISUAL_ERROR_AUDIO_SAMPLEPOOL_NULL);

	visual_buffer_init_allocate (&temp, visual_buffer_get_size (buffer), visual_buffer_destroyer_free);

	samplepool = visual_audio_samplepool_new (); // this function's broken. This line was added to get rid of a compile warning. Not sure what samplepool's supposed to be, because it appears the below code expects an already existing VisAudioSamplePool. Dunno.

	while ((channel = visual_list_next (samplepool->channels, &le)) != NULL) {
		if (visual_audio_get_sample (audio, &temp, channel->channelid) == VISUAL_OK) {
			if (first == TRUE) {
				visual_audio_sample_buffer_mix (buffer, &temp, FALSE, 1.0);

				first = FALSE;
			} else {
				visual_audio_sample_buffer_mix (buffer, &temp, divide, 1.0);
			}
		}
	}

	visual_object_unref (VISUAL_OBJECT (&temp));

	return VISUAL_OK;
}
Exemplo n.º 4
0
static int get_next_pcall_id (VisList *callbacks)
{
	VisListEntry *le = NULL;
	VisParamEntryCallback *pcall;
	int found = FALSE;
	int i;

	/* Walk through all possible ids */
	for (i = 0; i < VISUAL_PARAM_CALLBACK_ID_MAX; i++) {

		found = FALSE;
		/* Check all the callbacks if the id is used */
		while ((pcall = visual_list_next (callbacks, &le)) != NULL) {

			/* Found the ID, break and get ready for the next iterate */
			if (pcall->id == i) {
				found = TRUE;

				break;
			}
		}

		/* The id has NOT been found, thus is an original, and we return this as the next id */
		if (found == FALSE)
			return i;
	}

	/* This is virtually impossible, or something very wrong is going ok, but no id seems to be left */
	return -1;
}
Exemplo n.º 5
0
int visual_ringbuffer_get_size (VisRingBuffer *ringbuffer)
{
    VisListEntry *le = NULL;
    VisRingBufferEntry *entry;
    int totalsize = 0;

    visual_return_val_if_fail (ringbuffer != NULL, -VISUAL_ERROR_RINGBUFFER_NULL);

    while ((entry = visual_list_next (ringbuffer->entries, &le)) != NULL) {
        int bsize = 0;

        if (entry->type == VISUAL_RINGBUFFER_ENTRY_TYPE_BUFFER) {

            if ((bsize = visual_buffer_get_size (entry->buffer)) > 0)
                totalsize += bsize;

        } else if (entry->type == VISUAL_RINGBUFFER_ENTRY_TYPE_FUNCTION) {

            if (entry->sizefunc != NULL) {
                totalsize += entry->sizefunc (ringbuffer, entry);
            } else {
                VisBuffer *tempbuf = entry->datafunc (ringbuffer, entry);

                if ((bsize = visual_buffer_get_size (tempbuf)) > 0)
                    totalsize += bsize;

                visual_buffer_unref (tempbuf);
            }
        }
    }

    return totalsize;
}
Exemplo n.º 6
0
int pipeline_container_negotiate (LVAVSPipelineContainer *container, VisVideo *video)
{
    VisListEntry *le = NULL;
    LVAVSPipelineElement *element;

    while ((element = visual_list_next (container->members, &le)) != NULL) {

        switch (element->type) {
            case LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR:
                visual_actor_set_video (element->data.actor, video);
                visual_actor_video_negotiate (element->data.actor, VISUAL_VIDEO_DEPTH_NONE, FALSE, FALSE);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM:
                visual_transform_set_video (element->data.transform, video);
                visual_transform_video_negotiate (element->data.transform);

                break;


            case LVAVS_PIPELINE_ELEMENT_TYPE_CONTAINER:

                pipeline_container_negotiate (LVAVS_PIPELINE_CONTAINER (element), video);

                break;

            default:

                break;
        }
    }

    return VISUAL_OK;
}
Exemplo n.º 7
0
int visual_audio_samplepool_channel_flush_old (VisAudioSamplePoolChannel *channel)
{
	VisList *list;
	VisListEntry *le = NULL;
	VisRingBufferEntry *rentry;
	VisAudioSample *sample;

	visual_return_val_if_fail (channel != NULL, -VISUAL_ERROR_AUDIO_SAMPLEPOOL_CHANNEL_NULL);

	list = visual_ringbuffer_get_list (channel->samples);

	while ((rentry = visual_list_next (list, &le)) != NULL) {
		VisTime diff;
		VisTime curtime;

		sample = visual_ringbuffer_entry_get_functiondata (rentry);

		visual_time_get (&curtime);

		visual_time_difference (&diff, &sample->timestamp, &curtime);

		if (visual_time_past (&diff, &channel->samples_timeout) == TRUE) {
			visual_list_destroy (list, &le);

			if (le == NULL)
				break;
		}
	}

	return VISUAL_OK;
}
Exemplo n.º 8
0
/**
 * Notifies all the callbacks for the given VisParamEntry parameter.
 *
 * @param param Pointer to the VisParamEntry of which all the change notification
 * 	callbacks need to be called.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_NULL on failure.
 */
int visual_param_entry_notify_callbacks (VisParamEntry *param)
{
	VisListEntry *le = NULL;
	VisParamEntryCallback *pcall;
	
	visual_log_return_val_if_fail (param != NULL, -VISUAL_ERROR_PARAM_NULL);

	while ((pcall = visual_list_next (&param->callbacks, &le)) != NULL)
		pcall->callback (param, visual_object_get_private (VISUAL_OBJECT (pcall)));

	return VISUAL_OK;
}
Exemplo n.º 9
0
int pipeline_container_realize (LVAVSPipelineContainer *container)
{
    VisListEntry *le = NULL;
    LVAVSPipelineElement *element;

    while ((element = visual_list_next (container->members, &le)) != NULL) {

        switch (element->type) {
            case LVAVS_PIPELINE_ELEMENT_TYPE_NULL:

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR:

                visual_actor_realize (element->data.actor);
                visual_param_container_copy_match (visual_plugin_get_params (
                            visual_actor_get_plugin (element->data.actor)), element->params);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM:

                visual_transform_realize (element->data.transform);
                visual_param_container_copy_match (visual_plugin_get_params (
                            visual_transform_get_plugin (element->data.transform)), element->params);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_MORPH:

                visual_morph_realize (element->data.morph);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_RENDERSTATE:

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_CONTAINER:

                pipeline_container_realize (LVAVS_PIPELINE_CONTAINER (element));

                break;

            default:
                visual_log (VISUAL_LOG_CRITICAL, "Invalid LVAVSPipelineElementType");

                break;
        }
    }
    return 0;
}
Exemplo n.º 10
0
int visual_audio_samplepool_flush_old (VisAudioSamplePool *samplepool)
{
	VisListEntry *le = NULL;
	VisAudioSamplePoolChannel *channel;

	visual_return_val_if_fail (samplepool != NULL, -VISUAL_ERROR_AUDIO_SAMPLEPOOL_NULL);

	while ((channel = visual_list_next (samplepool->channels, &le)) != NULL) {
		visual_audio_samplepool_channel_flush_old (channel);
	}

	return VISUAL_OK;
}
Exemplo n.º 11
0
VisAudioSamplePoolChannel *visual_audio_samplepool_get_channel (VisAudioSamplePool *samplepool, const char *channelid)
{
	VisListEntry *le = NULL;
	VisAudioSamplePoolChannel *channel;

	visual_return_val_if_fail (samplepool != NULL, NULL);
	visual_return_val_if_fail (channelid != NULL, NULL);

	while ((channel = visual_list_next (samplepool->channels, &le)) != NULL) {
		if (strcmp (channel->channelid, channelid) == 0)
			return channel;
	}

	return NULL;
}
Exemplo n.º 12
0
/**
 * Retrieve a VisParamEntry from a VisParamContainer by giving the name of the VisParamEntry that is requested.
 *
 * @param paramcontainer A pointer to the VisParamContainer from which a VisParamEntry is requested.
 * @param name The name of the VisParamEntry that is requested from the VisParamContainer.
 *
 * @return Pointer to the VisParamEntry, or NULL.
 */
VisParamEntry *visual_param_container_get (VisParamContainer *paramcontainer, const char *name)
{
	VisListEntry *le = NULL;
	VisParamEntry *param;

	visual_log_return_val_if_fail (paramcontainer != NULL, NULL);
	visual_log_return_val_if_fail (name != NULL, NULL);

	while ((param = visual_list_next (&paramcontainer->entries, &le)) != NULL) {
		param = le->data;

		if (strcmp (param->name, name) == 0)
			return param;
	}

	return NULL;
}
Exemplo n.º 13
0
int visual_hashlist_clear (VisHashlist *hashlist)
{
	VisListEntry *le = NULL;

	visual_return_val_if_fail (hashlist != NULL, -VISUAL_ERROR_HASHLIST_NULL);

	/* Destroy all entries in hashlist first */
	while (visual_list_next (hashlist->list, &le) != NULL)
		visual_hashlist_remove_list_entry (hashlist, le);

	if (hashlist->index != NULL)
		visual_object_unref (VISUAL_OBJECT (hashlist->index));

	hashlist->index = visual_hashmap_new (NULL);
	visual_hashmap_set_table_size (hashlist->index, hashlist->size);

	return VISUAL_OK;
}
Exemplo n.º 14
0
/**
 * Copies matching VisParamEntry elements from srccont into destcont, matching on the name.
 *
 * @param destcont A pointer to the VisParamContainer in which the VisParamEntry values are copied.
 * @param srccont A pointer to the VisParamContainer from which the VisParamEntry values are copied.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_CONTAINER_NULL, on failure.
 */
int visual_param_container_copy_match (VisParamContainer *destcont, VisParamContainer *srccont)
{
	VisListEntry *le = NULL;
	VisParamEntry *destparam;
	VisParamEntry *srcparam;

	visual_log_return_val_if_fail (destcont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);
	visual_log_return_val_if_fail (srccont != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);

	while ((destparam = visual_list_next (&destcont->entries, &le)) != NULL) {
		srcparam = visual_param_container_get (srccont, visual_param_entry_get_name (destparam));

		if (srcparam != NULL)
			visual_param_entry_set_from_param (destparam, srcparam);
	}

	return VISUAL_OK;
}
Exemplo n.º 15
0
/**
 * Removes a VisParamEntry from the VisParamContainer by giving the name of the VisParamEntry that needs
 * to be removed.
 *
 * @param paramcontainer A pointer to the VisParamContainer from which a VisParamEntry needs to be removed.
 * @param name The name of the VisParamEntry that needs to be removed from the VisParamContainer.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_CONTAINER_NULL, -VISUAL_ERROR_NULL
 *	or -VISUAL_ERROR_PARAM_NOT_FOUND on failure.
 */
int visual_param_container_remove (VisParamContainer *paramcontainer, const char *name)
{
	VisListEntry *le = NULL;
	VisParamEntry *param;

	visual_log_return_val_if_fail (paramcontainer != NULL, -VISUAL_ERROR_PARAM_CONTAINER_NULL);
	visual_log_return_val_if_fail (name != NULL, -VISUAL_ERROR_NULL);

	while ((param = visual_list_next (&paramcontainer->entries, &le)) != NULL) {

		if (strcmp (param->name, name) == 0) {
			visual_list_delete (&paramcontainer->entries, &le);

			return VISUAL_OK;
		}
	}

	return -VISUAL_ERROR_PARAM_NOT_FOUND;
}
Exemplo n.º 16
0
int pipeline_container_propagate_event (LVAVSPipelineContainer *container, VisEvent *event)
{
    VisListEntry *le = NULL;
    VisEventQueue *pluginqueue;
    LVAVSPipelineElement *element;

    while ((element = visual_list_next (container->members, &le)) != NULL) {

        switch (element->type) {
            case LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR:

                pluginqueue = visual_plugin_get_eventqueue (visual_actor_get_plugin (element->data.actor));

                visual_object_ref (VISUAL_OBJECT (event));
                visual_event_queue_add (pluginqueue, event);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM:

                pluginqueue = visual_plugin_get_eventqueue (visual_actor_get_plugin (element->data.actor));

                visual_object_ref (VISUAL_OBJECT (event));
                visual_event_queue_add (pluginqueue, event);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_CONTAINER:

                pipeline_container_propagate_event (LVAVS_PIPELINE_CONTAINER (element), event);

                break;

            default:

                break;
        }
    }


    return VISUAL_OK;
}
Exemplo n.º 17
0
/**
 * Removes a change notification callback from the list of callbacks.
 *
 * @param param Pointer to the VisParamEntry from which a change notification callback is removed.
 * @param id The callback ID that was given by the visual_param_entry_add_callback method.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_NULL on failure.
 */
int visual_param_entry_remove_callback (VisParamEntry *param, int id)
{
	VisListEntry *le = NULL;
	VisParamEntryCallback *pcall;

	visual_log_return_val_if_fail (param != NULL, -VISUAL_ERROR_PARAM_NULL);

	while ((pcall = visual_list_next (&param->callbacks, &le)) != NULL) {

		if (id == pcall->id) {
			visual_list_delete (&param->callbacks, &le);

			visual_object_unref (VISUAL_OBJECT (pcall));

			return VISUAL_OK;
		}
	}

	return VISUAL_OK;
}
Exemplo n.º 18
0
static VisUIWidget * check_widget(VisUIWidget * w, const char * name,
                                  bg_parameter_info_t * info)
  {
  VisUIWidget * ret = NULL;
  int i;
  int num_items;
  VisListEntry * list_entry;
  switch(w->type)
    {
    case VISUAL_WIDGET_TYPE_RANGE:       /**< Range base widget: \a VisUIRange. */
    case VISUAL_WIDGET_TYPE_ENTRY:       /**< Entry box widget: \a VisUIEntry. */
    case VISUAL_WIDGET_TYPE_MUTATOR:     /**< Mutator base widget: \a VisUIMutator. */
    case VISUAL_WIDGET_TYPE_NULL:    /**< NULL widget */
    case VISUAL_WIDGET_TYPE_WIDGET:      /**< Base widget: \a VisUIWidget. */
    case VISUAL_WIDGET_TYPE_LABEL:       /**< Label widget: \a VisUILabel. */
    case VISUAL_WIDGET_TYPE_IMAGE:       /**< Image widget: \a VisUIImage. */
    case VISUAL_WIDGET_TYPE_SEPARATOR:   /**< Separator widget: \a VisUISeparator. */
    case VISUAL_WIDGET_TYPE_COLORPALETTE:/**< Color palette widget: \a VisUIColorPalette. */
    case VISUAL_WIDGET_TYPE_CHOICE:      /**< Choice base widget: \a VisUIChoice. */
      break;
    case VISUAL_WIDGET_TYPE_CONTAINER:   /**< Container widget: \a VisUIContainer. */
    case VISUAL_WIDGET_TYPE_FRAME:       /**< Frame widget: \a VisUIFrame. */
      /* Get child */
      return check_widget(VISUAL_UI_CONTAINER(w)->child, name, info);
      break;
    case VISUAL_WIDGET_TYPE_BOX:         /**< Box widget: \a VisUIBox. */
      /* Get children */
      list_entry = NULL;
      while(visual_list_next(&VISUAL_UI_BOX(w)->childs, &list_entry))
        {
        if((ret = check_widget(list_entry->data, name, info)))
          return ret;
        }
      break;
    case VISUAL_WIDGET_TYPE_TABLE:       /**< Table widget: \a VisUITable. */
      /* Get children */
      list_entry = NULL;
      while(visual_list_next(&VISUAL_UI_TABLE(w)->childs, &list_entry))
        {
        if((ret = check_widget(((VisUITableEntry*)list_entry->data)->widget, name, info)))
          {
          return ret;
          }
        }
      break;
    case VISUAL_WIDGET_TYPE_NOTEBOOK:    /**< Notebook widget: \a VisUINotebook. */
      /* Get children */
      /* Get children */
      list_entry = NULL;
      while(visual_list_next(&VISUAL_UI_NOTEBOOK(w)->childs, &list_entry))
        {
        if((ret = check_widget(list_entry->data, name, info)))
          return ret;
        }
      break;
    case VISUAL_WIDGET_TYPE_SLIDER:      /**< Slider widget: \a VisUISlider. */
      if(strcmp(name, VISUAL_UI_MUTATOR(w)->param->name))
        return 0;
      if((VISUAL_UI_MUTATOR(w)->param->type == VISUAL_PARAM_ENTRY_TYPE_FLOAT) ||
         (VISUAL_UI_MUTATOR(w)->param->type == VISUAL_PARAM_ENTRY_TYPE_DOUBLE))
        {
        info->type = BG_PARAMETER_SLIDER_FLOAT;
        info->val_min.val_f = VISUAL_UI_RANGE(w)->min;
        info->val_max.val_f = VISUAL_UI_RANGE(w)->max;
        info->num_digits = VISUAL_UI_RANGE(w)->precision;
        if((VISUAL_UI_MUTATOR(w)->param->type == VISUAL_PARAM_ENTRY_TYPE_FLOAT))
          info->val_default.val_f = VISUAL_UI_MUTATOR(w)->param->numeric.floating;
        else
          info->val_default.val_f = VISUAL_UI_MUTATOR(w)->param->numeric.doubleflt;
        }
      else
        {
        info->type = BG_PARAMETER_SLIDER_INT;
        info->val_min.val_i = (int)VISUAL_UI_RANGE(w)->min;
        info->val_max.val_i = (int)VISUAL_UI_RANGE(w)->max;
        info->val_default.val_i = VISUAL_UI_MUTATOR(w)->param->numeric.integer;
        }
      info->flags |= BG_PARAMETER_SYNC;
      ret = w;
      break;
    case VISUAL_WIDGET_TYPE_NUMERIC:     /**< Numeric widget: \a VisUINumeric. */
      if(strcmp(name, VISUAL_UI_MUTATOR(w)->param->name))
        return 0;
      if((VISUAL_UI_MUTATOR(w)->param->type == VISUAL_PARAM_ENTRY_TYPE_FLOAT) ||
         (VISUAL_UI_MUTATOR(w)->param->type == VISUAL_PARAM_ENTRY_TYPE_DOUBLE))
        {
        info->type = BG_PARAMETER_FLOAT;
        info->val_min.val_f = VISUAL_UI_RANGE(w)->min;
        info->val_max.val_f = VISUAL_UI_RANGE(w)->max;
        info->num_digits = VISUAL_UI_RANGE(w)->precision;
        if((VISUAL_UI_MUTATOR(w)->param->type == VISUAL_PARAM_ENTRY_TYPE_FLOAT))
          info->val_default.val_f = VISUAL_UI_MUTATOR(w)->param->numeric.floating;
        else
          info->val_default.val_f = VISUAL_UI_MUTATOR(w)->param->numeric.doubleflt;
        }
      else
        {
        info->type = BG_PARAMETER_INT;
        info->val_min.val_i = (int)VISUAL_UI_RANGE(w)->min;
        info->val_max.val_i = (int)VISUAL_UI_RANGE(w)->max;
        info->val_default.val_i = VISUAL_UI_MUTATOR(w)->param->numeric.integer;
        }
      info->flags |= BG_PARAMETER_SYNC;
      ret = w;
      break;
    case VISUAL_WIDGET_TYPE_COLOR:       /**< Color widget: \a VisUIColor. */
    case VISUAL_WIDGET_TYPE_COLORBUTTON: /**< Color button widget: \a VisUIColorButton. */
      if(strcmp(name, VISUAL_UI_MUTATOR(w)->param->name))
        return 0;
      info->type = BG_PARAMETER_COLOR_RGB;
      info->flags |= BG_PARAMETER_SYNC;
      info->val_default.val_color[0] = (float)VISUAL_UI_MUTATOR(w)->param->color.r / 255.0;
      info->val_default.val_color[1] = (float)VISUAL_UI_MUTATOR(w)->param->color.g / 255.0;
      info->val_default.val_color[2] = (float)VISUAL_UI_MUTATOR(w)->param->color.b / 255.0;
      ret = w;
      break;
    case VISUAL_WIDGET_TYPE_POPUP:       /**< Popup widget: \a VisUIPopup. */
    case VISUAL_WIDGET_TYPE_LIST:        /**< List widget: \a VisUIList. */
    case VISUAL_WIDGET_TYPE_RADIO:       /**< Radio widget: \a VisUIRadio. */
      if(strcmp(name, VISUAL_UI_MUTATOR(w)->param->name))
        return 0;
      info->type = BG_PARAMETER_STRINGLIST;
      info->flags |= BG_PARAMETER_SYNC;
      num_items = 0;
      list_entry = NULL;
      while(visual_list_next(&VISUAL_UI_CHOICE(w)->choices.choices, &list_entry))
        num_items++;
      info->multi_names_nc = calloc(num_items+1, sizeof(info->multi_names_nc));
      list_entry = NULL;
      for(i = 0; i < num_items; i++)
        {
        visual_list_next(&VISUAL_UI_CHOICE(w)->choices.choices, &list_entry);
        info->multi_names_nc[i] = gavl_strdup(((VisUIChoiceEntry*)(list_entry->data))->name);

        /* Check if this is the current value */
        //        visual_param_entry_compare(((VisUIChoiceEntry*)(list_entry->data))->value,
        //                                       VISUAL_UI_MUTATOR(w)->param)
        if(!i)
          {
          info->val_default.val_str = gavl_strdup(info->multi_names_nc[i]);
          }
        }
      ret = w;
      break;
    case VISUAL_WIDGET_TYPE_CHECKBOX:     /**< Checkbox widget: \a VisUICheckbox. */
      if(strcmp(name, VISUAL_UI_MUTATOR(w)->param->name))
        return 0;
      info->type = BG_PARAMETER_CHECKBUTTON;
      info->flags |= BG_PARAMETER_SYNC;
      ret = w;
      break;
    }
  if(ret)
    info->help_string = gavl_strrep(info->help_string, w->tooltip);
  bg_parameter_info_set_const_ptrs(info);
  return ret;
  }
Exemplo n.º 19
0
static void set_parameter_lv(void * data, const char * name,
                             const bg_parameter_value_t * val)
  {
  int supported;
  lv_priv_t * priv;
  int index;
  int i_tmp;
  uint8_t r, g, b;
  char * tmp_string;
  VisParamEntry * param;
  VisListEntry * list_entry;

  VisColor * color;
  const bg_parameter_info_t * info;
  
  if(!name)
    return;
  priv = (lv_priv_t*)data;

  info = bg_parameter_find(priv->parameters, name);
  if(!info)
    return;

  /* This would crash if multi_parameters were supported */
  index = info - priv->parameters;

  tmp_string = gavl_strdup(name);
  param = visual_param_entry_new(tmp_string);
  free(tmp_string);
  /* Menus have to be treated specially */
  if(info->type == BG_PARAMETER_STRINGLIST)
    {
    if(!priv->widgets[index])
      return;
    /* Get the selected index */
    supported = 0;
    list_entry = NULL;
    while(visual_list_next(&VISUAL_UI_CHOICE(priv->widgets[index])->choices.choices,
                           &list_entry))
      {
      if(!strcmp(((VisUIChoiceEntry*)(list_entry->data))->name, val->val_str))
        {
        visual_param_entry_set_from_param(param,
                                          ((VisUIChoiceEntry*)(list_entry->data))->value);
        supported = 1;
        break;
        }
      }
    }
  else
    {
    supported = 1;
    switch(priv->params[index]->type)
      {
      case VISUAL_PARAM_ENTRY_TYPE_NULL:     /**< No parameter. */
        supported = 0;
        break;
      case VISUAL_PARAM_ENTRY_TYPE_STRING:   /**< String parameter. */
        if(val->val_str)
          visual_param_entry_set_string(param, val->val_str);
        else
          supported = 0;
        break;
      case VISUAL_PARAM_ENTRY_TYPE_INTEGER:  /**< Integer parameter. */
        visual_param_entry_set_integer(param, val->val_i);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_FLOAT:    /**< Floating point parameter. */
        visual_param_entry_set_float(param, val->val_f);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_DOUBLE:   /**< Double floating point parameter. */
        visual_param_entry_set_double(param, val->val_f);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_COLOR:    /**< VisColor parameter. */
        i_tmp = (int)(val->val_color[0] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        r = i_tmp;
        
        i_tmp = (int)(val->val_color[1] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        g = i_tmp;

        i_tmp = (int)(val->val_color[2] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        b = i_tmp;

        color = visual_color_new();
        visual_color_set(color, r, g, b);
        visual_param_entry_set_color_by_color(param, color);
        visual_object_unref(VISUAL_OBJECT(color));
        break;
      case VISUAL_PARAM_ENTRY_TYPE_PALETTE:  /**< VisPalette parameter. */
      case VISUAL_PARAM_ENTRY_TYPE_OBJECT:   /**< VisObject parameter. */
      case VISUAL_PARAM_ENTRY_TYPE_END:      /**< List end, and used as terminator for VisParamEntry lists. */
        supported = 0;
        break;
      }
    }
  if(supported)
    {
    visual_event_queue_add_param(visual_plugin_get_eventqueue(visual_actor_get_plugin(priv->actor)),
                              param);
    }
  else
    visual_object_unref(VISUAL_OBJECT(param));
  }
Exemplo n.º 20
0
int visual_ringbuffer_get_data_offset (VisRingBuffer *ringbuffer, VisBuffer *data, int offset, int nbytes)
{
    VisListEntry *le = NULL;
    VisRingBufferEntry *entry;
    int curposition = 0;
    int startat = 0;
    int buffercorr = 0;

    visual_return_val_if_fail (ringbuffer != NULL, -VISUAL_ERROR_RINGBUFFER_NULL);
    visual_return_val_if_fail (data != NULL, -VISUAL_ERROR_BUFFER_NULL);

    /* Fixate possible partial buffer */
    if (offset > 0)
        startat = fixate_with_partial_data_request (ringbuffer, data, offset, nbytes, &buffercorr);

    curposition = buffercorr;

    /* Buffer fixated with partial segment, request the other segments */
    while (curposition < nbytes) {
        int lindex = 0;
        le = NULL;

        /* return immediately if there are no elements in the list */
        if(visual_list_count(ringbuffer->entries) == 0)
            return VISUAL_OK;

        while ((entry = visual_list_next (ringbuffer->entries, &le)) != NULL) {
            VisBuffer *tempbuf = NULL;

            lindex++;

            /* Skip to the right offset buffer fragment */
            if (lindex <= startat)
                continue;

            if (entry->type == VISUAL_RINGBUFFER_ENTRY_TYPE_BUFFER) {

                tempbuf = entry->buffer;

            } else if (entry->type == VISUAL_RINGBUFFER_ENTRY_TYPE_FUNCTION) {

                /* Will bail out through visual_error_raise(), this is fatal, let's not try to
                 * recover, it's a very obvious bug in the software */
                if (entry->datafunc == NULL) {
                    visual_log (VISUAL_LOG_ERROR,
                                _("No VisRingBufferDataFunc data provider function set on "
                                  "type VISUAL_RINGBUFFER_ENTRY_TYPE_FUNCTION"));

                    return -VISUAL_ERROR_IMPOSSIBLE;
                }

                tempbuf = entry->datafunc (ringbuffer, entry);
            }

            if (curposition + visual_buffer_get_size (tempbuf) > nbytes) {
                VisBuffer *buf;

                buf = visual_buffer_new_wrap_data (visual_buffer_get_data (tempbuf), nbytes - curposition);
                visual_buffer_put (data, buf, curposition);
                visual_buffer_free (buf);

                if (entry->type == VISUAL_RINGBUFFER_ENTRY_TYPE_FUNCTION)
                    visual_buffer_unref (tempbuf);

                return VISUAL_OK;
            }

            visual_buffer_put (data, tempbuf, curposition);

            curposition += visual_buffer_get_size (tempbuf);

            if (entry->type == VISUAL_RINGBUFFER_ENTRY_TYPE_FUNCTION)
                visual_buffer_unref (tempbuf);

            /* Filled without room for partial buffer addition */
            if (curposition == nbytes)
                return VISUAL_OK;
        }

        startat = 0;
    }

    return VISUAL_OK;
}
Exemplo n.º 21
0
/* Internal functions */
int pipeline_from_preset (LVAVSPipelineContainer *container, LVAVSPresetContainer *presetcont)
{
    VisListEntry *le = NULL;
    LVAVSPresetElement *pelem;
    LVAVSPipelineElement *element;
    LVAVSPipelineContainer *cont;
    VisPluginRef *ref;
    LVAVSPipeline *pipeline = LVAVS_PIPELINE_ELEMENT(container)->pipeline; 

    while ((pelem = visual_list_next (presetcont->members, &le)) != NULL) {

        switch (pelem->type) {
            case LVAVS_PRESET_ELEMENT_TYPE_PLUGIN:
                ref = visual_plugin_find (visual_plugin_get_registry (), pelem->element_name);

                if (ref == NULL) {
                    visual_log (VISUAL_LOG_CRITICAL, "Requested plugin %s not in registry", pelem->element_name);

                    break;
                }

                if (ref->info == NULL) {
                    visual_log (VISUAL_LOG_CRITICAL, "Could not get VisPluginInfo for %s", pelem->element_name);

                    break;
                }

                /* FIXME fix libvisual type lookup and use the functions here */
                if (strcmp (ref->info->type, VISUAL_PLUGIN_TYPE_ACTOR) == 0) {

                    element = lvavs_pipeline_element_new (LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR);
                    element->data.actor = visual_actor_new (pelem->element_name);
                    visual_object_set_private(VISUAL_OBJECT(element->data.actor->plugin), pipeline);

                } else if (strcmp (ref->info->type, VISUAL_PLUGIN_TYPE_MORPH) == 0) {

                    element = lvavs_pipeline_element_new (LVAVS_PIPELINE_ELEMENT_TYPE_MORPH);
                    element->data.morph = visual_morph_new (pelem->element_name);
                    visual_object_set_private(VISUAL_OBJECT(element->data.morph->plugin), pipeline);

                } else if (strcmp (ref->info->type, VISUAL_PLUGIN_TYPE_TRANSFORM) == 0) {

                    element = lvavs_pipeline_element_new (LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM);
                    element->data.transform = visual_transform_new (pelem->element_name);
                    visual_object_set_private(VISUAL_OBJECT(element->data.transform->plugin), pipeline);

                } else {
                    printf("uknown type '%s' '%s'\n", ref->info->type, ref->info->name);
                }

                if (pelem->pcont != NULL) {
                    element->params = visual_param_container_new ();
                    visual_param_container_copy (element->params, pelem->pcont);
                }

                element->pipeline = LVAVS_PIPELINE_ELEMENT (container)->pipeline;

                visual_list_add (container->members, element);

                break;

            case LVAVS_PRESET_ELEMENT_TYPE_CONTAINER:
                cont = lvavs_pipeline_container_new ();

        LVAVS_PIPELINE_ELEMENT(cont)->params = LVAVS_PIPELINE_ELEMENT(container)->params;
        LVAVS_PIPELINE_ELEMENT(cont)->pipeline = LVAVS_PIPELINE_ELEMENT(container)->pipeline;

                visual_list_add (container->members, cont);

                pipeline_from_preset (cont, LVAVS_PRESET_CONTAINER (pelem));
                break;

            case LVAVS_PRESET_ELEMENT_TYPE_RENDERSTATE:

                break;

            case LVAVS_PRESET_ELEMENT_TYPE_COMMENT:

                break;

            case LVAVS_PRESET_ELEMENT_TYPE_BPM:

                break;

            case LVAVS_PRESET_ELEMENT_TYPE_STACK:

                break;
            
            default:
                visual_log (VISUAL_LOG_CRITICAL, "Invalid LVAVSPresetElementType in LVAVSPresetElement");

                break;
        }
    }

    return VISUAL_OK;
}
Exemplo n.º 22
0
static int fixate_with_partial_data_request (VisRingBuffer *ringbuffer, VisBuffer *data, int offset, int nbytes,
        int *buffercorr)
{
    VisListEntry *le = NULL;
    VisRingBufferEntry *entry;
    int curoffset = 0;
    int startat = 0;

    *buffercorr = 0;

    while ((entry = visual_list_next (ringbuffer->entries, &le)) != NULL) {
        int bsize = 0;

        startat++;

        if (entry->type == VISUAL_RINGBUFFER_ENTRY_TYPE_BUFFER) {

            if ((bsize = visual_buffer_get_size (entry->buffer)) > 0)
                curoffset += bsize;

            /* This buffer partially falls within the offset */
            if (curoffset > offset) {
                visual_buffer_put_data (data,
                                        ((uint8_t *) visual_buffer_get_data (entry->buffer) +
                                         visual_buffer_get_size (entry->buffer)) -
                                        (curoffset - offset), curoffset - offset, 0);

                *buffercorr = curoffset - offset;

                break;
            }
        } else if (entry->type == VISUAL_RINGBUFFER_ENTRY_TYPE_FUNCTION) {

            if (entry->sizefunc != NULL) {
                curoffset += entry->sizefunc (ringbuffer, entry);

                /* This buffer partially falls within the offset */
                if (curoffset > offset) {

                    VisBuffer *tempbuf = entry->datafunc (ringbuffer, entry);

                    visual_buffer_put_data (data,
                                            ((uint8_t *) visual_buffer_get_data (tempbuf) +
                                             visual_buffer_get_size (tempbuf)) -
                                            (curoffset - offset), curoffset - offset, 0);

                    visual_buffer_unref (tempbuf);

                    *buffercorr = curoffset - offset;

                    break;
                }
            } else {
                VisBuffer *tempbuf = entry->datafunc (ringbuffer, entry);

                if ((bsize = visual_buffer_get_size (tempbuf)) > 0)
                    curoffset += bsize;

                /* This buffer partially falls within the offset */
                if (curoffset > offset) {
                    visual_buffer_put_data (data,
                                            ((uint8_t *) visual_buffer_get_data (tempbuf) +
                                             visual_buffer_get_size (tempbuf)) -
                                            (curoffset - offset), curoffset - offset, 0);

                    *buffercorr = curoffset - offset;

                    break;
                }

                visual_buffer_unref (tempbuf);
            }
        }
    }

    return startat;
}
Exemplo n.º 23
0
char *avs_serialize_container_deserialize (AVSSerializeContainer *scont, char *section)
{
	AVSSerializeEntry *sentry;
	VisListEntry *le = NULL;

	while ((sentry = visual_list_next (&scont->layout, &le)) != NULL) {
		switch (sentry->type) {
			case AVS_SERIALIZE_ENTRY_TYPE_BYTE:
				if (sentry->param != NULL) {
					visual_param_entry_set_integer (sentry->param, AVS_SERIALIZE_GET_BYTE (section));

					if (visual_param_entry_get_integer (sentry->param) > sentry->boundry && sentry->boundry > 0) {
						visual_log (VISUAL_LOG_WARNING, "A serialized entry did hit the upper value boundry");

						visual_param_entry_set_integer (sentry->param, 0);
					}
				}

				AVS_SERIALIZE_SKIP_BYTE (section);

				break;

			case AVS_SERIALIZE_ENTRY_TYPE_BYTE_WITH_INT_SKIP:
				if (sentry->param != NULL) {
					visual_param_entry_set_integer (sentry->param, AVS_SERIALIZE_GET_BYTE (section));

					if (visual_param_entry_get_integer (sentry->param) > sentry->boundry && sentry->boundry > 0) {
						visual_log (VISUAL_LOG_WARNING, "A serialized entry did hit the upper value boundry");

						visual_param_entry_set_integer (sentry->param, 0);
					}
				}

				AVS_SERIALIZE_SKIP_INT (section);

				break;

			case AVS_SERIALIZE_ENTRY_TYPE_INT:
				if (sentry->param != NULL) {
					// use get_int here... instead of get_byte
					visual_param_entry_set_integer (sentry->param, AVS_SERIALIZE_GET_BYTE (section));

					if (visual_param_entry_get_integer (sentry->param) > sentry->boundry && sentry->boundry > 0) {
						visual_log (VISUAL_LOG_WARNING, "A serialized entry did hit the upper value boundry");

						visual_param_entry_set_integer (sentry->param, 0);
					}
				}

				AVS_SERIALIZE_SKIP_INT (section);

				break;

			case AVS_SERIALIZE_ENTRY_TYPE_STRING:

				section = avs_serialize_retrieve_string_from_preset_section (section, sentry->param);

				break;

			case AVS_SERIALIZE_ENTRY_TYPE_COLOR:

				section = avs_serialize_retrieve_color_from_preset_section (section, sentry->param);

				break;

			case AVS_SERIALIZE_ENTRY_TYPE_PALETTE:

				section = avs_serialize_retrieve_palette_from_preset_section (section, sentry->param);

				break;

			default:
				printf ("INVALID SERIALIZE TYPE, BAILING OUT VERY HARDLY\n");
				return NULL;

				break;

		}

	}

	return section;
}
Exemplo n.º 24
0
static bg_parameter_info_t *
create_parameters(VisActor * actor, VisUIWidget *** widgets,
                  VisParamEntry *** params_ret)
  {
  int num_parameters, i, index, supported;
  bg_parameter_info_t * ret;
  VisParamContainer * params;
  //  VisHashmapChainEntry *entry;
  VisParamEntry *param_entry;
  VisListEntry * list_entry;
  VisUIWidget * widget;
  VisUIWidget * param_widget;
  
  params = visual_plugin_get_params(visual_actor_get_plugin(actor));
  
  /* Count parameters */
  num_parameters = 0;
  
  list_entry = NULL;

  while(visual_list_next(&params->entries,
                         &list_entry))
    num_parameters++;

  if(!num_parameters)
    return NULL;
  /* Create parameters */
  ret = calloc(num_parameters+1, sizeof(*ret));

  if(widgets)
    *widgets = calloc(num_parameters, sizeof(**widgets));

  if(params_ret)
    *params_ret = calloc(num_parameters, sizeof(**params_ret));
  
  list_entry = NULL;
  index = 0;

  widget = visual_plugin_get_userinterface(visual_actor_get_plugin(actor));
  
  for(i = 0; i < num_parameters; i++)
    {
    visual_list_next(&params->entries, &list_entry);
    param_entry = list_entry->data;
    //    param_entry = VISUAL_PARAMENTRY(entry->data);
    
    if(params_ret)
      (*params_ret)[index] = param_entry;
    
    supported = 1;
    
    if(widget)
      param_widget = check_widget(widget, param_entry->name, &ret[index]);
    else
      param_widget = NULL;
    
    if(!param_widget)
      {
      switch(param_entry->type)
        {
        case VISUAL_PARAM_ENTRY_TYPE_NULL:     /**< No parameter. */
          supported = 0;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_STRING:   /**< String parameter. */
          ret[index].type = BG_PARAMETER_STRING;
          ret[index].val_default.val_str =
            gavl_strrep(ret[index].val_default.val_str,
                      param_entry->string);
          break;
        case VISUAL_PARAM_ENTRY_TYPE_INTEGER:  /**< Integer parameter. */
          ret[index].type = BG_PARAMETER_INT;
          ret[index].flags |= BG_PARAMETER_SYNC;
          ret[index].val_default.val_i = param_entry->numeric.integer;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_FLOAT:    /**< Floating point parameter. */
          ret[index].type = BG_PARAMETER_FLOAT;
          ret[index].flags |= BG_PARAMETER_SYNC;
          ret[index].val_default.val_f = param_entry->numeric.floating;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_DOUBLE:   /**< Double floating point parameter. */
          ret[index].type = BG_PARAMETER_FLOAT;
          ret[index].flags |= BG_PARAMETER_SYNC;
          ret[index].val_default.val_f = param_entry->numeric.doubleflt;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_COLOR:    /**< VisColor parameter. */
          ret[index].type = BG_PARAMETER_COLOR_RGB;
          ret[index].flags |= BG_PARAMETER_SYNC;
          ret[index].val_default.val_color[0] = (float)param_entry->color.r / 255.0;
          ret[index].val_default.val_color[1] = (float)param_entry->color.g / 255.0;
          ret[index].val_default.val_color[2] = (float)param_entry->color.b / 255.0;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_PALETTE:  /**< VisPalette parameter. */
        case VISUAL_PARAM_ENTRY_TYPE_OBJECT:   /**< VisObject parameter. */
        case VISUAL_PARAM_ENTRY_TYPE_END:      /**< List end, and used as terminator for VisParamEntry lists. */
          supported = 0;
          break;
        }
      }
    
    if(widgets)
      (*widgets)[index] = param_widget;
    
    if(!supported)
      continue;
    
    ret[index].name = gavl_strdup(param_entry->name);
    ret[index].long_name = gavl_strdup(param_entry->name);
    index++;
    }
  return ret;
  }