Exemple #1
0
void
gsl_data_cache_open (GslDataCache *dcache)
{
  g_return_if_fail (dcache != NULL);
  g_return_if_fail (dcache->ref_count > 0);

  GSL_SPIN_LOCK (&dcache->mutex);
  if (!dcache->open_count)
    {
      BseErrorType error;

      error = gsl_data_handle_open (dcache->dhandle);
      if (error)
	{
	  /* FIXME: this is pretty fatal, throw out zero blocks now? */
	  sfi_diag ("%s: failed to open \"%s\": %s", G_STRLOC, dcache->dhandle->name, bse_error_blurb (error));
	}
      else
	{
          dcache->high_persistency = gsl_data_handle_needs_cache (dcache->dhandle);
	  dcache->open_count = 1;
	  dcache->ref_count++;
	}
    }
  else
    dcache->open_count++;
  GSL_SPIN_UNLOCK (&dcache->mutex);
}
Exemple #2
0
static BseErrorType
bse_wave_add_inlined_wave_chunk (BseWave      *self,
                                 GslWaveChunk *wchunk)
{
  g_return_val_if_fail (BSE_IS_WAVE (self), BSE_ERROR_INTERNAL);
  BseErrorType error = gsl_data_handle_open (wchunk->dcache->dhandle);
  if (!error)
    self->open_handles = sfi_ring_append (self->open_handles, wchunk->dcache->dhandle);
  return error;
}
static GslDataHandle*
gsl_data_handle_new_ogg_vorbis_any (const gchar *file_name,
                                    guint        lbitstream,
                                    gfloat       osc_freq,
                                    gboolean     add_zoffset,
                                    guint        byte_offset,
                                    guint        byte_size,
                                    guint       *n_channelsp,
                                    gfloat      *mix_freqp)
{
  if (n_channelsp)
    *n_channelsp = 0;
  if (mix_freqp)
    *mix_freqp = 0;
  VorbisHandle *vhandle = sfi_new_struct0 (VorbisHandle, 1);
  gboolean success = gsl_data_handle_common_init (&vhandle->dhandle, file_name);
  if (success)
    {
      BseErrorType error;

      vhandle->dhandle.vtable = &dh_vorbis_vtable;
      vhandle->n_bitstreams = 0;
      vhandle->bitstream = lbitstream;
      vhandle->osc_freq = osc_freq;
      vhandle->rfile_byte_offset = byte_offset;
      vhandle->rfile_add_zoffset = add_zoffset != FALSE;
      vhandle->rfile_byte_length = byte_size;

      /* we can only check matters upon opening and need
       * to initialize things like the bitstream_serialno.
       */
      error = gsl_data_handle_open (&vhandle->dhandle);
      if (!error)
	{
          if (n_channelsp)
            *n_channelsp = vhandle->dhandle.setup.n_channels;
          if (mix_freqp)
            *mix_freqp = vhandle->dhandle.setup.mix_freq;
	  gsl_data_handle_close (&vhandle->dhandle);
	  return &vhandle->dhandle;
	}
      else
	{
	  gsl_data_handle_unref (&vhandle->dhandle);
	  return NULL;
	}
    }
  else
    {
      sfi_delete_struct (VorbisHandle, vhandle);
      return NULL;
    }
}
Exemple #4
0
/* --- chain handle --- */
static GslErrorType
chain_handle_open (GslDataHandle      *dhandle,
		   GslDataHandleSetup *setup)
{
  ChainHandle *chandle = (ChainHandle*) dhandle;
  GslErrorType error;

  error = gsl_data_handle_open (chandle->src_handle);
  if (error != GSL_ERROR_NONE)
    return error;
  *setup = chandle->src_handle->setup;

  return GSL_ERROR_NONE;
}
Exemple #5
0
static void
findx ()
{
  GslDataCache *dcache = gsl_data_cache_new (global_handle, 1);
  GslDataHandle *shandle = gsl_data_handle_new_dcached (dcache);
  GslLong length = gsl_data_handle_length (shandle);
  GslLong l, start = 0, end = 0, lsize = gsl_data_handle_length (shandle) / 2;
  gdouble score = 0, least = GSL_MAXLONG;
  
  gsl_data_cache_unref (dcache);
  gsl_data_handle_open (shandle);
  
  while (lsize)
    {
      for (l = 0; l < length - lsize; l++)
	{
	  GslDataHandle *dhandle = gsl_data_handle_new_looped (shandle, l, l + lsize);
	  
	  gsl_data_handle_open (dhandle);
	  score = score_loop (shandle, dhandle);
	  gsl_data_handle_close (dhandle);
	  gsl_data_handle_unref (dhandle);
	  if (score < least)
	    {
	      start = l;
	      end = l + lsize;
	      g_print ("\nimproved: %f < %f: [0x%lx..0x%lx] (%lu)\n", score, least, start, end, lsize);
	      least = score;
	    }
	  g_print ("\rprocessed: %lu / %lu\r", l, length - lsize);
	}
      lsize -= 1;
    }
  gsl_data_handle_close (shandle);
  gsl_data_handle_unref (shandle);
}
Exemple #6
0
static GslErrorType
dcache_handle_open (GslDataHandle      *dhandle,
		    GslDataHandleSetup *setup)
{
  DCacheHandle *chandle = (DCacheHandle*) dhandle;
  GslErrorType error;

  error = gsl_data_handle_open (chandle->dcache->dhandle);
  if (error != GSL_ERROR_NONE)
    return error;
  gsl_data_cache_open (chandle->dcache);
  *setup = chandle->dcache->dhandle->setup;
  gsl_data_handle_close (chandle->dcache->dhandle);

  return GSL_ERROR_NONE;
}
Exemple #7
0
/* --- cut handle --- */
static GslErrorType
cut_handle_open (GslDataHandle      *dhandle,
		 GslDataHandleSetup *setup)
{
  CutHandle *chandle = (CutHandle*) dhandle;
  GslErrorType error;

  error = gsl_data_handle_open (chandle->src_handle);
  if (error != GSL_ERROR_NONE)
    return error;
  *setup = chandle->src_handle->setup;
  setup->n_values -= MIN (setup->n_values, chandle->tail_cut);
  setup->n_values -= MIN (setup->n_values, chandle->n_cut_values);

  return GSL_ERROR_NONE;
}
GslVorbis1Handle*
gsl_vorbis1_handle_new (GslDataHandle *ogg_vorbis_handle,
                        guint          serialno)
{
  GslVorbis1Handle *v1h = NULL;
  if (ogg_vorbis_handle->vtable == &dh_vorbis_vtable &&
      gsl_data_handle_open (ogg_vorbis_handle) == BSE_ERROR_NONE)
    {
      v1h = g_new0 (GslVorbis1Handle, 1);
      v1h->dhandle = ogg_vorbis_handle;
      VorbisHandle *vhandle = (VorbisHandle*) ogg_vorbis_handle;
      v1h->bitstream_serialno = vhandle->bitstream_serialno;
      v1h->rfile_byte_offset = vhandle->rfile_byte_offset;
      v1h->rfile_add_zoffset = vhandle->rfile_add_zoffset;
      v1h->rfile_byte_length = vhandle->rfile_byte_length;
      v1h->forced_serialno = serialno;
    }
  return v1h;
}
Exemple #9
0
/* --- insert handle --- */
static GslErrorType
insert_handle_open (GslDataHandle      *dhandle,
		    GslDataHandleSetup *setup)
{
  InsertHandle *ihandle = (InsertHandle*) dhandle;
  GslErrorType error;

  error = gsl_data_handle_open (ihandle->src_handle);
  if (error != GSL_ERROR_NONE)
    return error;
  *setup = ihandle->src_handle->setup;
  ihandle->paste_offset = ihandle->requested_paste_offset < 0 ? setup->n_values : ihandle->requested_paste_offset;
  if (setup->n_values < ihandle->paste_offset)
    setup->n_values = ihandle->paste_offset + ihandle->n_paste_values;
  else
    setup->n_values += ihandle->n_paste_values;
  setup->bit_depth = MAX (setup->bit_depth, ihandle->paste_bit_depth);

  return GSL_ERROR_NONE;
}