int visual_audio_sample_buffer_mix_many (VisBuffer *dest, int divide, int channels, ...) { VisBuffer **buffers; double *chanmuls; va_list ap; int i; visual_return_val_if_fail (dest != NULL, -VISUAL_ERROR_BUFFER_NULL); buffers = visual_mem_malloc (channels * sizeof (VisBuffer *)); chanmuls = visual_mem_malloc (channels * sizeof (double)); va_start (ap, channels); /* Retrieving mixing data from valist */ for (i = 0; i < channels; i++) buffers[i] = va_arg (ap, VisBuffer *); for (i = 0; i < channels; i++) chanmuls[i] = va_arg (ap, double); visual_buffer_fill (dest, 0); visual_audio_sample_buffer_mix (dest, buffers[0], FALSE, chanmuls[0]); /* The mixing loop */ for (i = 1; i < channels; i++) visual_audio_sample_buffer_mix (dest, buffers[0], divide, chanmuls[i]); va_end (ap); visual_mem_free (buffers); visual_mem_free (chanmuls); return VISUAL_OK; }
/** * Sets the VisParamEntry to VISUAL_PARAM_ENTRY_TYPE_STRING and assigns the string given as argument to it. * * @param param Pointer to the VisParamEntry to which a parameter is set. * @param string The string for this parameter. * * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_NULL on failure. */ int visual_param_entry_set_string (VisParamEntry *param, char *string) { visual_log_return_val_if_fail (param != NULL, -VISUAL_ERROR_PARAM_NULL); param->type = VISUAL_PARAM_ENTRY_TYPE_STRING; if (string == NULL && param->string == NULL) return VISUAL_OK; if (string == NULL && param->string != NULL) { visual_mem_free (param->string); param->string = NULL; visual_param_entry_changed (param); } else if (param->string == NULL && string != NULL) { param->string = strdup (string); visual_param_entry_changed (param); } else if (strcmp (string, param->string) != 0) { visual_mem_free (param->string); param->string = strdup (string); visual_param_entry_changed (param); } return VISUAL_OK; }
static int param_entry_dtor (VisObject *object) { VisParamEntry *param = VISUAL_PARAMENTRY (object); if (param->string != NULL) visual_mem_free (param->string); if (param->name != NULL) visual_mem_free (param->name); if (param->objdata != NULL) visual_object_unref (param->objdata); if (param->annotation != NULL) visual_mem_free (param->annotation); visual_palette_free_colors (¶m->pal); visual_collection_destroy (VISUAL_COLLECTION (¶m->callbacks)); param->string = NULL; param->name = NULL; param->objdata = NULL; param->annotation = NULL; return VISUAL_OK; }
extern "C" int lv_projectm_cleanup (VisPluginData *plugin) { ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin)); /* Cleanup, and thus also free our private */ visual_mem_free (priv->PM); visual_mem_free (priv); return 0; }
int visual_audio_get_sample_mixed (VisAudio *audio, VisBuffer *buffer, int divide, int channels, ...) { VisBuffer temp; char **chanids; double *chanmuls; va_list ap; int i; int first = TRUE; visual_return_val_if_fail (audio != NULL, -VISUAL_ERROR_AUDIO_NULL); visual_return_val_if_fail (buffer != NULL, -VISUAL_ERROR_BUFFER_NULL); visual_buffer_init_allocate (&temp, visual_buffer_get_size (buffer), visual_buffer_destroyer_free); chanids = visual_mem_malloc (channels * sizeof (char *)); chanmuls = visual_mem_malloc (channels * sizeof (double)); va_start (ap, channels); /* Retrieving mixing data from valist */ for (i = 0; i < channels; i++) chanids[i] = va_arg (ap, char *); for (i = 0; i < channels; i++) chanmuls[i] = va_arg (ap, double); visual_buffer_fill (buffer, 0); /* The mixing loop */ for (i = 0; i < channels; i++) { if (visual_audio_get_sample (audio, &temp, chanids[i]) == VISUAL_OK) { if (first == TRUE) { visual_audio_sample_buffer_mix (buffer, &temp, FALSE, chanmuls[i]); first = FALSE; } else { visual_audio_sample_buffer_mix (buffer, &temp, divide, chanmuls[i]); } } } va_end (ap); visual_object_unref (VISUAL_OBJECT (&temp)); visual_mem_free (chanids); visual_mem_free (chanmuls); return VISUAL_OK; }
static int lv_nebulus_cleanup (VisPluginData *plugin) { NebulusPrivate *priv = visual_object_get_private (VISUAL_OBJECT (plugin)); visual_return_val_if_fail (plugin != NULL, -1); if (!face_first) glDeleteLists(facedl, 1); if (!tentacles_first) glDeleteLists(cubedl, 1); if (!child_first) glDeleteLists(childdl, 1); delete_gl_texture(knotbg); delete_gl_texture(tunnel); delete_gl_texture(tentacle); delete_gl_texture(twist); delete_gl_texture(twistbg); delete_gl_texture(texchild); delete_gl_texture(childbg); delete_gl_texture(energy); visual_object_unref (VISUAL_OBJECT (&child_image)); visual_object_unref (VISUAL_OBJECT (&energy_image)); visual_object_unref (VISUAL_OBJECT (&tentacle_image)); visual_object_unref (VISUAL_OBJECT (&tunnel_image)); visual_object_unref (VISUAL_OBJECT (&twist_image)); visual_object_unref (VISUAL_OBJECT (&background_image)); visual_buffer_free (priv->pcmbuf); visual_mem_free (priv); return 0; }
char *avs_serialize_retrieve_string_from_preset_section (char *section, VisParamEntry *param) { char *string; int len; int i; /* FIXME should just get an int ? */ len = AVS_SERIALIZE_GET_INT (section); AVS_SERIALIZE_SKIP_INT (section); if (len > 0) { string = visual_mem_malloc0 (len); strncpy (string, section, len); visual_param_entry_set_string (param, string); visual_mem_free (string); } AVS_SERIALIZE_SKIP_LENGTH (section, len); printf("after length skip :%s\n", section); return section; }
static int act_gdkpixbuf_load_file (PixbufPrivate *priv, const char *filename) { visual_log (VISUAL_LOG_INFO, "Loading image from '%s'", filename); if (priv->source) { g_object_unref (priv->source); priv->source = NULL; } if (priv->target) { visual_video_unref (priv->target); priv->target = NULL; } visual_mem_free (priv->filename); priv->filename = visual_strdup (filename); priv->source = gdk_pixbuf_new_from_file (filename, NULL); if (!priv->source) { visual_log (VISUAL_LOG_ERROR, "Failed to load image from file '%s'", filename); return FALSE; } act_gdkpixbuf_update_image (priv); return TRUE; }
int visual_video_set_buffer (VisVideo *video, void *buffer) { visual_return_val_if_fail (video != NULL, -VISUAL_ERROR_VIDEO_NULL); if (visual_buffer_get_allocated (video->buffer)) { visual_log (VISUAL_LOG_ERROR, _("Trying to set a screen buffer on " "a VisVideo structure which points to an allocated screen buffer")); return -VISUAL_ERROR_VIDEO_HAS_ALLOCATED; } visual_buffer_set_data (video->buffer, buffer); visual_buffer_set_destroyer (video->buffer, NULL); if (video->pixel_rows != NULL) { visual_mem_free (video->pixel_rows); video->pixel_rows = NULL; } if (visual_buffer_get_data (video->buffer) != NULL) { video->pixel_rows = visual_mem_new0 (void *, video->height); precompute_row_table (video); }
/** * cleanup plugin (release resources) * * @param plugin plugin to be cleaned up. * * @return 0 on success. */ static int inp_mplayer_cleanup( VisPluginData *plugin ) { int unclean = 0; mplayer_priv_t *priv = NULL; visual_return_val_if_fail( plugin != NULL, -1 ); priv = visual_object_get_private (VISUAL_OBJECT (plugin)); visual_return_val_if_fail( priv != NULL, -1 ); if ( priv->loaded == 1 ) { void *mmap_area = (void*)priv->mmap_area; int mmap_count = priv->mmap_area->bs + sizeof( mplayer_data_t ); if ( priv->fd > 0 ) { if ( close( priv->fd ) != 0 ) { visual_log( VISUAL_LOG_CRITICAL, _("Could not close file descriptor %d: %s"), priv->fd, strerror( errno ) ); unclean |= 1; } priv->fd = -1; } else { visual_log( VISUAL_LOG_CRITICAL, _("Wrong file descriptor %d"), priv->fd ); unclean |= 2; } if ( munmap( mmap_area, mmap_count ) != 0 ) { visual_log( VISUAL_LOG_CRITICAL, _("Could not munmap() area %p+%d. %s"), mmap_area, mmap_count, strerror( errno ) ); unclean |= 4; } } visual_mem_free( priv->sharedfile ); visual_mem_free( priv ); return - unclean; }
static int act_gstreamer_cleanup (VisPluginData *plugin) { GstreamerPrivate *priv = visual_object_get_private (VISUAL_OBJECT (plugin)); visual_mem_free (priv); return 0; }
static int lv_flower_cleanup (VisPluginData *plugin) { FlowerPrivate *priv = visual_object_get_private (VISUAL_OBJECT (plugin)); visual_timer_free (priv->flower.timer); visual_timer_free (priv->t); visual_mem_free (priv); return 0; }
static int lv_morph_flash_cleanup (VisPluginData *plugin) { FlashPrivate *priv = visual_object_get_private (VISUAL_OBJECT (plugin)); visual_palette_free (priv->whitepal); visual_mem_free (priv); return 0; }
static int beat_adv_dtor(VisObject *obj) { VisBeatAdv *adv = VISUAL_BEAT_ADV(obj); if(adv->beathistory != NULL) visual_mem_free(adv->beathistory); adv->beathistory = NULL; return TRUE; }
/** * Frees allocated colors from a VisPalette. * * @param pal Pointer to the VisPalette from which colors need to be freed. * * @return VISUAL_OK on succes, -VISUAL_ERROR_PALETTE_NULL on failure. */ int visual_palette_free_colors (VisPalette *pal) { visual_log_return_val_if_fail (pal != NULL, -VISUAL_ERROR_PALETTE_NULL); if (pal->colors != NULL) visual_mem_free (pal->colors); pal->colors = NULL; pal->ncolors = 0; return VISUAL_OK; }
static int act_jakdaw_cleanup (VisPluginData *plugin) { JakdawPrivate *priv = visual_object_get_private (VISUAL_OBJECT (plugin)); _jakdaw_feedback_close (priv); visual_object_unref (VISUAL_OBJECT (priv->pcmbuf)); visual_object_unref (VISUAL_OBJECT (priv->freqbuf)); visual_mem_free (priv); return 0; }
static int free_plugpaths () { int i; if (__lv_plugpaths == NULL) return VISUAL_OK; for (i = 0; i < __lv_plugpath_cnt - 1; i++) visual_mem_free (__lv_plugpaths[i]); free (__lv_plugpaths); return VISUAL_OK; }
/** * Sets the annotation field of the VisParamEntry to the provided null terminated string. * * @param param Pointer to the VisParamEntry to which a parameter is set. * @param anno A null terminated string which to assign to the VisParamEntry's annotation field. * * @return VISUAL_OK on success, -VISUAL_ERROR_PARAM_NULL or -VISUAL_ERROR_PARAM_ANNO_NULL on failure. */ int visual_param_entry_set_annotation (VisParamEntry *param, char *anno) { visual_log_return_val_if_fail(param != NULL, -VISUAL_ERROR_PARAM_NULL); ; visual_log_return_val_if_fail(anno != NULL, -VISUAL_ERROR_PARAM_ANNO_NULL); if (param->annotation != NULL) visual_mem_free(param->annotation); param->annotation = strdup(anno); return VISUAL_OK; }
static int lv_goom_cleanup (VisPluginData *plugin) { GoomPrivate *priv = visual_object_get_private (VISUAL_OBJECT (plugin)); if (priv->goominfo != NULL) goom_close (priv->goominfo); visual_buffer_free (priv->pcmbuf1); visual_buffer_free (priv->pcmbuf2); visual_mem_free (priv); return 0; }
/** * Quits libvisual, destroys all the plugin registries. * * @return VISUAL_OK on succes, -VISUAL_ERROR_LIBVISUAL_NOT_INITIALIZED on failure. */ int visual_quit () { int ret; if (__lv_initialized == FALSE) { visual_log (VISUAL_LOG_WARNING, _("Never initialized")); return -VISUAL_ERROR_LIBVISUAL_NOT_INITIALIZED; } if (visual_fourier_is_initialized () == TRUE) visual_fourier_deinitialize (); ret = visual_object_unref (VISUAL_OBJECT (__lv_plugins)); if (ret < 0) visual_log (VISUAL_LOG_WARNING, _("Plugins references list: destroy failed: %s"), visual_error_to_string (ret)); ret = visual_object_unref (VISUAL_OBJECT (__lv_plugins_actor)); if (ret < 0) visual_log (VISUAL_LOG_WARNING, _("Actor plugins list: destroy failed: %s"), visual_error_to_string (ret)); ret = visual_object_unref (VISUAL_OBJECT (__lv_plugins_input)); if (ret < 0) visual_log (VISUAL_LOG_WARNING, _("Input plugins list: destroy failed: %s"), visual_error_to_string (ret)); ret = visual_object_unref (VISUAL_OBJECT (__lv_plugins_morph)); if (ret < 0) visual_log (VISUAL_LOG_WARNING, _("Morph plugins list: destroy failed: %s"), visual_error_to_string (ret)); ret = visual_object_unref (VISUAL_OBJECT (__lv_plugins_transform)); if (ret < 0) visual_log (VISUAL_LOG_WARNING, _("Transform plugins list: destroy failed: %s"), visual_error_to_string (ret)); ret = visual_object_unref (VISUAL_OBJECT (__lv_paramcontainer)); if (ret < 0) visual_log (VISUAL_LOG_WARNING, _("Global param container: destroy failed: %s"), visual_error_to_string (ret)); ret = visual_object_unref (VISUAL_OBJECT (__lv_userinterface)); if (ret < 0) visual_log (VISUAL_LOG_WARNING, _("Error during UI destroy: %s"), visual_error_to_string (ret)); if (__lv_progname != NULL) { visual_mem_free (__lv_progname); __lv_progname = NULL; } __lv_initialized = FALSE; return VISUAL_OK; }
static int lvavs_preset_element_dtor (VisObject *object) { LVAVSPresetElement *element = LVAVS_PRESET_ELEMENT (object); if (element->pcont != NULL) visual_object_unref (VISUAL_OBJECT (element->pcont)); if (element->element_name != NULL) visual_mem_free((void *)element->element_name); element->pcont = NULL; return TRUE; }
/** * Set the name for a VisParamEntry. * * @param param Pointer to the VisParamEntry to which the name is set. * @param name The name that is set to the VisParamEntry. * * @return VISUAL_OK on succes, -VISUAL_ERROR_PARAM_NULL on failure. */ int visual_param_entry_set_name (VisParamEntry *param, char *name) { visual_log_return_val_if_fail (param != NULL, -VISUAL_ERROR_PARAM_NULL); if (param->name != NULL) visual_mem_free (param->name); param->name = NULL; if (name != NULL) param->name = strdup (name); return VISUAL_OK; }
/* Object destructors */ static int lvavs_preset_dtor (VisObject *object) { LVAVSPreset *preset = LVAVS_PRESET (object); if (preset->origfile != NULL) visual_mem_free (preset->origfile); if (preset->main != NULL) visual_object_unref (VISUAL_OBJECT (preset->main)); preset->origfile = NULL; preset->main = NULL; return TRUE; }
int act_infinite_cleanup (VisPluginData *plugin) { InfinitePrivate *priv; visual_return_val_if_fail (plugin != NULL, -1); priv = visual_object_get_private (VISUAL_OBJECT (plugin)); _inf_close_renderer (priv); visual_palette_free (priv->pal); visual_mem_free (priv); return 0; }
static int audio_samplepool_channel_dtor (VisObject *object) { VisAudioSamplePoolChannel *channel = VISUAL_AUDIO_SAMPLEPOOL_CHANNEL (object); if (channel->samples != NULL) visual_object_unref (VISUAL_OBJECT (channel->samples)); if (channel->channelid != NULL) visual_mem_free (channel->channelid); channel->samples = NULL; channel->channelid= NULL; return VISUAL_OK; }
static int beat_dtor(VisObject *obj) { VisBeat *beat = VISUAL_BEAT(obj); if(beat->txt != NULL) visual_mem_free(beat->txt); beat->txt = NULL; if(beat->TCHist != NULL) visual_mem_free(beat->TCHist); beat->TCHist = NULL; if(beat->smoother != NULL) visual_mem_free(beat->smoother); beat->smoother = NULL; if(beat->half_discriminated != NULL) visual_mem_free(beat->half_discriminated); beat->half_discriminated = NULL; if(beat->half_discriminated2 != NULL) visual_mem_free(beat->half_discriminated2); beat->half_discriminated2 = NULL; if(beat->adv != NULL) visual_object_unref(VISUAL_OBJECT(beat->adv)); beat->adv = NULL; return TRUE; }
/* Object destructors */ static int avs_tree_dtor (VisObject *object) { AVSTree *avstree = AVS_TREE (object); if (avstree->data != NULL) visual_mem_free (avstree->data); if (avstree->main != NULL) visual_object_unref (VISUAL_OBJECT (avstree->main)); avstree->origfile = NULL; avstree->data = NULL; avstree->cur = NULL; avstree->main = NULL; return TRUE; }
VisMorph *visual_morph_new (const char *morphname) { VisMorph *morph; int result; morph = visual_mem_new0 (VisMorph, 1); result = visual_morph_init (morph, morphname); if (result != VISUAL_OK) { visual_mem_free (morph); return NULL; } /* Do the VisObject initialization */ visual_object_set_allocated (VISUAL_OBJECT (morph), TRUE); visual_object_ref (VISUAL_OBJECT (morph)); return morph; }
VisTransform *visual_transform_new (const char *transformname) { VisTransform *transform; int result; transform = visual_mem_new0 (VisTransform, 1); result = visual_transform_init (transform, transformname); if (result != VISUAL_OK) { visual_mem_free (transform); return NULL; } /* Do the VisObject initialization */ visual_object_set_allocated (VISUAL_OBJECT (transform), TRUE); visual_object_ref (VISUAL_OBJECT (transform)); return transform; }
int visual_video_free_buffer (VisVideo *video) { visual_return_val_if_fail (video != NULL, -VISUAL_ERROR_VIDEO_NULL); visual_return_val_if_fail (visual_video_get_pixels (video) != NULL, -VISUAL_ERROR_VIDEO_PIXELS_NULL); if (video->pixel_rows != NULL) visual_mem_free (video->pixel_rows); if (visual_buffer_get_allocated (video->buffer)) { visual_buffer_destroy_content (video->buffer); } else { return -VISUAL_ERROR_VIDEO_NO_ALLOCATED; } video->pixel_rows = NULL; visual_buffer_set_data_pair (video->buffer, NULL, 0); return VISUAL_OK; }