]> git.sesse.net Git - vlc/commitdiff
* ./include/inpu_ext-dec.h added a check to fifo->b_die after the call
authorGildas Bazin <gbazin@videolan.org>
Fri, 24 May 2002 12:42:14 +0000 (12:42 +0000)
committerGildas Bazin <gbazin@videolan.org>
Fri, 24 May 2002 12:42:14 +0000 (12:42 +0000)
to BitstreamNextDataPacket() in GetChunk().
Code using GetChunk() also needs to check fifo->b_die before using the
obtained data.
This fixes frequent crashes you get on win32 with the a52 plugin when you
close a stream.

include/input_ext-dec.h
plugins/a52/a52.c
plugins/ac3_spdif/ac3_spdif.c
plugins/lpcm_adec/lpcm_adec.c
plugins/spudec/spu_decoder.c

index c643472646d390cf447ddaf252255235552e72fe..9851ed8ece8ba283e7289edfd46af866c3423ad2 100644 (file)
@@ -2,7 +2,7 @@
  * input_ext-dec.h: structures exported to the VideoLAN decoders
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: input_ext-dec.h,v 1.58 2002/05/18 17:47:46 sam Exp $
+ * $Id: input_ext-dec.h,v 1.59 2002/05/24 12:42:14 gbazin Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Michel Kaempf <maxx@via.ecp.fr>
@@ -505,9 +505,11 @@ static inline void GetChunk( bit_stream_t * p_bit_stream,
             p_buffer += i_available;
             i_buf_len -= i_available;
             BitstreamNextDataPacket( p_bit_stream );
+            if( p_bit_stream->p_decoder_fifo->b_die )
+                return;
         }
         while( (i_available = p_bit_stream->p_end - p_bit_stream->p_byte)
-                <= i_buf_len && !p_bit_stream->p_decoder_fifo->b_die );
+                <= i_buf_len );
 
         if( i_buf_len )
         {
index 55ca6a2ee34e8ffe29a23568f762881b195fed2b..cde0a85d672054acfc9043c59ad8d833d782d68f 100644 (file)
@@ -4,7 +4,7 @@
  *   (http://liba52.sf.net/).
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: a52.c,v 1.11 2002/05/20 15:03:32 gbazin Exp $
+ * $Id: a52.c,v 1.12 2002/05/24 12:42:14 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *      
@@ -158,6 +158,7 @@ static int decoder_Run ( decoder_config_t *p_config )
 
         /* get a52 frame header */
         GetChunk( &p_a52_adec->bit_stream, p_a52_adec->p_frame_buffer, 7 );
+       if( p_a52_adec->p_fifo->b_die ) break;
 
         /* check if frame is valid and get frame info */
         p_a52_adec->frame_size = a52_syncinfo( p_a52_adec->p_frame_buffer,
@@ -171,7 +172,7 @@ static int decoder_Run ( decoder_config_t *p_config )
             continue;
         }
 
-        if( DecodeFrame( p_a52_adec ) )
+        if( DecodeFrame( p_a52_adec ) && !p_a52_adec->p_fifo->b_die )
         {
             DecoderError( p_config->p_decoder_fifo );
             free( p_a52_adec );
@@ -240,9 +241,9 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec )
     }
 
     /* Creating the audio output fifo if not created yet */
-    if (p_a52_adec->p_aout_fifo == NULL )
+    ifp_a52_adec->p_aout_fifo == NULL )
     {
-        p_a52_adec->p_aout_fifo = aout_CreateFifo( AOUT_FIFO_PCM, 
+        p_a52_adec->p_aout_fifo = aout_CreateFifo( AOUT_FIFO_PCM,
                                     p_a52_adec->i_channels,
                                     p_a52_adec->sample_rate,
                                     AC3DEC_FRAME_SIZE * p_a52_adec->i_channels,
@@ -279,6 +280,7 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec )
     /* Get the complete frame */
     GetChunk( &p_a52_adec->bit_stream, p_a52_adec->p_frame_buffer + 7,
               p_a52_adec->frame_size - 7 );
+    if( p_a52_adec->p_fifo->b_die ) return( -1 );
 
     /* do the actual decoding now */
     a52_frame( p_a52_adec->p_a52_state, p_a52_adec->p_frame_buffer,
index 9f36401bc3d32805d2fd2859356b486770dfd11a..a68848ba49a9930f00be97731a8a1f3cf9995a36 100644 (file)
@@ -2,7 +2,7 @@
  * ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: ac3_spdif.c,v 1.24 2002/05/17 18:01:25 stef Exp $
+ * $Id: ac3_spdif.c,v 1.25 2002/05/24 12:42:14 gbazin Exp $
  *
  * Authors: Stéphane Borel <stef@via.ecp.fr>
  *          Juha Yrjola <jyrjola@cc.hut.fi>
@@ -406,6 +406,8 @@ int ac3_parse_syncinfo( ac3_spdif_thread_t *p_spdif )
     /* Read sync frame */
     GetChunk( &p_spdif->bit_stream, p_spdif->p_ac3 + 2,
               sizeof(sync_frame_t) - 2 );
+    if( p_spdif->p_fifo->b_die ) return -1;
+
     p_sync_frame = (sync_frame_t*)p_spdif->p_ac3;
 
     /* Compute frame rate */
index ef1a782eda0179d1cc1374d47a19f22dcd572db5..2e1f4647508ae3a5981e18a216eba32fe27b5497 100644 (file)
@@ -2,7 +2,7 @@
  * lpcm_decoder_thread.c: lpcm decoder thread
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: lpcm_adec.c,v 1.14 2002/04/19 13:56:11 sam Exp $
+ * $Id: lpcm_adec.c,v 1.15 2002/05/24 12:42:14 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Henri Fallon <henri@videolan.org>
@@ -191,7 +191,8 @@ void DecodeFrame( lpcmdec_thread_t * p_lpcmdec )
     }
     
     GetChunk( &p_lpcmdec->bit_stream, p_temp, LPCMDEC_FRAME_SIZE);
-    
+    if( p_lpcmdec->p_fifo->b_die ) return;
+
     for( i_loop = 0; i_loop < LPCMDEC_FRAME_SIZE/2; i_loop++ )
     {
         buffer[2*i_loop]=p_temp[2*i_loop+1];
index 9303ba4190356e1362055e26f7bf17cc1fc7dc37..58893d737fbb18cbdfe6e6b45645f03b1d6c69bf 100644 (file)
@@ -2,7 +2,7 @@
  * spu_decoder.c : spu decoder thread
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: spu_decoder.c,v 1.23 2002/05/19 15:50:02 stef Exp $
+ * $Id: spu_decoder.c,v 1.24 2002/05/24 12:42:14 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Rudolf Cornelissen <rag.cornelissen@inter.nl.net>
@@ -320,11 +320,12 @@ static void ParsePacket( spudec_thread_t *p_spudec )
     }
 
     /* Get RLE data */
-    for( i_offset = 0;
-         i_offset + SPU_CHUNK_SIZE < p_spudec->i_rle_size;
+    for( i_offset = 0; i_offset < p_spudec->i_rle_size;
          i_offset += SPU_CHUNK_SIZE )
     {
-        GetChunk( &p_spudec->bit_stream, p_src + i_offset, SPU_CHUNK_SIZE );
+        GetChunk( &p_spudec->bit_stream, p_src + i_offset,
+                  ( i_offset + SPU_CHUNK_SIZE < p_spudec->i_rle_size ) ?
+                  SPU_CHUNK_SIZE : p_spudec->i_rle_size - i_offset );
 
         /* Abort subtitle parsing if we were requested to stop */
         if( p_spudec->p_fifo->b_die )
@@ -335,9 +336,6 @@ static void ParsePacket( spudec_thread_t *p_spudec )
         }
     }
 
-    GetChunk( &p_spudec->bit_stream, p_src + i_offset,
-              p_spudec->i_rle_size - i_offset );
-
 #if 0
     /* Dump the subtitle info */
     intf_WarnHexDump( 5, p_spu->p_sys->p_data, p_spudec->i_rle_size );
@@ -1202,4 +1200,3 @@ static void RenderSPU( const vout_thread_t *p_vout, picture_t *p_pic,
         break;
     }
 }
-