]> git.sesse.net Git - vlc/commitdiff
* ./plugins/mpeg_vdec/vpar_headers.c: we no longer crash when the next
authorSam Hocevar <sam@videolan.org>
Wed, 27 Feb 2002 22:57:10 +0000 (22:57 +0000)
committerSam Hocevar <sam@videolan.org>
Wed, 27 Feb 2002 22:57:10 +0000 (22:57 +0000)
    stream doesn't have the same image size as the previous one.
  * ./src/audio_output/aout_pcm.c: another overrun fix; please test.

include/config.h
plugins/fx/scope.c
plugins/mpeg_vdec/vpar_headers.c
src/audio_output/aout_pcm.c
src/audio_output/aout_spdif.c
src/audio_output/audio_output.c

index f115d792727c9265e18158c173262f6ae85266a1..d95e5417fea1de7208dcfc79a1e4935eee1fdfe0 100644 (file)
 /* Number of audio output frames contained in an audio output fifo.
  * (AOUT_FIFO_SIZE + 1) must be a power of 2, in order to optimise the
  * %(AOUT_FIFO_SIZE + 1) operation with an &AOUT_FIFO_SIZE.
- * With 511 we have at least 511*384/2/48000=2 seconds of sound */
-#define AOUT_FIFO_SIZE                  511
+ * With 255 we have at least 255*384/2/48000=1 second of sound */
+#define AOUT_FIFO_SIZE                  255
 
 /* Maximum number of audio fifos. The value of AOUT_MAX_FIFOS should be a power
  * of two, in order to optimize the '/AOUT_MAX_FIFOS' and '*AOUT_MAX_FIFOS'
  * - short, in order to be able to play a new song very quickly (especially a
  *   song from the interface)
  * - long, in order to perform the buffer calculations as few as possible */
-#define AOUT_BUFFER_DURATION            100000
+#define AOUT_BUFFER_DURATION            50000
 
 /*****************************************************************************
  * Video configuration
index 3384dcb782930be45a4f07ba9a2f2e7f297bc222..e9dbf10d8b5efc843c6f725dfff10021afa017d5 100644 (file)
@@ -2,7 +2,7 @@
  * scope.c : Scope effect module
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: scope.c,v 1.1 2002/02/25 04:30:03 sam Exp $
+ * $Id: scope.c,v 1.2 2002/02/27 22:57:10 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -52,7 +52,9 @@ static void aout_getfunctions( function_list_t * p_function_list );
  *****************************************************************************/
 typedef struct aout_sys_s
 {
-    struct aout_fifo_s *p_aout_fifo; /* XXX: unused yet */
+    struct aout_thread_s aout;
+    struct aout_fifo_s *p_aout_fifo;
+
     struct vout_thread_s *p_vout;
 
 } aout_sys_t;
@@ -128,6 +130,10 @@ static int aout_SetFormat( aout_thread_t *p_aout )
     p_aout->i_format = AOUT_FMT_U16_LE;
     p_aout->i_channels = 2;
 
+    p_aout->p_sys->aout.i_format = p_aout->i_format;
+    p_aout->p_sys->aout.i_channels = p_aout->i_channels;
+    p_aout->p_sys->aout.i_rate = p_aout->i_rate;
+
     return( 0 );
 }
 
index e2649ebcf5b64d28c79792831d0fceea8633b7de..3dbf36e5e2914206125b868356e59300f0c2f4f0 100644 (file)
@@ -2,7 +2,7 @@
  * vpar_headers.c : headers parsing
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: vpar_headers.c,v 1.14 2002/02/19 00:50:19 sam Exp $
+ * $Id: vpar_headers.c,v 1.15 2002/02/27 22:57:10 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Stéphane Borel <stef@via.ecp.fr>
@@ -489,6 +489,33 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
     /* Spawn a video output if there is none */
     vlc_mutex_lock( &p_vout_bank->lock );
     
+    if( p_vout_bank->i_count != 0 )
+    {
+        /* Take the first video output FIXME: take the best one */
+        p_vpar->p_vout = p_vout_bank->pp_vout[ 0 ];
+
+        if( p_vpar->p_vout->render.i_width != p_vpar->sequence.i_width
+             || p_vpar->p_vout->render.i_height != p_vpar->sequence.i_height
+             || p_vpar->p_vout->render.i_chroma != ChromaToFourCC( p_vpar->sequence.i_chroma_format )
+             || p_vpar->p_vout->render.i_aspect != p_vpar->sequence.i_aspect )
+        {
+            p_vout_bank->pp_vout[ 0 ] = NULL;
+            p_vout_bank->i_count--;
+            vlc_mutex_unlock( &p_vout_bank->lock );
+            vout_DestroyThread( p_vpar->p_vout, NULL );
+            vlc_mutex_lock( &p_vout_bank->lock );
+
+            /* XXX: race condition here if p_vout_bank->i_count was updated */
+            if( p_vout_bank->i_count )
+            {
+                vlc_mutex_unlock( &p_vout_bank->lock );
+                intf_ErrMsg( "vpar error: can't open vout, aborting" );
+                p_vpar->p_fifo->b_error = 1;
+                return;
+            }
+        }
+    }
+
     if( p_vout_bank->i_count == 0 )
     {
         intf_WarnMsg( 1, "vpar: no vout present, spawning one" );
@@ -514,11 +541,6 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
         p_vout_bank->pp_vout[ p_vout_bank->i_count ] = p_vpar->p_vout;
         p_vout_bank->i_count++;
     }
-    else
-    {
-        /* Take the first video output FIXME: take the best one */
-        p_vpar->p_vout = p_vout_bank->pp_vout[ 0 ];
-    }
 
     vlc_mutex_unlock( &p_vout_bank->lock );
 }
index f7c9f5f1c12bca67181809802a04794221b7911f..3393d1879343a3cc74431e641e0eee7cb51743fa 100644 (file)
@@ -2,7 +2,7 @@
  * aout_pcm.c: PCM audio output functions
  *****************************************************************************
  * Copyright (C) 1999-2002 VideoLAN
- * $Id: aout_pcm.c,v 1.1 2002/02/24 22:06:50 sam Exp $
+ * $Id: aout_pcm.c,v 1.2 2002/02/27 22:57:10 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Cyril Deguet <asmax@via.ecp.fr>
@@ -51,7 +51,7 @@ static int  NextFrame ( aout_thread_t * p_aout, aout_fifo_t * p_fifo,
 void aout_PCMThread( aout_thread_t * p_aout )
 {
     int i_fifo;
-    int i_buffer, i_buffer_limit, i_bytes;
+    int i_buffer, i_buffer_limit, i_units = 0;
 
     /* As the s32_buffer was created with calloc(), we don't have to set this
      * memory to zero and we can immediately jump into the thread's loop */
@@ -118,13 +118,13 @@ void aout_PCMThread( aout_thread_t * p_aout )
             break;
         }
 
-        i_bytes = p_aout->pf_getbufinfo( p_aout, i_buffer_limit );
-
         switch ( p_aout->i_format )
         {
         case AOUT_FMT_U8:
         case AOUT_FMT_S8:
-            p_aout->date = mdate() + ((((mtime_t)((i_bytes + 4 *
+            i_units = p_aout->pf_getbufinfo( p_aout, i_buffer_limit );
+
+            p_aout->date = mdate() + ((((mtime_t)((i_units + 4 *
                 p_aout->i_latency) / p_aout->i_channels)) * 1000000) /
                 ((mtime_t)p_aout->i_rate)) + p_main->i_desync;
 
@@ -136,7 +136,9 @@ void aout_PCMThread( aout_thread_t * p_aout )
         case AOUT_FMT_U16_BE:
         case AOUT_FMT_S16_LE:
         case AOUT_FMT_S16_BE:
-            p_aout->date = mdate() + ((((mtime_t)((i_bytes + 4 *
+            i_units = p_aout->pf_getbufinfo( p_aout, i_buffer_limit * 2 ) / 2;
+
+            p_aout->date = mdate() + ((((mtime_t)((i_units + 4 *
                 p_aout->i_latency) / (2 * p_aout->i_channels))) * 1000000) /
                 ((mtime_t)p_aout->i_rate)) + p_main->i_desync;
 
@@ -145,7 +147,7 @@ void aout_PCMThread( aout_thread_t * p_aout )
             break;
         }
 
-        if ( i_bytes > i_buffer_limit )
+        if ( i_units > i_buffer_limit )
         {
             msleep( p_aout->i_msleep );
         }
index e5fdff758949368f35fa4e35be1f79dfaf388aee..f66d9f2a94dd960b999f9b147445baa1c8dfb36c 100644 (file)
@@ -2,7 +2,7 @@
  * aout_spdif.c: AC3 passthrough output
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: aout_spdif.c,v 1.23 2002/02/24 22:06:50 sam Exp $
+ * $Id: aout_spdif.c,v 1.24 2002/02/27 22:57:10 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Stéphane Borel <stef@via.ecp.fr>
@@ -55,9 +55,9 @@ void aout_SpdifThread( aout_thread_t * p_aout )
     {
         for( i_fifo = 0 ; i_fifo < AOUT_MAX_FIFOS ; i_fifo++ )
         {
-            /* the loop read each fifo so that we can change the stream
+            /* The loop reads each fifo so that we can change the stream
              * on the fly but mulitplexing is not handled yet so
-             * the sound will be broken is more than one fifo has data */ 
+             * the sound will be broken if more than one fifo has data */ 
             /* TODO: write the muliplexer :) */
             if( p_aout->fifo[i_fifo].i_format == AOUT_FIFO_SPDIF )
             {
@@ -93,7 +93,7 @@ void aout_SpdifThread( aout_thread_t * p_aout )
 
                     vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
 
-                    /* play spdif frame to the external decoder 
+                    /* Play spdif frame to the external decoder 
                      * the kernel driver will sleep until the
                      * dsp buffer is empty enough to accept the data */
                     if( m_play > ( mdate() - m_frame_time ) )
index 8c41bca88ef81be17038f847a3a75b787520e248..825778883e33f87efe5b32e4d2d52336f2c039b5 100644 (file)
@@ -2,7 +2,7 @@
  * audio_output.c : audio output thread
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: audio_output.c,v 1.79 2002/02/26 18:25:40 gbazin Exp $
+ * $Id: audio_output.c,v 1.80 2002/02/27 22:57:10 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Cyril Deguet <asmax@via.ecp.fr>
@@ -193,8 +193,8 @@ static int aout_SpawnThread( aout_thread_t * p_aout )
     /* Compute the size (in audio units) of the audio output buffer. Although
      * AOUT_BUFFER_DURATION is given in microseconds, the output rate is given
      * in Hz, that's why we need to divide by 10^6 microseconds (1 second) */
-    p_aout->i_units = ((s64)p_aout->i_rate * AOUT_BUFFER_DURATION) / 1000000;
-    p_aout->i_msleep = AOUT_BUFFER_DURATION / 4;
+    p_aout->i_units = (s64)p_aout->i_rate * AOUT_BUFFER_DURATION / 1000000;
+    p_aout->i_msleep = AOUT_BUFFER_DURATION;
 
     /* Make pf_aout_thread point to the right thread function, and compute the
      * byte size of the audio output buffer */