Commit 27ebd5cd authored by Laurent Aimar's avatar Laurent Aimar

* asf: in fast/slow motion we don't play audio (unless there isn't any

video). Added some clean up.
parent bed89e05
......@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: asf.c,v 1.16 2003/01/20 13:04:03 fenrir Exp $
* $Id: asf.c,v 1.17 2003/01/23 15:07:20 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -430,43 +430,9 @@ static int Activate( vlc_object_t * p_this )
default: var = def; break;\
}
static int Demux( input_thread_t *p_input )
static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
{
demux_sys_t *p_demux = p_input->p_demux_data;
int i;
/* catch seek from user */
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
{
off_t i_offset;
msleep( DEFAULT_PTS_DELAY );
i_offset = ASF_TellAbsolute( p_input ) - p_demux->i_data_begin;
if( i_offset < 0 )
{
i_offset = 0;
}
/* XXX work only when i_min_data_packet_size == i_max_data_packet_size */
i_offset += p_demux->p_fp->i_min_data_packet_size -
i_offset % p_demux->p_fp->i_min_data_packet_size;
ASF_SeekAbsolute( p_input, p_demux->i_data_begin + i_offset );
p_demux->i_time = 0;
for( i = 0; i < 128 ; i++ )
{
#define p_stream p_demux->stream[i]
if( p_stream )
{
p_stream->i_time = 0;
}
#undef p_stream
}
p_demux->i_first_pts = -1;
}
for( i = 0; i < 10; i++ ) // parse 10 packets
{
int i_data_packet_min = p_demux->p_fp->i_min_data_packet_size;
uint8_t *p_peek;
int i_skip;
......@@ -666,7 +632,17 @@ static int Demux( input_thread_t *p_input )
/* send complete packet to decoder */
if( p_stream->p_pes->i_pes_size > 0 )
{
input_DecodePES( p_stream->p_es->p_decoder_fifo, p_stream->p_pes );
if( p_stream->p_es->p_decoder_fifo &&
( b_play_audio || p_stream->i_cat != AUDIO_ES ) )
{
input_DecodePES( p_stream->p_es->p_decoder_fifo,
p_stream->p_pes );
}
else
{
input_DeletePES( p_input->p_method_data,
p_stream->p_pes );
}
p_stream->p_pes = NULL;
}
}
......@@ -738,7 +714,7 @@ static int Demux( input_thread_t *p_input )
}
}
continue;
return( 1 );
loop_error_recovery:
msg_Warn( p_input, "unsupported packet header" );
......@@ -749,7 +725,79 @@ loop_error_recovery:
}
ASF_SkipBytes( p_input, i_data_packet_min );
} // loop over packet
return( 1 );
}
static int Demux( input_thread_t *p_input )
{
demux_sys_t *p_demux = p_input->p_demux_data;
vlc_bool_t b_play_audio;
int i;
/* catch seek from user */
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
{
off_t i_offset;
msleep( DEFAULT_PTS_DELAY );
i_offset = ASF_TellAbsolute( p_input ) - p_demux->i_data_begin;
if( i_offset < 0 )
{
i_offset = 0;
}
/* XXX work only when i_min_data_packet_size == i_max_data_packet_size */
i_offset += p_demux->p_fp->i_min_data_packet_size -
i_offset % p_demux->p_fp->i_min_data_packet_size;
ASF_SeekAbsolute( p_input, p_demux->i_data_begin + i_offset );
p_demux->i_time = 0;
for( i = 0; i < 128 ; i++ )
{
#define p_stream p_demux->stream[i]
if( p_stream )
{
p_stream->i_time = 0;
}
#undef p_stream
}
p_demux->i_first_pts = -1;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
if( p_input->stream.control.i_rate == DEFAULT_RATE )
{
b_play_audio = VLC_TRUE;
}
else
{
int i;
b_play_audio = VLC_TRUE;
for( i = 0; i < 128; i++ )
{
if( p_demux->stream[i] &&
p_demux->stream[i]->i_cat == VIDEO_ES &&
p_demux->stream[i]->p_es &&
p_demux->stream[i]->p_es->p_decoder_fifo )
{
/* there is at least ine video track so no need to play audio */
b_play_audio = VLC_FALSE;
}
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
for( i = 0; i < 10; i++ ) // parse 10 packets
{
int i_result;
if( ( i_result = DemuxPacket( p_input, b_play_audio ) ) <= 0 )
{
return i_result;
}
}
p_demux->i_time = -1;
for( i = 0; i < 128 ; i++ )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment