#include "sndfile.h"
#include "common.h"
-#if 0 /* HAVE_EXTERNAL_LIBS : Disable for TIZEN */
+#if HAVE_EXTERNAL_LIBS
#include <FLAC/stream_decoder.h>
#include <FLAC/stream_encoder.h>
unsigned bufferpos ;
const FLAC__Frame *frame ;
+ FLAC__bool bufferbackup ;
unsigned compression ;
-
} FLAC_PRIVATE ;
typedef struct
if (pflac->ptr == NULL)
{ /*
- ** This pointer is reset to NULL each time the current frame has been
- ** decoded. Somehow its used during encoding and decoding.
+ ** Not sure why this code is here and not elsewhere.
+ ** Removing it causes valgrind errors.
*/
+ pflac->bufferbackup = SF_TRUE ;
for (i = 0 ; i < frame->header.channels ; i++)
{
if (pflac->rbuffer [i] == NULL)
return 0 ;
} ;
- if (pflac->remain % channels != 0)
- { psf_log_printf (psf, "Error: pflac->remain %u channels %u\n", pflac->remain, channels) ;
- return 0 ;
- } ;
-
switch (pflac->pcmtype)
{ case PFLAC_PCM_SHORT :
{ short *retpcm = (short*) pflac->ptr ;
pflac->frame = frame ;
pflac->bufferpos = 0 ;
+ pflac->bufferbackup = SF_FALSE ;
pflac->wbuffer = buffer ;
flac_buffer_copy (psf) ;
static unsigned
flac_read_loop (SF_PRIVATE *psf, unsigned len)
{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;
- FLAC__StreamDecoderState state ;
pflac->pos = 0 ;
pflac->len = len ;
pflac->remain = len ;
-
- state = FLAC__stream_decoder_get_state (pflac->fsd) ;
- if (state > FLAC__STREAM_DECODER_END_OF_STREAM)
- { psf_log_printf (psf, "FLAC__stream_decoder_get_state returned %s\n", FLAC__StreamDecoderStateString [state]) ;
- /* Current frame is busted, so NULL the pointer. */
- pflac->frame = NULL ;
- } ;
-
- /* First copy data that has already been decoded and buffered. */
if (pflac->frame != NULL && pflac->bufferpos < pflac->frame->header.blocksize)
flac_buffer_copy (psf) ;
while (pflac->pos < pflac->len)
{ if (FLAC__stream_decoder_process_single (pflac->fsd) == 0)
break ;
- state = FLAC__stream_decoder_get_state (pflac->fsd) ;
- if (state >= FLAC__STREAM_DECODER_END_OF_STREAM)
- { psf_log_printf (psf, "FLAC__stream_decoder_get_state returned %s\n", FLAC__StreamDecoderStateString [state]) ;
- /* Current frame is busted, so NULL the pointer. */
- pflac->frame = NULL ;
+ if (FLAC__stream_decoder_get_state (pflac->fsd) >= FLAC__STREAM_DECODER_END_OF_STREAM)
break ;
- } ;
} ;
pflac->ptr = NULL ;