* Preamble
*****************************************************************************/
+/* workaround libflac overriding assert.h system header */
+#define assert(x) do {} while(0)
+
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_codec.h>
#include <vlc_aout.h>
-#include <FLAC/stream_decoder.h>
-#include <FLAC/stream_encoder.h>
+#include <stream_decoder.h>
+#include <stream_encoder.h>
#include <vlc_block_helper.h>
#include <vlc_bits.h>
*/
block_t *p_block;
aout_buffer_t *p_aout_buffer;
+ date_t end_date;
/*
* FLAC properties
p_sys->p_block = *pp_block;
*pp_block = NULL;
+ if( p_sys->p_block->i_pts > VLC_TS_INVALID &&
+ p_sys->p_block->i_pts != date_Get( &p_sys->end_date ) )
+ date_Set( &p_sys->end_date, p_sys->p_block->i_pts );
+
p_sys->p_aout_buffer = 0;
if( !FLAC__stream_decoder_process_single( p_sys->p_flac ) )
if( p_dec->fmt_out.audio.i_channels <= 0 ||
p_dec->fmt_out.audio.i_channels > 8 )
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+ if( date_Get( &p_sys->end_date ) <= VLC_TS_INVALID )
+ return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+
const int * const pi_reorder = ppi_reorder[p_dec->fmt_out.audio.i_channels];
p_sys->p_aout_buffer =
}
/* Date management (already done by packetizer) */
- p_sys->p_aout_buffer->i_pts = p_sys->p_block->i_pts;
- p_sys->p_aout_buffer->i_length = p_sys->p_block->i_length;
+ p_sys->p_aout_buffer->i_pts = date_Get( &p_sys->end_date );
+ p_sys->p_aout_buffer->i_length =
+ date_Increment( &p_sys->end_date, frame->header.blocksize ) -
+ p_sys->p_aout_buffer->i_pts;
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
p_sys->b_stream_info = true;
p_sys->stream_info = metadata->data.stream_info;
- return;
+ date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
+ date_Set( &p_sys->end_date, VLC_TS_INVALID );
}
/*****************************************************************************