Esempio n. 1
0
static void
_msdata_free(void)
{
   // cleanup msdata outside of thread due to thread issues in dlsym etc.
   if (!msdata) return;
   //cleanup Remix stuffs
   remix_destroy(msdata->msenv->remixenv, msdata->player);
   remix_destroy(msdata->msenv->remixenv, msdata->deck);
   remix_purge(msdata->msenv->remixenv);

   free(msdata->msenv);
   free(msdata);
   msdata = NULL;
}
Esempio n. 2
0
static Multisense_Data *
init_multisense_environment(void)
{
   Multisense_Data *msdata;
   char ms_factory[BUF_LEN];
   char *ms_factory_env;
   Eina_Module *m = NULL;
   MULTISENSE_FACTORY_INIT_FUNC multisense_factory_init;

   msdata = calloc(1, sizeof(Multisense_Data));
   if (!msdata) goto err;

   msdata->msenv = calloc(1, sizeof(Edje_Multisense_Env));
   if (!msdata->msenv) goto err;

   ms_factory_env = getenv("MULTISENSE_FACTORY");
   if (ms_factory_env)
     strncpy(ms_factory, ms_factory_env, BUF_LEN);
   else
     strcpy(ms_factory, "multisense_factory");
   
   m = _edje_module_handle_load(ms_factory);
   if (!m) goto err;
   
   msdata->msenv->remixenv = remix_init();

   multisense_factory_init = 
     eina_module_symbol_get(m, "multisense_factory_init");
   if (multisense_factory_init) multisense_factory_init(msdata->msenv);

   msdata->multisense_sound_player_get = 
     eina_module_symbol_get(m, "multisense_sound_player_get");
   if (!msdata->multisense_sound_player_get) goto err;

   msdata->deck = remix_deck_new(msdata->msenv->remixenv);
   msdata->track = remix_track_new(msdata->msenv->remixenv, msdata->deck);
   msdata->snd_layer = remix_layer_new_ontop(msdata->msenv->remixenv,
                                             msdata->track,
                                             REMIX_TIME_SAMPLES);
   msdata->player_layer = remix_layer_new_ontop(msdata->msenv->remixenv,
                                                msdata->track,
                                                REMIX_TIME_SAMPLES);
   msdata->player = msdata->multisense_sound_player_get(msdata->msenv);
   if (!msdata->player) goto err;
   msdata->player_snd = remix_sound_new(msdata->msenv->remixenv,
                                        msdata->player, msdata->player_layer,
                                        REMIX_SAMPLES(0),
                                        REMIX_SAMPLES(REMIX_COUNT_INFINITE));
   return msdata;

err:
   if (msdata)
     {
        if (msdata->deck) remix_destroy(msdata->msenv->remixenv, msdata->deck);
        if (msdata->msenv->remixenv) remix_purge(msdata->msenv->remixenv);
        if (msdata->msenv) free(msdata->msenv);
        free(msdata);
     }
   return NULL;
}
Esempio n. 3
0
static void
remix_gain_replace_mixstream (RemixEnv * env, RemixBase * gain)
{
  RemixCount mixlength = remix_base_get_mixlength (env, gain);
  RemixGain * gi = (RemixGain *)remix_base_get_instance_data (env, gain);

  if (gi->_gain_envstream != RemixNone)
    remix_destroy (env, (RemixBase *)gi->_gain_envstream);

  gi->_gain_envstream =
    remix_stream_new_contiguous (env, mixlength);
}
Esempio n. 4
0
static RemixBase *
remix_sndfile_create (RemixEnv * env, RemixBase * sndfile,
		     const char * path, int writing)
{
  RemixSndfileInstance * si =
    remix_malloc (sizeof (struct _RemixSndfileInstance));

  si->path = strdup (path);
  si->writing = writing;

  if (writing) {
    si->info.samplerate = remix_get_samplerate (env);
    si->info.channels = 1; /* XXX: how many channels, or specify? */
    si->info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; /* XXX: assumes WAV */

    si->file = sf_open  (path, SFM_WRITE, &si->info);
    si->pcm = NULL;
    si->pcm_n = 0;
  } else {
    si->file = sf_open (path, SFM_READ, &si->info);
    si->pcm = (float *) malloc (BLOCK_FRAMES * si->info.channels *
				sizeof(float));
    si->pcm_n = 0;
  }

  if (si->file == NULL) {
    remix_set_error (env, REMIX_ERROR_SYSTEM);
    remix_destroy (env, (RemixBase *)sndfile);
    return RemixNone;
  }

  sf_command (si->file, SFC_SET_NORM_FLOAT, NULL, SF_TRUE);

  if (writing)
    sf_command (si->file, SFC_SET_ADD_DITHER_ON_WRITE, NULL, SF_TRUE);

  sndfile->instance_data = si;

  return sndfile;
}