Example #1
0
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;
}
Example #2
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;
}
  System::System (int& argc, char**& argv)
      : m_impl(new Impl)
  {
      visual_log (VISUAL_LOG_INFO, "Starting Libvisual %s", get_version ().c_str ());

#if ENABLE_NLS
      bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
      bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif

      __lv_progname = visual_strdup (argv[0]);

      /* Initialize CPU caps */
      visual_cpu_initialize ();

      /* Initialize Mem system */
      visual_mem_initialize ();

      /* Initialize CPU-accelerated graphics functions */
      visual_alpha_blend_initialize ();

      /* Initialize high-resolution timer system */
	  Time::init ();

      /* Initialize Thread system */
      visual_thread_initialize ();

      /* Initialize FFT system */
      Fourier::init ();

      /* Initialize the plugin registry */
      PluginRegistry::init ();

      m_impl->params = visual_param_container_new ();
      init_params (m_impl->params);
  }
int load_parameters(const char * filename)
{
  FILE *f = fopen(filename,"r");
  if(f==NULL)
    return 0;
  char buf[1024];
  char *ptr, *word;
  const char *err;
  int line = 1, mode = 0;

  char *oldlocal = setlocale (LC_NUMERIC, "C");


  if(ps)
    freeparams();
  p_parsed.name = 0;

  fgets(buf,1024, f);

  while(!feof(f))
    {
      ptr = buf;
      word = nextword(ptr);
      if(word[0]!= '#')
	{
	  switch (mode)
	    {
	    case 0: //Begin
	      if(strcmp(word, "Begin") == 0)
		{
		  word = nextword(ptr);
		  if(strcmp(word, "Effect") == 0)
		    {
		      mode = 1;
		      word = nextword(ptr);
		      p_parsed.name = 0;
		      if(strcmp(word, "inherits") == 0)
			{
			  word = nextword(ptr);
			  for(int i=0;i<nump;i++)
			    {
			      if(strcmp(ps[i].name, word)==0)
				{
				  p_parsed = ps[i];
				  p_parsed.name = visual_strdup(p_parsed.name);
				  break;
				}
			    }
			}
		    }
		  else
		    {
		      err= "unknown Begin";
		      goto error;
		    }

		}

	    case 1:
	      if(strcmp(word, "End") == 0)
			{
			  word = nextword(ptr);

			  if(strcmp(word, "Effect") == 0)
				{
				  if(p_parsed.name==0)
					{
					  err = "no name for this effect";
					  goto error;
					}
				  mode = 0;
				  if(nump++==0)
					ps = (parameters *) malloc(nump* sizeof(parameters));
				  else
					ps = (parameters *) realloc(ps,nump* sizeof(parameters));
				  ps[nump-1] = p_parsed;

				}

			}
	      else
		{
		  char *var,  *egal, *val;
		  int i;
		  var = word;
		  egal = nextword(ptr);
		  val = nextword(ptr);
		  for(i=0;i<numpp;i++)
		    {
		      if(strcmp(var, pp[i].pname)==0)
			{
			  switch (pp[i].type)
			    {
			    case PARAM_INT:
			      sscanf(val, "%d", (int *)pp[i].where);
			      break;
			    case PARAM_FLOAT:
				  float val2 ;
				  val2 = atof(val);
				  *((float *)pp[i].where) = val2;
			      break;
			    case PARAM_CHAR:
			      sscanf(val, "%c", (char *)pp[i].where);
			      break;
			    case PARAM_STR:
			      if(*(char **)pp[i].where)
				free(*(char **)pp[i].where);
			      *(char **)pp[i].where = visual_strdup(val);
			      break;
			    }
			  break;
			}
		    }
		  if(i==numpp && *egal == '=')
		    {
		      err= "unknown parameter";
		      goto error;
		    }
		}
	    }
	}
      fgets(buf,1024, f);line++;
    }
  if(mode == 1)
    {
      err = " missing End Effect";
      goto error;
    }
  setlocale (LC_NUMERIC, oldlocal);


  fclose(f);
  newconfig = 1;
  allocParts();
  changep();
  return 1;
 error:
  setlocale (LC_NUMERIC, oldlocal);
  fclose(f);
  return 0;
}
Example #5
0
/**
 * fill config with default values
 */
void config_default(BlurskConfig *conf)
{
    char config_default_color_style[] = "Rainbow";
    char config_default_signal_color[] = "Normal signal";
    char config_default_background[] = "Black bkgnd";
    char config_default_blur_style[] = "Random";
    char config_default_transition_speed[] = "Medium switch";
    char config_default_fade_speed[] = "Medium fade";
    char config_default_blur_when[] = "Full blur";
    char config_default_blur_stencil[] = "No stencil";
    char config_default_signal_style[] = "Stereo spectrum";
    char config_default_plot_style[] = "Line";
    char config_default_flash_style[] = "No flash";
    char config_default_overall_effect[] = "Normal effect";
    char config_default_floaters[] = "No floaters";
    char config_default_cpu_speed[] = "Fast CPU";
    char config_default_show_info[] = "Never show info";
    /*char config_default_fullscreen_method[] = "None";*/


    /* window geometry -- generally ignored */
    conf->width = 256;
    conf->height = 128;

    /* main options */
    conf->color = 0x00ffff;
    if(conf->color_style)
        visual_mem_free(conf->color_style);
    conf->color_style = visual_strdup(config_default_color_style);
    if(conf->signal_color)
        visual_mem_free(conf->signal_color);
    conf->signal_color = visual_strdup(config_default_signal_color);
    conf->contour_lines = FALSE;
    conf->hue_on_beats = FALSE;
    if(conf->background)
        visual_mem_free(conf->background);
    conf->background = visual_strdup(config_default_background);
    if(conf->blur_style)
        visual_mem_free(conf->blur_style);
    conf->blur_style = visual_strdup(config_default_blur_style);
    if(conf->transition_speed)
        visual_mem_free(conf->transition_speed);
    conf->transition_speed = visual_strdup(config_default_transition_speed);
    if(conf->fade_speed)
        visual_mem_free(conf->fade_speed);
    conf->fade_speed = visual_strdup(config_default_fade_speed);
    if(conf->blur_when)
        visual_mem_free(conf->blur_when);
    conf->blur_when = visual_strdup(config_default_blur_when);
    if(conf->blur_stencil)
        visual_mem_free(conf->blur_stencil);
    conf->blur_stencil = visual_strdup(config_default_blur_stencil);
    conf->slow_motion = FALSE;
    if(conf->signal_style)
        visual_mem_free(conf->signal_style);
    conf->signal_style = visual_strdup(config_default_signal_style);
    if(conf->plot_style)
        visual_mem_free(conf->plot_style);
    conf->plot_style = visual_strdup(config_default_plot_style);
    conf->thick_on_beats = TRUE;
    if(conf->flash_style)
        visual_mem_free(conf->flash_style);
    conf->flash_style = visual_strdup(config_default_flash_style);
    if(conf->overall_effect)
        visual_mem_free(conf->overall_effect);
    conf->overall_effect = visual_strdup(config_default_overall_effect);
    if(conf->floaters)
        visual_mem_free(conf->floaters);
    conf->floaters = visual_strdup(config_default_floaters);

    /* advanced options */
    if(conf->cpu_speed)
        visual_mem_free(conf->cpu_speed);
    conf->cpu_speed = visual_strdup(config_default_cpu_speed);
    if(conf->show_info)
        visual_mem_free(conf->show_info);
    conf->show_info = visual_strdup(config_default_show_info);
    conf->info_timeout = 4;
    conf->show_timestamp = 0;
    conf->beat_sensitivity = 4;
}
Example #6
0
int inp_alsa_init (VisPluginData *plugin)
{
	snd_pcm_hw_params_t *hwparams = NULL;
	alsaPrivate *priv;
	unsigned int rate = inp_alsa_var_samplerate;
	unsigned int exact_rate;
	unsigned int tmp;
	int dir;
	int err;

#if ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif

	visual_return_val_if_fail(plugin != NULL, -1);

	priv = visual_mem_new0 (alsaPrivate, 1);
	visual_return_val_if_fail(priv != NULL, -1);

	visual_object_set_private (VISUAL_OBJECT (plugin), priv);

	if ((err = snd_pcm_open(&priv->chandle, visual_strdup(inp_alsa_var_cdevice),
			SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK)) < 0) {
		visual_log(VISUAL_LOG_ERROR,
			    _("Record open error: %s"), snd_strerror(err));
		return -1;
	}

	snd_pcm_hw_params_malloc(&hwparams);
	visual_return_val_if_fail(hwparams != NULL, -1);

	if (snd_pcm_hw_params_any(priv->chandle, hwparams) < 0) {
		visual_log(VISUAL_LOG_ERROR,
			   _("Cannot configure this PCM device"));
		snd_pcm_hw_params_free(hwparams);
		return(-1);
	}

	if (snd_pcm_hw_params_set_access(priv->chandle, hwparams,
					 SND_PCM_ACCESS_RW_INTERLEAVED) < 0) {
		visual_log(VISUAL_LOG_ERROR, _("Error setting access"));
		snd_pcm_hw_params_free(hwparams);
		return(-1);
	}

#if VISUAL_LITTLE_ENDIAN == 1
	if (snd_pcm_hw_params_set_format(priv->chandle, hwparams,
					 SND_PCM_FORMAT_S16_LE) < 0) {
#else
	if (snd_pcm_hw_params_set_format(priv->chandle, hwparams,
					 SND_PCM_FORMAT_S16_BE) < 0) {
#endif
		visual_log(VISUAL_LOG_ERROR, _("Error setting format"));
		snd_pcm_hw_params_free(hwparams);
		return(-1);
	}

	exact_rate = rate;

	if (snd_pcm_hw_params_set_rate_near(priv->chandle, hwparams,
					    &exact_rate, &dir) < 0) {
		visual_log(VISUAL_LOG_ERROR, _("Error setting rate"));
		snd_pcm_hw_params_free(hwparams);
		return(-1);
	}
	if (exact_rate != rate) {
		visual_log(VISUAL_LOG_INFO,
			   _("The rate %d Hz is not supported by your " \
			   "hardware.\n" \
			   "==> Using %d Hz instead"), rate, exact_rate);
	}
	rate = exact_rate;

	if (snd_pcm_hw_params_set_channels(priv->chandle, hwparams,
					   inp_alsa_var_channels) < 0) {
	        visual_log(VISUAL_LOG_ERROR, _("Error setting channels"));
		snd_pcm_hw_params_free(hwparams);
		return(-1);
	}

       /* Setup a large buffer */

	tmp = 1000000;
	if (snd_pcm_hw_params_set_period_time_near(priv->chandle, hwparams, &tmp, &dir) < 0){
		visual_log(VISUAL_LOG_ERROR, _("Error setting period time"));
		snd_pcm_hw_params_free(hwparams);
		return(-1);
	}

	tmp = 1000000*4;
	if (snd_pcm_hw_params_set_buffer_time_near(priv->chandle, hwparams, &tmp, &dir) < 0){
		visual_log(VISUAL_LOG_ERROR, _("Error setting buffer time"));
		snd_pcm_hw_params_free(hwparams);
		return(-1);
	}


	if (snd_pcm_hw_params(priv->chandle, hwparams) < 0) {
		visual_log(VISUAL_LOG_ERROR, _("Error setting HW params"));
		snd_pcm_hw_params_free(hwparams);
		return(-1);
	}

	if (snd_pcm_prepare(priv->chandle) < 0) {
		visual_log(VISUAL_LOG_ERROR, _("Failed to prepare interface"));
		snd_pcm_hw_params_free(hwparams);
		return(-1);
	}

	snd_pcm_hw_params_free(hwparams);

	priv->loaded = 1;

	return 0;
}

int inp_alsa_cleanup (VisPluginData *plugin)
{
	alsaPrivate *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)
		snd_pcm_close(priv->chandle);

	visual_mem_free (priv);

	return 0;
}