+ /* Set output properties */
+ p_dec->fmt_out.i_codec = VLC_FOURCC('f','l','a','c');
+
+ if( i_ret != VLC_SUCCESS )
+ {
+ es_format_Clean( &p_dec->fmt_out );
+ p_dec->fmt_out = es_save;
+ }
+ return i_ret;
+}
+
+/*****************************************************************************
+ * CloseDecoder: flac decoder destruction
+ *****************************************************************************/
+static void CloseDecoder( vlc_object_t *p_this )
+{
+ decoder_t *p_dec = (decoder_t *)p_this;
+ decoder_sys_t *p_sys = p_dec->p_sys;
+
+#ifdef USE_LIBFLAC
+ FLAC__stream_decoder_finish( p_sys->p_flac );
+ FLAC__stream_decoder_delete( p_sys->p_flac );
+#endif
+
+ free( p_sys->p_block );
+ free( p_sys );
+}
+
+/*****************************************************************************
+ * ProcessHeader: process Flac header.
+ *****************************************************************************/
+static void ProcessHeader( decoder_t *p_dec )
+{
+ decoder_sys_t *p_sys = p_dec->p_sys;
+
+#ifdef USE_LIBFLAC
+ if( !p_dec->fmt_in.i_extra ) return;
+