- if( *p_input->psz_demux && !strncmp( p_input->psz_demux, "flac", 4 ) )
- {
- /* User forced */
- msg_Err( p_input, "this doesn't look like an flac stream, "
- "continuing anyway" );
- }
- else
- {
- msg_Warn( p_input, "flac module discarded (no startcode)" );
- return( -1 );
- }
+ msg_Err( p_demux, "invalid size for a STREAMINFO metadata block" );
+ return VLC_EGENERIC;
+ }
+
+ /*
+ * Load the FLAC packetizer
+ */
+ p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_DECODER );
+ p_sys->p_packetizer->pf_decode_audio = 0;
+ p_sys->p_packetizer->pf_decode_video = 0;
+ p_sys->p_packetizer->pf_decode_sub = 0;
+ p_sys->p_packetizer->pf_packetize = 0;
+
+ /* Initialization of decoder structure */
+ es_format_Init( &p_sys->p_packetizer->fmt_in, AUDIO_ES,
+ VLC_FOURCC( 'f', 'l', 'a', 'c' ) );
+
+ /* Store STREAMINFO for the decoder and packetizer */
+ p_sys->p_packetizer->fmt_in.i_extra = fmt.i_extra = STREAMINFO_SIZE + 4;
+ p_sys->p_packetizer->fmt_in.p_extra = malloc( STREAMINFO_SIZE + 4 );
+ stream_Read( p_demux->s, p_sys->p_packetizer->fmt_in.p_extra,
+ STREAMINFO_SIZE + 4 );
+
+ /* Fake this as the last metadata block */
+ ((uint8_t*)p_sys->p_packetizer->fmt_in.p_extra)[4] |= 0x80;
+ fmt.p_extra = malloc( STREAMINFO_SIZE + 4 );
+ memcpy( fmt.p_extra, p_sys->p_packetizer->fmt_in.p_extra,
+ STREAMINFO_SIZE + 4 );
+
+ p_sys->p_packetizer->p_module =
+ module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 );
+ if( !p_sys->p_packetizer->p_module )
+ {
+ if( p_sys->p_packetizer->fmt_in.p_extra )
+ free( p_sys->p_packetizer->fmt_in.p_extra );
+ vlc_object_destroy( p_sys->p_packetizer );
+
+ msg_Err( p_demux, "cannot find flac packetizer" );
+ return VLC_EGENERIC;