Esempio n. 1
0
int visual_collection_iter_init (VisCollectionIter *iter,
		VisCollectionIterAssignFunc assignfunc, VisCollectionIterNextFunc nextfunc,
		VisCollectionIterHasMoreFunc hasmorefunc, VisCollectionIterGetDataFunc getdatafunc,
		VisCollection *collection, VisObject *context)
{
	visual_log_return_val_if_fail (iter != NULL, -VISUAL_ERROR_COLLECTION_ITER_NULL);

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (iter));
	visual_object_set_dtor (VISUAL_OBJECT (iter), NULL);
	visual_object_set_allocated (VISUAL_OBJECT (iter), FALSE);

	/* Set the VisCollectionIter data */
	iter->assignfunc = assignfunc;
	iter->nextfunc = nextfunc;
	iter->hasmorefunc = hasmorefunc;
	iter->getdatafunc = getdatafunc;
	iter->collection = collection;
	iter->context = context;

	if (iter->collection != NULL)
		visual_object_ref (VISUAL_OBJECT (iter->collection));

	return VISUAL_OK;
}
Esempio n. 2
0
int visual_hashlist_init (VisHashlist *hashlist, VisCollectionDestroyerFunc destroyer, int size)
{
	visual_return_val_if_fail (hashlist != NULL, -VISUAL_ERROR_HASHLIST_NULL);

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (hashlist));
	visual_object_set_dtor (VISUAL_OBJECT (hashlist), visual_collection_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (hashlist), FALSE);

	/* Set the VisCollection data */
	visual_collection_set_destroyer (VISUAL_COLLECTION (hashlist), destroyer);
	visual_collection_set_destroy_func (VISUAL_COLLECTION (hashlist), hashlist_destroy);
	visual_collection_set_size_func (VISUAL_COLLECTION (hashlist), hashlist_size);
	visual_collection_set_iter_func (VISUAL_COLLECTION (hashlist), hashlist_iter);

	/* Set the VisHashlist data */
	visual_hashlist_set_size (hashlist, size);

	hashlist->list = visual_list_new (NULL);

	hashlist->index = visual_hashmap_new (NULL); /* FIXME create in set_limits, rehash if not NULL */
	visual_hashmap_set_table_size (hashlist->index, size); /* <- also */

	return VISUAL_OK;
}
int visual_transform_init (VisTransform *transform, const char *transformname)
{
    visual_return_val_if_fail (transform != NULL, -VISUAL_ERROR_TRANSFORM_NULL);

    if (transformname && !LV::transform_plugin_get_list ().empty ()) {
        visual_log (VISUAL_LOG_ERROR, _("the plugin list is NULL"));
        return -VISUAL_ERROR_PLUGIN_NO_LIST;
    }

    /* Do the VisObject initialization */
    visual_object_clear (VISUAL_OBJECT (transform));
    visual_object_set_dtor (VISUAL_OBJECT (transform), transform_dtor);
    visual_object_set_allocated (VISUAL_OBJECT (transform), FALSE);

    /* Reset the VisTransform data */
    transform->plugin = NULL;
    transform->video = NULL;
    transform->pal = NULL;

    if (transformname == NULL)
        return VISUAL_OK;

    if (!LV::PluginRegistry::instance()->has_plugin (VISUAL_PLUGIN_TYPE_TRANSFORM, transformname)) {
        return -VISUAL_ERROR_PLUGIN_NOT_FOUND;
    }

    transform->plugin = visual_plugin_load (VISUAL_PLUGIN_TYPE_TRANSFORM, transformname);

    return VISUAL_OK;
}
Esempio n. 4
0
/**
 * Initializes a VisTransform, this will set the allocated flag for the object to FALSE. Should not
 * be used to reset a VisTransform, or on a VisTransform created by visual_transform_new().
 *
 * @see visual_transform_new
 *
 * @param transform Pointer to the VisTransform that is initialized.
 * @param transformname
 *	The name of the plugin to load, or NULL to simply initialize a new transform.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_TRANSFORM_NULL or -VISUAL_ERROR_PLUGIN_NO_LIST on failure.
 */
int visual_transform_init (VisTransform *transform, const char *transformname)
{
	VisPluginRef *ref;

	visual_log_return_val_if_fail (transform != NULL, -VISUAL_ERROR_TRANSFORM_NULL);

	if (__lv_plugins_transform == NULL && transformname != NULL) {
		visual_log (VISUAL_LOG_CRITICAL, _("the plugin list is NULL"));
		return -VISUAL_ERROR_PLUGIN_NO_LIST;
	}

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (transform));
	visual_object_set_dtor (VISUAL_OBJECT (transform), transform_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (transform), FALSE);

	/* Reset the VisTransform data */
	transform->plugin = NULL;
	transform->video = NULL;
	transform->pal = NULL;

	if (transformname == NULL)
		return VISUAL_OK;

	ref = visual_plugin_find (__lv_plugins_transform, transformname);

	transform->plugin = visual_plugin_load (ref);

	return VISUAL_OK;
}
Esempio n. 5
0
int visual_video_init (VisVideo *video)
{
	visual_return_val_if_fail (video != NULL, -VISUAL_ERROR_VIDEO_NULL);

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (video));
	visual_object_set_dtor (VISUAL_OBJECT (video), video_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (video), FALSE);

	/* Reset the VisVideo data */
	video->buffer = visual_buffer_new ();

	video->pixel_rows = NULL;

	visual_video_set_attributes (video, 0, 0, 0, VISUAL_VIDEO_DEPTH_NONE);
	visual_video_set_buffer (video, NULL);
	visual_video_set_palette (video, NULL);

	video->parent = NULL;
	video->rect = visual_rectangle_new_empty ();

	/* Composite control */
	video->compositetype = VISUAL_VIDEO_COMPOSITE_TYPE_SRC;

	/* Colors */
	video->colorkey = visual_color_new ();

	return VISUAL_OK;
}
Esempio n. 6
0
int visual_random_context_init (VisRandomContext *rcontext, uint32_t seed)
{
	visual_return_val_if_fail (rcontext != NULL, -VISUAL_ERROR_RANDOM_CONTEXT_NULL);

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (rcontext));
	visual_object_set_dtor (VISUAL_OBJECT (rcontext), NULL);
	visual_object_set_allocated (VISUAL_OBJECT (rcontext), FALSE);

	/* Set the VisRandomContext data */
	visual_random_context_set_seed (rcontext, seed);

	return VISUAL_OK;
}
Esempio n. 7
0
int visual_audio_samplepool_init (VisAudioSamplePool *samplepool)
{
	visual_return_val_if_fail (samplepool != NULL, -VISUAL_ERROR_AUDIO_SAMPLEPOOL_NULL);

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (samplepool));
	visual_object_set_dtor (VISUAL_OBJECT (samplepool), audio_samplepool_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (samplepool), FALSE);

	/* Reset the VisAudioSamplePool structure */
	samplepool->channels = visual_list_new (visual_object_collection_destroyer);

	return VISUAL_OK;
}
Esempio n. 8
0
int visual_audio_init (VisAudio *audio)
{
	visual_return_val_if_fail (audio != NULL, -VISUAL_ERROR_AUDIO_NULL);

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (audio));
	visual_object_set_dtor (VISUAL_OBJECT (audio), audio_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (audio), FALSE);

	/* Reset the VisAudio data */
	audio->samplepool = visual_audio_samplepool_new ();

	return VISUAL_OK;
}
Esempio n. 9
0
int visual_ringbuffer_init (VisRingBuffer *ringbuffer)
{
    visual_return_val_if_fail (ringbuffer != NULL, -VISUAL_ERROR_RINGBUFFER_NULL);

    /* Do the VisObject initialization */
    visual_object_clear (VISUAL_OBJECT (ringbuffer));
    visual_object_set_dtor (VISUAL_OBJECT (ringbuffer), ringbuffer_dtor);
    visual_object_set_allocated (VISUAL_OBJECT (ringbuffer), FALSE);

    /* Reset the VisRingBuffer structure */
    ringbuffer->entries = visual_list_new (visual_object_collection_destroyer);

    return VISUAL_OK;
}
Esempio n. 10
0
/**
 * Initializes a VisPalette, this should not be used to reset a VisPalette.
 * The resulting initialized VisPalette is a valid VisObject even if it was not allocated.
 * Keep in mind that VisPalette structures that were created by visual_palette_new() should not
 * be passed to visual_palette_init().
 *
 * @see visual_palette_new
 *
 * @param pal Pointer to the VisPalette which needs to be initialized.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_PALETTE_NULL on failure.
 */
int visual_palette_init (VisPalette *pal)
{
	visual_log_return_val_if_fail (pal != NULL, -VISUAL_ERROR_PALETTE_NULL);

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (pal));
	visual_object_set_dtor (VISUAL_OBJECT (pal), palette_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (pal), FALSE);

	/* Reset the VisPalette data */
	pal->ncolors = 0;
	pal->colors = NULL;

	return VISUAL_OK;
}
Esempio n. 11
0
/**
 * Initializes a VisActor, this will set the allocated flag for the object to FALSE. Should not
 * be used to reset a VisActor, or on a VisActor created by visual_actor_new().
 *
 * @see visual_actor_new
 *
 * @param actor Pointer to the VisActor that is initialized.
 * @param actorname
 *	The name of the plugin to load, or NULL to simply initialize a new actor.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_ACTOR_NULL or -VISUAL_ERROR_PLUGIN_NO_LIST on failure.
 */
int visual_actor_init (VisActor *actor, const char *actorname)
{
	VisPluginRef *ref;
	VisPluginEnviron *enve;
	VisActorPluginEnviron *actenviron;

	visual_log_return_val_if_fail (actor != NULL, -VISUAL_ERROR_ACTOR_NULL);

	if (__lv_plugins_actor == NULL && actorname != NULL) {
		visual_log (VISUAL_LOG_CRITICAL, _("the plugin list is NULL"));

		return -VISUAL_ERROR_PLUGIN_NO_LIST;
	}

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (actor));
	visual_object_set_dtor (VISUAL_OBJECT (actor), actor_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (actor), FALSE);

	/* Reset the VisActor data */
	actor->plugin = NULL;
	actor->video = NULL;
	actor->transform = NULL;
	actor->fitting = NULL;
	actor->ditherpal = NULL;

	visual_mem_set (&actor->songcompare, 0, sizeof (VisSongInfo));

	if (actorname == NULL)
		return VISUAL_OK;

	ref = visual_plugin_find (__lv_plugins_actor, actorname);

	actor->plugin = visual_plugin_load (ref);

	/* Adding the VisActorPluginEnviron */
	actenviron = visual_mem_new0 (VisActorPluginEnviron, 1);

	visual_object_initialize (VISUAL_OBJECT (actenviron), TRUE, NULL);

	enve = visual_plugin_environ_new (VISUAL_ACTOR_PLUGIN_ENVIRON, VISUAL_OBJECT (actenviron));
	visual_plugin_environ_add (actor->plugin, enve);

	return VISUAL_OK;
}
Esempio n. 12
0
int visual_audio_samplepool_channel_init (VisAudioSamplePoolChannel *channel, const char *channelid)
{
	visual_return_val_if_fail (channel != NULL, -VISUAL_ERROR_AUDIO_SAMPLEPOOL_CHANNEL_NULL);

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (channel));
	visual_object_set_dtor (VISUAL_OBJECT (channel), audio_samplepool_channel_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (channel), FALSE);

	/* Reset the VisAudioSamplePoolChannel data */
	channel->samples = visual_ringbuffer_new ();

	visual_time_set (&channel->samples_timeout, 1, 0); /* FIXME not safe against time screws */
	channel->channelid = visual_strdup (channelid);
	channel->factor = 1.0;

	return VISUAL_OK;
}
Esempio n. 13
0
int visual_ringbuffer_entry_init (VisRingBufferEntry *entry, VisBuffer *buffer)
{
    visual_return_val_if_fail (entry != NULL, -VISUAL_ERROR_RINGBUFFER_ENTRY_NULL);

    /* Do the VisObject initialization */
    visual_object_clear (VISUAL_OBJECT (entry));
    visual_object_set_dtor (VISUAL_OBJECT (entry), ringbuffer_entry_dtor);
    visual_object_set_allocated (VISUAL_OBJECT (entry), FALSE);

    /* Reset the VisRingBufferEntry data */
    entry->type = VISUAL_RINGBUFFER_ENTRY_TYPE_BUFFER;
    entry->datafunc = NULL;
    entry->destroyfunc = NULL;
    entry->sizefunc = NULL;
    entry->buffer = buffer;
    entry->functiondata = NULL;

    return VISUAL_OK;
}
Esempio n. 14
0
int visual_audio_sample_init (VisAudioSample *sample, VisBuffer *buffer, VisTime *timestamp,
		VisAudioSampleFormatType format,
		VisAudioSampleRateType rate)
{
	visual_return_val_if_fail (sample != NULL, -VISUAL_ERROR_AUDIO_SAMPLE_NULL);

	/* Do the VisObject initialization */
	visual_object_clear (VISUAL_OBJECT (sample));
	visual_object_set_dtor (VISUAL_OBJECT (sample), audio_sample_dtor);
	visual_object_set_allocated (VISUAL_OBJECT (sample), FALSE);

	/* Reset the VisAudioSamplePool structure */
	visual_time_copy (&sample->timestamp, timestamp);
	sample->rate = rate;
	sample->format = format;
	sample->buffer = buffer;
	sample->processed = NULL;

	return VISUAL_OK;
}
Esempio n. 15
0
int visual_morph_init (VisMorph *morph, const char *morphname)
{
    visual_return_val_if_fail (morph != NULL, -VISUAL_ERROR_MORPH_NULL);

    if (morphname && get_morph_plugin_list ().empty ()) {
        visual_log (VISUAL_LOG_ERROR, _("the plugin list is NULL"));

        return -VISUAL_ERROR_PLUGIN_NO_LIST;
    }

    /* Do the VisObject initialization */
    visual_object_clear (VISUAL_OBJECT (morph));
    visual_object_set_dtor (VISUAL_OBJECT (morph), morph_dtor);
    visual_object_set_allocated (VISUAL_OBJECT (morph), FALSE);

    /* Reset the VisMorph data */
    morph->plugin = NULL;
    morph->dest = NULL;
    morph->morphpal = visual_palette_new (256);
    morph->morphtime = visual_time_new ();
    morph->timer = visual_timer_new ();
    visual_morph_set_rate (morph, 0);
    visual_morph_set_steps (morph, 0);
    morph->stepsdone = 0;

    visual_morph_set_mode (morph, VISUAL_MORPH_MODE_SET);

    if (morphname == NULL)
        return VISUAL_OK;

    if (!LV::PluginRegistry::instance()->has_plugin (VISUAL_PLUGIN_TYPE_MORPH, morphname)) {
        return -VISUAL_ERROR_PLUGIN_NOT_FOUND;
    }

    morph->plugin = visual_plugin_load (VISUAL_PLUGIN_TYPE_MORPH, morphname);

    return VISUAL_OK;
}
Esempio n. 16
0
int visual_ringbuffer_entry_init_function (VisRingBufferEntry *entry,
        VisRingBufferDataFunc datafunc,
        VisRingBufferDestroyFunc destroyfunc,
        VisRingBufferSizeFunc sizefunc,
        void *functiondata)
{
    visual_return_val_if_fail (entry != NULL, -VISUAL_ERROR_RINGBUFFER_ENTRY_NULL);

    /* Do the VisObject initialization */
    visual_object_clear (VISUAL_OBJECT (entry));
    visual_object_set_dtor (VISUAL_OBJECT (entry), ringbuffer_entry_dtor);
    visual_object_set_allocated (VISUAL_OBJECT (entry), FALSE);

    /* Reset the VisRingBufferEntry data */
    entry->type = VISUAL_RINGBUFFER_ENTRY_TYPE_FUNCTION;
    entry->datafunc = datafunc;
    entry->destroyfunc = destroyfunc;
    entry->sizefunc = sizefunc;
    entry->buffer = NULL;
    entry->functiondata = functiondata;

    return VISUAL_OK;
}