[LAD] using libsndfile to write signed short

Cedric Roux sed at free.fr
Fri Sep 26 08:20:34 UTC 2014


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);
>    }
> }


More information about the Linux-audio-dev mailing list