Commit 8a517cbb authored by Laurent Aimar's avatar Laurent Aimar

* avi: no more segfault when we have 'max buffer allocation reached'

* all: fixed(kludged ?) the fact that when we have a 'max buffer allocation reached'
we cannot send null packet to decoder.
parent cc6ee817
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* but exported to plug-ins * but exported to plug-ins
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2002 VideoLAN * Copyright (C) 1999-2002 VideoLAN
* $Id: input_ext-plugins.h,v 1.38 2002/11/12 13:57:12 sam Exp $ * $Id: input_ext-plugins.h,v 1.39 2003/01/25 03:12:20 fenrir Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -62,6 +62,7 @@ VLC_EXPORT( void, input_ExtractPES, ( decoder_fifo_t *, pes_packet_t ** ) ); ...@@ -62,6 +62,7 @@ VLC_EXPORT( void, input_ExtractPES, ( decoder_fifo_t *, pes_packet_t ** ) );
VLC_EXPORT( void, input_FlushPESFifo, ( decoder_fifo_t * ) ); VLC_EXPORT( void, input_FlushPESFifo, ( decoder_fifo_t * ) );
void input_EscapeDiscontinuity( input_thread_t * ); void input_EscapeDiscontinuity( input_thread_t * );
void input_EscapeAudioDiscontinuity( input_thread_t * ); void input_EscapeAudioDiscontinuity( input_thread_t * );
VLC_EXPORT( void, input_NullPacket, ( input_thread_t *, es_descriptor_t * ) );
/***************************************************************************** /*****************************************************************************
* Prototypes from input_clock.c * Prototypes from input_clock.c
...@@ -98,50 +99,8 @@ VLC_EXPORT( int, input_AccessInit, ( input_thread_t * ) ); ...@@ -98,50 +99,8 @@ VLC_EXPORT( int, input_AccessInit, ( input_thread_t * ) );
VLC_EXPORT( void, input_AccessReinit, ( input_thread_t * ) ); VLC_EXPORT( void, input_AccessReinit, ( input_thread_t * ) );
VLC_EXPORT( void, input_AccessEnd, ( input_thread_t * ) ); VLC_EXPORT( void, input_AccessEnd, ( input_thread_t * ) );
/***************************************************************************** /* no need to export this one */
* Create a NULL packet for padding in case of a data loss data_packet_t *input_NewPacketForce( input_buffers_t *, size_t );
*****************************************************************************/
static inline void input_NullPacket( input_thread_t * p_input,
es_descriptor_t * p_es )
{
data_packet_t * p_pad_data;
pes_packet_t * p_pes;
if( (p_pad_data = input_NewPacket( p_input->p_method_data,
PADDING_PACKET_SIZE )) == NULL )
{
msg_Err( p_input, "no new packet" );
p_input->b_error = 1;
return;
}
memset( p_pad_data->p_payload_start, 0, PADDING_PACKET_SIZE );
p_pad_data->b_discard_payload = 1;
p_pes = p_es->p_pes;
if( p_pes != NULL )
{
p_pes->b_discontinuity = 1;
p_pes->p_last->p_next = p_pad_data;
p_pes->p_last = p_pad_data;
p_pes->i_nb_data++;
}
else
{
if( (p_pes = input_NewPES( p_input->p_method_data )) == NULL )
{
msg_Err( p_input, "no PES packet" );
p_input->b_error = 1;
return;
}
p_pes->i_rate = p_input->stream.control.i_rate;
p_pes->p_first = p_pes->p_last = p_pad_data;
p_pes->i_nb_data = 1;
p_pes->b_discontinuity = 1;
input_DecodePES( p_es->p_decoder_fifo, p_pes );
}
}
/* /*
* Optional standard file descriptor operations (input_ext-plugins.h) * Optional standard file descriptor operations (input_ext-plugins.h)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* avi.c : AVI file Stream input module for vlc * avi.c : AVI file Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: avi.c,v 1.29 2003/01/23 15:52:04 sam Exp $ * $Id: avi.c,v 1.30 2003/01/25 03:12:20 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -142,7 +142,20 @@ static int input_ReadInPES( input_thread_t *p_input, ...@@ -142,7 +142,20 @@ static int input_ReadInPES( input_thread_t *p_input,
p_pes->i_pes_size, 2048 ) ); p_pes->i_pes_size, 2048 ) );
if( i_read <= 0 ) if( i_read <= 0 )
{ {
return p_pes->i_pes_size; /* should occur only with EOF and max allocation reached
* it safer to return an error */
/* free all data packet */
for( p_data = p_pes->p_first; p_data != NULL; )
{
data_packet_t *p_next;
p_next = p_data->p_next;
input_DeletePacket( p_input->p_method_data, p_data );
p_data = p_next;
}
/* free pes */
input_DeletePES( p_input->p_method_data, p_pes );
return -1;
} }
if( !p_pes->p_first ) if( !p_pes->p_first )
...@@ -1696,6 +1709,7 @@ static int AVIDemux_Seekable( input_thread_t *p_input ) ...@@ -1696,6 +1709,7 @@ static int AVIDemux_Seekable( input_thread_t *p_input )
demux_sys_t *p_avi = p_input->p_demux_data; demux_sys_t *p_avi = p_input->p_demux_data;
/* detect new selected/unselected streams */ /* detect new selected/unselected streams */
for( i_stream = 0,i_stream_count= 0, b_video = VLC_FALSE; for( i_stream = 0,i_stream_count= 0, b_video = VLC_FALSE;
i_stream < p_avi->i_streams; i_stream++ ) i_stream < p_avi->i_streams; i_stream++ )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_dec.c: Functions for the management of decoders * input_dec.c: Functions for the management of decoders
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: input_dec.c,v 1.56 2003/01/22 10:44:50 fenrir Exp $ * $Id: input_dec.c,v 1.57 2003/01/25 03:12:20 fenrir Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -284,6 +284,52 @@ void input_FlushPESFifo( decoder_fifo_t *p_fifo ) ...@@ -284,6 +284,52 @@ void input_FlushPESFifo( decoder_fifo_t *p_fifo )
vlc_mutex_unlock( &p_fifo->data_lock ); vlc_mutex_unlock( &p_fifo->data_lock );
} }
/*****************************************************************************
* Create a NULL packet for padding in case of a data loss
*****************************************************************************/
void input_NullPacket( input_thread_t * p_input,
es_descriptor_t * p_es )
{
data_packet_t * p_pad_data;
pes_packet_t * p_pes;
if( (p_pad_data = input_NewPacketForce( p_input->p_method_data,
PADDING_PACKET_SIZE)) == NULL )
{
msg_Err( p_input, "no new packet" );
p_input->b_error = 1;
return;
}
memset( p_pad_data->p_payload_start, 0, PADDING_PACKET_SIZE );
p_pad_data->b_discard_payload = 1;
p_pes = p_es->p_pes;
if( p_pes != NULL )
{
p_pes->b_discontinuity = 1;
p_pes->p_last->p_next = p_pad_data;
p_pes->p_last = p_pad_data;
p_pes->i_nb_data++;
}
else
{
if( (p_pes = input_NewPES( p_input->p_method_data )) == NULL )
{
msg_Err( p_input, "no PES packet" );
p_input->b_error = 1;
return;
}
p_pes->i_rate = p_input->stream.control.i_rate;
p_pes->p_first = p_pes->p_last = p_pad_data;
p_pes->i_nb_data = 1;
p_pes->b_discontinuity = 1;
input_DecodePES( p_es->p_decoder_fifo, p_pes );
}
}
/***************************************************************************** /*****************************************************************************
* input_EscapeDiscontinuity: send a NULL packet to the decoders * input_EscapeDiscontinuity: send a NULL packet to the decoders
*****************************************************************************/ *****************************************************************************/
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ext-plugins.c: useful functions for access and demux plug-ins * input_ext-plugins.c: useful functions for access and demux plug-ins
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: input_ext-plugins.c,v 1.26 2002/12/12 11:29:58 massiot Exp $ * $Id: input_ext-plugins.c,v 1.27 2003/01/25 03:12:20 fenrir Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -158,12 +158,13 @@ void input_BuffersEnd( input_thread_t * p_input, input_buffers_t * p_buffers ) ...@@ -158,12 +158,13 @@ void input_BuffersEnd( input_thread_t * p_input, input_buffers_t * p_buffers )
* input_NewBuffer: return a pointer to a data buffer of the appropriate size * input_NewBuffer: return a pointer to a data buffer of the appropriate size
*****************************************************************************/ *****************************************************************************/
static inline data_buffer_t * NewBuffer( input_buffers_t * p_buffers, static inline data_buffer_t * NewBuffer( input_buffers_t * p_buffers,
size_t i_size ) size_t i_size,
vlc_bool_t b_forced )
{ {
data_buffer_t * p_buf; data_buffer_t * p_buf;
/* Safety check */ /* Safety check */
if( p_buffers->i_allocated > INPUT_MAX_ALLOCATION ) if( !b_forced && p_buffers->i_allocated > INPUT_MAX_ALLOCATION )
{ {
return NULL; return NULL;
} }
...@@ -213,7 +214,7 @@ data_buffer_t * input_NewBuffer( input_buffers_t * p_buffers, size_t i_size ) ...@@ -213,7 +214,7 @@ data_buffer_t * input_NewBuffer( input_buffers_t * p_buffers, size_t i_size )
data_buffer_t * p_buf; data_buffer_t * p_buf;
vlc_mutex_lock( &p_buffers->lock ); vlc_mutex_lock( &p_buffers->lock );
p_buf = NewBuffer( p_buffers, i_size ); p_buf = NewBuffer( p_buffers, i_size, VLC_FALSE );
vlc_mutex_unlock( &p_buffers->lock ); vlc_mutex_unlock( &p_buffers->lock );
return p_buf; return p_buf;
...@@ -304,12 +305,13 @@ data_packet_t * input_ShareBuffer( input_buffers_t * p_buffers, ...@@ -304,12 +305,13 @@ data_packet_t * input_ShareBuffer( input_buffers_t * p_buffers,
* input_NewPacket: allocate a packet along with a buffer * input_NewPacket: allocate a packet along with a buffer
*****************************************************************************/ *****************************************************************************/
static inline data_packet_t * NewPacket( input_buffers_t * p_buffers, static inline data_packet_t * NewPacket( input_buffers_t * p_buffers,
size_t i_size ) size_t i_size,
vlc_bool_t b_forced )
{ {
data_buffer_t * p_buf; data_buffer_t * p_buf;
data_packet_t * p_data; data_packet_t * p_data;
p_buf = NewBuffer( p_buffers, i_size ); p_buf = NewBuffer( p_buffers, i_size, b_forced );
if( p_buf == NULL ) if( p_buf == NULL )
{ {
...@@ -329,7 +331,18 @@ data_packet_t * input_NewPacket( input_buffers_t * p_buffers, size_t i_size ) ...@@ -329,7 +331,18 @@ data_packet_t * input_NewPacket( input_buffers_t * p_buffers, size_t i_size )
data_packet_t * p_data; data_packet_t * p_data;
vlc_mutex_lock( &p_buffers->lock ); vlc_mutex_lock( &p_buffers->lock );
p_data = NewPacket( p_buffers, i_size ); p_data = NewPacket( p_buffers, i_size, VLC_FALSE );
vlc_mutex_unlock( &p_buffers->lock );
return p_data;
}
data_packet_t * input_NewPacketForce( input_buffers_t * p_buffers, size_t i_size )
{
data_packet_t * p_data;
vlc_mutex_lock( &p_buffers->lock );
p_data = NewPacket( p_buffers, i_size, VLC_TRUE);
vlc_mutex_unlock( &p_buffers->lock ); vlc_mutex_unlock( &p_buffers->lock );
return p_data; return p_data;
...@@ -476,7 +489,7 @@ ssize_t input_FillBuffer( input_thread_t * p_input ) ...@@ -476,7 +489,7 @@ ssize_t input_FillBuffer( input_thread_t * p_input )
vlc_mutex_lock( &p_input->p_method_data->lock ); vlc_mutex_lock( &p_input->p_method_data->lock );
p_buf = NewBuffer( p_input->p_method_data, p_buf = NewBuffer( p_input->p_method_data,
i_remains + p_input->i_bufsize ); i_remains + p_input->i_bufsize, VLC_FALSE );
if( p_buf == NULL ) if( p_buf == NULL )
{ {
vlc_mutex_unlock( &p_input->p_method_data->lock ); vlc_mutex_unlock( &p_input->p_method_data->lock );
......
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