p_sys->i_state = STATE_NOSYNC;
p_sys->b_stream_info = false;
p_sys->p_block=NULL;
+ p_sys->i_pts = VLC_TS_INVALID;
p_sys->bytestream = block_BytestreamInit();
#ifdef USE_LIBFLAC
if( p_dec->fmt_out.i_codec == VLC_CODEC_FLAC )
{
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra =
- realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+ p_dec->fmt_out.p_extra = xrealloc( p_dec->fmt_out.p_extra,
+ p_dec->fmt_out.i_extra );
memcpy( p_dec->fmt_out.p_extra,
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
}
return NULL;
}
- if( !date_Get( &p_sys->end_date ) && !(*pp_block)->i_pts )
+ if( !date_Get( &p_sys->end_date ) && (*pp_block)->i_pts <= VLC_TS_INVALID )
{
/* We've just started the stream, wait for the first PTS. */
block_Release( *pp_block );
case STATE_SYNC:
/* New frame, set the Presentation Time Stamp */
p_sys->i_pts = p_sys->bytestream.p_block->i_pts;
- if( p_sys->i_pts != 0 &&
+ if( p_sys->i_pts > VLC_TS_INVALID &&
p_sys->i_pts != date_Get( &p_sys->end_date ) )
{
date_Set( &p_sys->end_date, p_sys->i_pts );
/* Make sure we don't reuse the same pts twice */
if( p_sys->i_pts == p_sys->bytestream.p_block->i_pts )
- p_sys->i_pts = p_sys->bytestream.p_block->i_pts = 0;
+ p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TS_INVALID;
/* So p_block doesn't get re-added several times */
*pp_block = block_BytestreamPop( &p_sys->bytestream );
/* Date management (already done by packetizer) */
p_sys->p_aout_buffer->i_pts = p_sys->p_block->i_pts;
- p_sys->p_aout_buffer->end_date =
- p_sys->p_block->i_pts + p_sys->p_block->i_length;
+ p_sys->p_aout_buffer->i_length = p_sys->p_block->i_length;
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
p_sys->i_samples_delay += p_aout_buf->i_nb_samples;
/* Convert samples to FLAC__int32 */
- if( p_sys->i_buffer < p_aout_buf->i_nb_bytes * 2 )
+ if( p_sys->i_buffer < p_aout_buf->i_buffer * 2 )
{
p_sys->p_buffer =
- realloc( p_sys->p_buffer, p_aout_buf->i_nb_bytes * 2 );
- p_sys->i_buffer = p_aout_buf->i_nb_bytes * 2;
+ xrealloc( p_sys->p_buffer, p_aout_buf->i_buffer * 2 );
+ p_sys->i_buffer = p_aout_buf->i_buffer * 2;
}
- for( i = 0 ; i < p_aout_buf->i_nb_bytes / 2 ; i++ )
+ for( i = 0 ; i < p_aout_buf->i_buffer / 2 ; i++ )
{
p_sys->p_buffer[i]= ((int16_t *)p_aout_buf->p_buffer)[i];
}
/* Backup the STREAMINFO metadata block */
p_enc->fmt_out.i_extra = STREAMINFO_SIZE + 4;
- p_enc->fmt_out.p_extra = malloc( STREAMINFO_SIZE + 4 );
+ p_enc->fmt_out.p_extra = xmalloc( STREAMINFO_SIZE + 4 );
memcpy( p_enc->fmt_out.p_extra, "fLaC", 4 );
memcpy( ((uint8_t *)p_enc->fmt_out.p_extra) + 4, buffer,
STREAMINFO_SIZE );