X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fau.c;h=19f8752247aff174d04aa55f40698cd84711cf7f;hb=56d4e908e1b71fc6161622701d1cf0db64e57aa6;hp=9663de597a0cff6ce908e60fcfb467858d6ff948;hpb=d3fe7f28797d4dba65ffcdd60bf932e758a48a9e;p=vlc diff --git a/modules/demux/au.c b/modules/demux/au.c index 9663de597a..19f8752247 100644 --- a/modules/demux/au.c +++ b/modules/demux/au.c @@ -1,32 +1,36 @@ /***************************************************************************** * au.c : au file input module for vlc ***************************************************************************** - * Copyright (C) 2001-2003 the VideoLAN team + * Copyright (C) 2001-2007 VLC authors and VideoLAN * $Id$ * * Authors: Laurent Aimar * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* malloc(), free() */ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include /* TODO: @@ -40,14 +44,14 @@ static int Open ( vlc_object_t * ); static void Close( vlc_object_t * ); -vlc_module_begin(); - set_category( CAT_INPUT ); - set_subcategory( SUBCAT_INPUT_DEMUX ); - set_description( _("AU demuxer") ); - set_capability( "demux2", 10 ); - set_callbacks( Open, Close ); - add_shortcut( "au" ); -vlc_module_end(); +vlc_module_begin () + set_category( CAT_INPUT ) + set_subcategory( SUBCAT_INPUT_DEMUX ) + set_description( N_("AU demuxer") ) + set_capability( "demux", 10 ) + set_callbacks( Open, Close ) + add_shortcut( "au" ) +vlc_module_end () /***************************************************************************** * Local prototypes @@ -101,16 +105,15 @@ static int Open( vlc_object_t *p_this ) demux_sys_t *p_sys; uint8_t hdr[20]; - uint8_t *p_peek; + const uint8_t *p_peek; int i_cat; int i_samples, i_modulo; - CHECK_PEEK( p_peek, 4 ); + if( stream_Peek( p_demux->s , &p_peek, 4 ) < 4 ) + return VLC_EGENERIC; if( memcmp( p_peek, ".snd", 4 ) ) - { return VLC_EGENERIC; - } /* skip signature */ stream_Read( p_demux->s, NULL, 4 ); /* cannot fail */ @@ -128,8 +131,8 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; } - STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys; - p_sys->i_time = 1; + DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys; + p_sys->i_time = 0; p_sys->i_header_size = GetDWBE( &hdr[0] ); /* skip extra header data */ @@ -153,14 +156,14 @@ static int Open( vlc_object_t *p_this ) switch( GetDWBE( &hdr[8] ) ) { case AU_ALAW_8: /* 8-bit ISDN A-law */ - p_sys->fmt.i_codec = VLC_FOURCC( 'a','l','a','w' ); + p_sys->fmt.i_codec = VLC_CODEC_ALAW; p_sys->fmt.audio.i_bitspersample = 8; p_sys->fmt.audio.i_blockalign = 1 * p_sys->fmt.audio.i_channels; i_cat = AU_CAT_PCM; break; case AU_MULAW_8: /* 8-bit ISDN u-law */ - p_sys->fmt.i_codec = VLC_FOURCC( 'u','l','a','w' ); + p_sys->fmt.i_codec = VLC_CODEC_MULAW; p_sys->fmt.audio.i_bitspersample = 8; p_sys->fmt.audio.i_blockalign = 1 * p_sys->fmt.audio.i_channels; i_cat = AU_CAT_PCM; @@ -258,6 +261,13 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; } + if( p_sys->fmt.audio.i_rate == 0 ) + { + msg_Err( p_demux, "invalid samplerate: 0" ); + free( p_sys ); + return VLC_EGENERIC; + } + /* add the es */ p_sys->es = es_out_Add( p_demux->out, &p_sys->fmt ); @@ -290,7 +300,7 @@ static int Demux( demux_t *p_demux ) block_t *p_block; /* set PCR */ - es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_time ); + es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_time ); if( ( p_block = stream_Block( p_demux->s, p_sys->i_frame_size ) ) == NULL ) { @@ -299,7 +309,7 @@ static int Demux( demux_t *p_demux ) } p_block->i_dts = - p_block->i_pts = p_sys->i_time; + p_block->i_pts = VLC_TS_0 + p_sys->i_time; es_out_Send( p_demux->out, p_sys->es, p_block ); @@ -326,7 +336,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) { demux_sys_t *p_sys = p_demux->p_sys; - return demux2_vaControlHelper( p_demux->s, p_sys->i_header_size, -1, + return demux_vaControlHelper( p_demux->s, p_sys->i_header_size, -1, p_sys->fmt.i_bitrate, p_sys->fmt.audio.i_blockalign, i_query, args ); }