X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Faiff.c;h=a236582b10f77af91bd450a81b68baae88f6d24d;hb=c1cf203b27210576125cb7f23df93804c4598b39;hp=186606713b561e7b941ee139d25a393e05144f90;hpb=05492281965ed211badf7e1f4c2220be720d3356;p=vlc diff --git a/modules/demux/aiff.c b/modules/demux/aiff.c index 186606713b..a236582b10 100644 --- a/modules/demux/aiff.c +++ b/modules/demux/aiff.c @@ -109,8 +109,7 @@ static int Open( vlc_object_t *p_this ) if( stream_Peek( p_demux->s, &p_peek, 12 ) < 12 ) return VLC_EGENERIC; - if( memcmp( p_peek, "FORM", 4 ) - || memcmp( &p_peek[8], "AIFF", 4 ) ) + if( memcmp( p_peek, "FORM", 4 ) || memcmp( &p_peek[8], "AIFF", 4 ) ) return VLC_EGENERIC; /* skip aiff header */ @@ -119,21 +118,25 @@ static int Open( vlc_object_t *p_this ) /* Fill p_demux field */ DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys; es_format_Init( &p_sys->fmt, UNKNOWN_ES, 0 ); - p_sys->i_time = 1; + p_sys->i_time = 0; p_sys->i_ssnd_pos = -1; for( ;; ) { uint32_t i_size; - CHECK_PEEK_GOTO( p_peek, 8 ); + if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 ) + goto error; + i_size = GetDWBE( &p_peek[4] ); msg_Dbg( p_demux, "chunk fcc=%4.4s size=%d", p_peek, i_size ); if( !memcmp( p_peek, "COMM", 4 ) ) { - CHECK_PEEK_GOTO( p_peek, 18+8 ); + if( stream_Peek( p_demux->s, &p_peek, 18+8 ) < 18+8 ) + goto error; + es_format_Init( &p_sys->fmt, AUDIO_ES, VLC_FOURCC( 't', 'w', 'o', 's' ) ); p_sys->fmt.audio.i_channels = GetWBE( &p_peek[8] ); p_sys->fmt.audio.i_bitspersample = GetWBE( &p_peek[14] ); @@ -144,7 +147,9 @@ static int Open( vlc_object_t *p_this ) } else if( !memcmp( p_peek, "SSND", 4 ) ) { - CHECK_PEEK_GOTO( p_peek, 8+8 ); + if( stream_Peek( p_demux->s, &p_peek, 8+8 ) < 8+8 ) + goto error; + p_sys->i_ssnd_pos = stream_Tell( p_demux->s ); p_sys->i_ssnd_size = i_size; p_sys->i_ssnd_offset = GetDWBE( &p_peek[8] ); @@ -235,7 +240,7 @@ static int Demux( demux_t *p_demux ) } /* 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); /* we will read 100ms at once */ i_read = p_sys->i_ssnd_fsize * ( p_sys->fmt.audio.i_rate / 10 ); @@ -249,7 +254,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; p_sys->i_time += (int64_t)1000000 * p_block->i_buffer / @@ -304,7 +309,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) { return VLC_EGENERIC; } - p_sys->i_time = 1 + (int64_t)1000000 * i_frame / p_sys->fmt.audio.i_rate; + p_sys->i_time = (int64_t)1000000 * i_frame / p_sys->fmt.audio.i_rate; return VLC_SUCCESS; } return VLC_EGENERIC;