Re: [LAD] using libsndfile to write signed short

From: Joël Krähemann <weedlight@email-addr-hidden>
Date: Fri Sep 26 2014 - 14:40:09 EEST

On Fri, 2014-09-26 at 12:15 +0200, Joël Krähemann wrote:
> On Fri, 2014-09-26 at 10:20 +0200, Cedric Roux wrote:
> > On 09/25/2014 11:50 PM, Joël Krähemann wrote:
> > > void
> > > ags_sndfile_write(AgsPlayable *playable, signed short *buffer, guint
> > > buffer_length)
> > > {
> > > AgsSndfile *sndfile;
> > > sf_count_t multi_frames, retval;
> > >
> > > sndfile = AGS_SNDFILE(playable);
> > >
> > > multi_frames = buffer_length;
> > > retval = sf_write_short(sndfile->file, buffer, multi_frames);
> >
> > If buffer_length gives the number of bytes of the buffer,
> > you may be in trouble here. For sf_write_short, /usr/include/sndfile.h
> > says:
> > ** All of these read/write function return number of items read/written.
> > See also the libsndfile FAQ:
> > http://www.mega-nerd.com/libsndfile/FAQ.html#Q012
> >
> > HTH
> >
> > >
> > > if(retval > multi_frames){
> > > // sf_seek(sndfile->file, (multi_frames - retval),
> > > SEEK_CUR);
> > > }
> > > }
>
> This is how the buffer is allocated. Strange to me is
>
> multi_frames = buffer_length;
>
> or
>
> multi_frames = sndfile->file->info->channels * buffer_length;
>
> gives about the same size of file.
>
>
>
> /* buffer */
> devout->buffer = (signed short **) malloc(4 * sizeof(signed short*));
> devout->buffer[0] = (signed short *) malloc(devout->dsp_channels *
> devout->buffer_size * sizeof(signed short));
> devout->buffer[1] = (signed short *) malloc(devout->dsp_channels *
> devout->buffer_size * sizeof(signed short));
> devout->buffer[2] = (signed short *) malloc(devout->dsp_channels *
> devout->buffer_size * sizeof(signed short));
> devout->buffer[3] = (signed short *) malloc(devout->dsp_channels *
> devout->buffer_size * sizeof(signed short));
>
>
>

The code should be correct rather a problem with the thread tree, once
more.

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Fri Sep 26 16:15:02 2014

This archive was generated by hypermail 2.1.8 : Fri Sep 26 2014 - 16:15:02 EEST