]> git.sesse.net Git - vlc/commitdiff
* demuxes: Worked around a bug in old VLC and VLS by changing TS stream types
authorChristophe Massiot <massiot@videolan.org>
Fri, 30 Aug 2002 22:22:24 +0000 (22:22 +0000)
committerChristophe Massiot <massiot@videolan.org>
Fri, 30 Aug 2002 22:22:24 +0000 (22:22 +0000)
  (see my last mail).
* aout: Rewrote our whole lock policy. The output thread now doesn't require
  the mixer_lock, which might avoid delays. We will also be able to change
  the filter pipelines at runtime.

23 files changed:
include/aout_internal.h
include/input_ext-dec.h
include/vlc_common.h
modules/access/dvd/es.c
modules/access/dvdplay/es.c
modules/access/dvdread/input.c
modules/audio_output/file.c
modules/audio_output/sdl.c
modules/codec/a52.c
modules/codec/a52old/a52old.c
modules/codec/lpcm/lpcm.c
modules/codec/spdif.c
modules/codec/spudec/spudec.c
modules/demux/mpeg/ps.c
modules/demux/mpeg/system.c
modules/demux/mpeg/system.h
modules/demux/mpeg/ts.c
modules/misc/dummy/aout.c
src/audio_output/audio_output.c
src/audio_output/filters.c
src/audio_output/input.c
src/audio_output/mixer.c
src/audio_output/output.c

index 5c4214ae86f315cc6c4a2ad79586396ed1628af3..ab69b7acba5825c7e8a9cbb40a801d69dd1a4dcd 100644 (file)
@@ -2,7 +2,7 @@
  * aout_internal.h : internal defines for audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: aout_internal.h,v 1.12 2002/08/25 09:39:59 sam Exp $
+ * $Id: aout_internal.h,v 1.13 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -126,6 +126,10 @@ typedef struct aout_mixer_t
  *****************************************************************************/
 struct aout_input_t
 {
+    /* When this lock is taken, the pipeline cannot be changed by a
+     * third-party. */
+    vlc_mutex_t             lock;
+
     audio_sample_format_t   input;
     aout_alloc_t            input_alloc;
 
@@ -166,16 +170,26 @@ struct aout_instance_t
 {
     VLC_COMMON_MEMBERS
 
+    /* Locks : please note that if you need several of these locks, it is
+     * mandatory (to avoid deadlocks) to take them in the following order :
+     * p_input->lock, mixer_lock, output_fifo_lock, input_fifo_lock.
+     * --Meuuh */
+    /* When input_fifos_lock is taken, none of the p_input->fifo structures
+     * can be read or modified by a third-party thread. */
+    vlc_mutex_t             input_fifos_lock;
+    /* When mixer_lock is taken, all decoder threads willing to mix a
+     * buffer must wait until it is released. The output pipeline cannot
+     * be modified. No input stream can be added or removed. */
+    vlc_mutex_t             mixer_lock;
+    /* When output_fifo_lock is taken, the p_aout->output.fifo structure
+     * cannot be read or written  by a third-party thread. */
+    vlc_mutex_t             output_fifo_lock;
+
     /* Input streams & pre-filters */
-    vlc_mutex_t             input_lock;
-    vlc_cond_t              input_signal;
-    int                     i_inputs_active;
-    vlc_bool_t              b_change_requested;
     aout_input_t *          pp_inputs[AOUT_MAX_INPUTS];
     int                     i_nb_inputs;
 
     /* Mixer */
-    vlc_mutex_t             mixer_lock;
     aout_mixer_t            mixer;
 
     /* Output plug-in */
index eaba3b9d22129a493f87d0b30ab9797602458ae8..e297519c92534f5b28abb05469595ec4dbc6b971 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.70 2002/08/26 23:00:22 massiot Exp $
+ * $Id: input_ext-dec.h,v 1.71 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Michel Kaempf <maxx@via.ecp.fr>
 #ifndef _VLC_INPUT_EXT_DEC_H
 #define _VLC_INPUT_EXT_DEC_H 1
 
-/* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers.
- * these values are used in src/input/mpeg_system.c, and in
- * the following plugins: mpeg_ts, mpeg_ts_dvbpsi, input_satellite. */
-#define MPEG1_VIDEO_ES      0x01
-#define MPEG2_VIDEO_ES      0x02
-#define MPEG1_AUDIO_ES      0x03
-#define MPEG2_AUDIO_ES      0x04
-#define A52_AUDIO_ES        0x81
-/* These ones might violate the norm : */
-#define DVD_SPU_ES          0x82
-#define LPCM_AUDIO_ES       0x83
-
 /* Structures exported to the decoders */
 
 /*****************************************************************************
index cae6d407481ec14e799995e2af40a4853364c783..3432149a5ebcc3677242ea0133428a2f48c08ae8 100644 (file)
@@ -3,7 +3,7 @@
  * Collection of useful common types and macros definitions
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vlc_common.h,v 1.25 2002/08/29 23:53:22 massiot Exp $
+ * $Id: vlc_common.h,v 1.26 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Samuel Hocevar <sam@via.ecp.fr>
  *          Vincent Seguin <seguin@via.ecp.fr>
@@ -133,11 +133,19 @@ typedef s64 mtime_t;
  *****************************************************************************/
 typedef u32 vlc_fourcc_t;
 
-#define VLC_FOURCC( a, b, c, d ) \
-    ( ((u32)a) | ( ((u32)b) << 8 ) | ( ((u32)c) << 16 ) | ( ((u32)d) << 24 ) )
+#ifdef WORDS_BIGENDIAN
+#   define VLC_FOURCC( a, b, c, d ) \
+        ( ((u32)d) | ( ((u32)c) << 8 ) | ( ((u32)b) << 16 ) | ( ((u32)a) << 24 ) )
+#   define VLC_TWOCC( a, b ) \
+        ( (u16)(b) | ( (u16)(a) << 8 ) )
 
-#define VLC_TWOCC( a, b ) \
-    ( (u16)(a) | ( (u16)(b) << 8 ) )
+#else
+#   define VLC_FOURCC( a, b, c, d ) \
+        ( ((u32)a) | ( ((u32)b) << 8 ) | ( ((u32)c) << 16 ) | ( ((u32)d) << 24 ) )
+#   define VLC_TWOCC( a, b ) \
+        ( (u16)(a) | ( (u16)(b) << 8 ) )
+
+#endif
 
 /*****************************************************************************
  * Classes declaration
index baf7df9132af9c6d616a41687b6850bb66ac569d..60e09cd85c59e772dcf81a03e911b264900f3307 100644 (file)
@@ -1,7 +1,7 @@
 /* es.c: functions to find and select ES
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: es.c,v 1.1 2002/08/04 17:23:41 sam Exp $
+ * $Id: es.c,v 1.2 2002/08/30 22:22:24 massiot Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -137,7 +137,7 @@ void DVDReadAudio( input_thread_t * p_input )
             {
             case 0x00:              /* A52 */
                 ADDES( 0xbd, 0x80 + audio_status.i_position,
-                       VLC_FOURCC('a','5','2',' '), AUDIO_ES, i_lang, 0 );
+                       VLC_FOURCC('a','5','2','b'), AUDIO_ES, i_lang, 0 );
                 strcat( p_es->psz_desc, " (A52)" );
 
                 break;
@@ -150,13 +150,15 @@ void DVDReadAudio( input_thread_t * p_input )
                 break;
             case 0x04:              /* LPCM */
                 ADDES( 0xbd, 0xa0 + audio_status.i_position,
-                       VLC_FOURCC('l','p','c','m'), AUDIO_ES, i_lang, 0 );
+                       VLC_FOURCC('l','p','c','b'), AUDIO_ES, i_lang, 0 );
                 strcat( p_es->psz_desc, " (lpcm)" );
 
                 break;
             case 0x06:              /* DTS */
-                i_id = ( ( 0x88 + audio_status.i_position ) << 8 ) | 0xbd;
-                msg_Err( p_input, "DTS audio not handled yet (0x%x)", i_id );
+                ADDES( 0xbd, 0x88 + audio_status.i_position,
+                       VLC_FOURCC('d','t','s','b'), AUDIO_ES, i_lang, 0 );
+                strcat( p_es->psz_desc, " (dts)" );
+
                 break;
             default:
                 i_id = 0;
@@ -219,7 +221,7 @@ void DVDReadSPU( input_thread_t * p_input )
 
             if( vmg.title.pi_yuv_color )
             {
-                ADDES( 0xbd, 0x20 + i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
+                ADDES( 0xbd, 0x20 + i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
                        vts.manager_inf.p_spu_attr[i-1].i_lang_code,
                        sizeof(int) + 16*sizeof(u32) );
                 *(int*)p_es->p_demux_data = 0xBeeF;
@@ -228,7 +230,7 @@ void DVDReadSPU( input_thread_t * p_input )
             }
             else
             {
-                ADDES( 0xbd, 0x20 + i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
+                ADDES( 0xbd, 0x20 + i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
                    vts.manager_inf.p_spu_attr[i-1].i_lang_code, 0 );
             }
         }
@@ -273,13 +275,13 @@ void DVDLaunchDecoders( input_thread_t * p_input )
         {
             int     i_a52 = i_audio;
             while( ( p_input->stream.pp_es[i_a52]->i_fourcc !=
-                     VLC_FOURCC('a','5','2',' ') ) && ( i_a52 <=
+                     VLC_FOURCC('a','5','2','b') ) && ( i_a52 <=
                      p_dvd->p_ifo->vts.manager_inf.i_audio_nb ) )
             {
                 i_a52++;
             }
             if( p_input->stream.pp_es[i_a52]->i_fourcc
-                 == VLC_FOURCC('a','5','2',' ') )
+                 == VLC_FOURCC('a','5','2','b') )
             {
                 input_SelectES( p_input,
                                 p_input->stream.pp_es[i_a52] );
@@ -308,7 +310,7 @@ void DVDLaunchDecoders( input_thread_t * p_input )
             for( i = 0; i < p_input->stream.i_es_number; i++ )
             {
                 if ( p_input->stream.pp_es[i]->i_fourcc
-                      == VLC_FOURCC('s','p','u',' ') )
+                      == VLC_FOURCC('s','p','u','b') )
                 {
                     j++;
                     if ( i_spu == j ) break;
index 6e565c7f45dc41d5b333cd89a56774b0a5e0346e..a8640b0188e73ba81ede95eeb9e419ba97e8a0c8 100644 (file)
@@ -2,7 +2,7 @@
  * es.c: functions to handle elementary streams.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: es.c,v 1.2 2002/08/07 00:29:36 sam Exp $
+ * $Id: es.c,v 1.3 2002/08/30 22:22:24 massiot Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -143,7 +143,7 @@ void dvdplay_Audio( input_thread_t * p_input )
             switch( p_attr->audio_format )
             {
             case 0x00:              /* A52 */
-                ADDES( i_id, VLC_FOURCC('a','5','2',' '), AUDIO_ES, i_lang, 0 );
+                ADDES( i_id, VLC_FOURCC('a','5','2','b'), AUDIO_ES, i_lang, 0 );
                 strcat( p_es->psz_desc, " (A52)" );
 
                 break;
@@ -154,16 +154,19 @@ void dvdplay_Audio( input_thread_t * p_input )
 
                 break;
             case 0x04:              /* LPCM */
-                ADDES( i_id, VLC_FOURCC('l','p','c','m'), AUDIO_ES, i_lang, 0 );
+                ADDES( i_id, VLC_FOURCC('l','p','c','b'), AUDIO_ES, i_lang, 0 );
                 strcat( p_es->psz_desc, " (lpcm)" );
 
                 break;
             case 0x05:              /* SDDS */
-                msg_Warn( p_input, "SDDS audio not handled" );
+                ADDES( i_id, VLC_FOURCC('s','d','d','b'), AUDIO_ES, i_lang, 0 );
+                strcat( p_es->psz_desc, " (sdds)" );
+
                 break;
             case 0x06:              /* DTS */
-                msg_Warn( p_input, "DTS audio not handled yet"
-                             "(0x%x)", i_id );
+                ADDES( i_id, VLC_FOURCC('d','t','s','b'), AUDIO_ES, i_lang, 0 );
+                strcat( p_es->psz_desc, " (dts)" );
+
                 break;
             default:
                 i_id = 0;
@@ -203,7 +206,7 @@ void dvdplay_Subp( input_thread_t * p_input )
             
             if( pi_palette )
             {
-                ADDES( i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
+                ADDES( i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
                        p_attr->lang_code, sizeof(int) + 16*sizeof(u32) );
                 *(int*)p_es->p_demux_data = 0xBeeF;
                 memcpy( (void*)p_es->p_demux_data + sizeof(int),
@@ -211,7 +214,7 @@ void dvdplay_Subp( input_thread_t * p_input )
             }
             else
             {
-                ADDES( i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
+                ADDES( i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
                        p_attr->lang_code, 0 );
             }
         }
@@ -250,12 +253,12 @@ void dvdplay_LaunchDecoders( input_thread_t * p_input )
             
             while( ( i_a52 < p_dvd->i_audio_nb ) &&
                    ( p_input->stream.pp_es[i_a52]->i_fourcc !=
-                        VLC_FOURCC('a','5','2',' ') ) )
+                        VLC_FOURCC('a','5','2','b') ) )
             {
                 i_a52++;
             }
             if( p_input->stream.pp_es[i_a52]->i_fourcc ==
-                    VLC_FOURCC('a','5','2',' ') )
+                    VLC_FOURCC('a','5','2','b') )
             {
                 input_SelectES( p_input,
                                 p_input->stream.pp_es[i_a52] );
index bcec9e62fe6ec43b154320bc9e2bae1c182e4496..9c956c91d504184e2bb30c74329e169bdf3a5978 100644 (file)
@@ -6,7 +6,7 @@
  * It depends on: libdvdread for ifo files and block reading.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: input.c,v 1.3 2002/08/29 23:53:22 massiot Exp $
+ * $Id: input.c,v 1.4 2002/08/30 22:22:24 massiot Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -679,7 +679,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area )
                     i_id = ( ( 0x80 + i_position ) << 8 ) | 0xbd;
                     p_es = input_AddES( p_input, NULL, i_id, 0 );
                     p_es->i_stream_id = 0xbd;
-                    p_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+                    p_es->i_fourcc = VLC_FOURCC('a','5','2','b');
                     p_es->i_cat = AUDIO_ES;
                     strcpy( p_es->psz_desc, DecodeLanguage(
                         p_vts->vtsi_mat->vts_audio_attr[i-1].lang_code ) ); 
@@ -703,7 +703,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area )
                     i_id = ( ( 0xa0 + i_position ) << 8 ) | 0xbd;
                     p_es = input_AddES( p_input, NULL, i_id, 0 );
                     p_es->i_stream_id = i_id;
-                    p_es->i_fourcc = VLC_FOURCC('l','p','c','m');
+                    p_es->i_fourcc = VLC_FOURCC('l','p','c','b');
                     p_es->i_cat = AUDIO_ES;
                     strcpy( p_es->psz_desc, DecodeLanguage(
                         p_vts->vtsi_mat->vts_audio_attr[i-1].lang_code ) ); 
@@ -766,7 +766,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area )
                 i_id = ( ( 0x20 + i_position ) << 8 ) | 0xbd;
                 p_es = input_AddES( p_input, NULL, i_id, 0 );
                 p_es->i_stream_id = 0xbd;
-                p_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+                p_es->i_fourcc = VLC_FOURCC('s','p','u','b');
                 p_es->i_cat = SPU_ES;
                 strcpy( p_es->psz_desc, DecodeLanguage(
                     p_vts->vtsi_mat->vts_subp_attr[i-1].lang_code ) ); 
@@ -1226,13 +1226,13 @@ static void DvdReadLauchDecoders( input_thread_t * p_input )
             {
                 int     i_a52 = i_audio;
                 while( ( p_input->stream.pp_es[i_a52]->i_fourcc !=
-                       VLC_FOURCC('a','5','2',' ') ) && ( i_a52 <=
+                       VLC_FOURCC('a','5','2','b') ) && ( i_a52 <=
                        p_dvd->p_vts_file->vtsi_mat->nr_of_vts_audio_streams ) )
                 {
                     i_a52++;
                 }
                 if( p_input->stream.pp_es[i_a52]->i_fourcc
-                     == VLC_FOURCC('a','5','2',' ') )
+                     == VLC_FOURCC('a','5','2','b') )
                 {
                     input_SelectES( p_input,
                                     p_input->stream.pp_es[i_a52] );
index ba86ad2183e08fa41ddc6a33458eef8f100cc645..1e33f001e2f49a1ed1425d813a8bf66f913a2e12 100644 (file)
@@ -2,7 +2,7 @@
  * file.c : audio output which writes the samples to a file
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: file.c,v 1.8 2002/08/19 23:12:57 massiot Exp $
+ * $Id: file.c,v 1.9 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -150,8 +150,6 @@ static void Play( aout_instance_t * p_aout )
 {
     aout_buffer_t * p_buffer;
 
-    /* We don't need the mixer lock, since Play is entered _with_ the
-     * mixer lock. */
     p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
 
     if( fwrite( p_buffer->p_buffer, p_buffer->i_nb_bytes, 1,
index 54a6e86b74f7247eb899b67046eb8e7ff7cea92f..2b0d569373aa811a0981018044ffb8a5a51d969c 100644 (file)
@@ -2,7 +2,7 @@
  * sdl.c : SDL audio output plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2002 VideoLAN
- * $Id: sdl.c,v 1.7 2002/08/25 16:55:55 sam Exp $
+ * $Id: sdl.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -167,9 +167,9 @@ static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len )
      * hardware latency, or the buffer state. So we just pop data and throw
      * it at SDL's face. Nah. */
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    vlc_mutex_lock( &p_aout->output_fifo_lock );
     p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    vlc_mutex_unlock( &p_aout->output_fifo_lock );
 
     if ( p_buffer != NULL )
     {
index 85851308d1905ae8bafa04596fed1810f15a1164..2d16dbcdf59e0f87570139b311536b757668eb05 100644 (file)
@@ -4,7 +4,7 @@
  *   (http://liba52.sf.net/).
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: a52.c,v 1.7 2002/08/26 23:00:22 massiot Exp $
+ * $Id: a52.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -118,7 +118,8 @@ static int OpenDecoder( vlc_object_t *p_this )
 {
     decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
     
-    if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ') )
+    if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ')
+         && p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') )
     {   
         return VLC_EGENERIC;
     }
index fed36b4c7dddd76be5d414fcb86430c46270630e..ad22d7944af505834951309dc769de3a5bad77c5 100644 (file)
@@ -2,7 +2,7 @@
  * a52old.c: A52 decoder module main file
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: a52old.c,v 1.5 2002/08/26 23:00:22 massiot Exp $
+ * $Id: a52old.c,v 1.6 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Michel Lespinasse <walken@zoy.org>
  *
@@ -77,7 +77,8 @@ static int OpenDecoder( vlc_object_t *p_this )
 {
     decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
     
-    if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ') )
+    if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ')
+         && p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') )
     {   
         return VLC_EGENERIC;
     }
index 1a075d1b1a1672bc2828d42fe9afda8ff5bdf78c..8a2efd1e1cabec9a27149b5224853ed5f6490453 100644 (file)
@@ -2,7 +2,7 @@
  * lpcm.c: lpcm decoder module
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: lpcm.c,v 1.2 2002/08/11 21:59:46 massiot Exp $
+ * $Id: lpcm.c,v 1.3 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Henri Fallon <henri@videolan.org>
@@ -64,7 +64,8 @@ static int OpenDecoder( vlc_object_t *p_this )
 {
     decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
 
-    if( p_fifo->i_fourcc != VLC_FOURCC('l','p','c','m') )
+    if( p_fifo->i_fourcc != VLC_FOURCC('l','p','c','m')
+         && p_fifo->i_fourcc != VLC_FOURCC('l','p','c','b') )
     {   
         return VLC_EGENERIC;
     }
index 6e69259655b052d50d904553160473dcce13d6c8..f9f58f8a4c4cc06cdfb8687e99ea157c39a842c8 100644 (file)
@@ -2,7 +2,7 @@
  * spdif.c: A/52 pass-through to external decoder with enabled soundcard
  *****************************************************************************
  * Copyright (C) 2001-2002 VideoLAN
- * $Id: spdif.c,v 1.7 2002/08/26 23:00:22 massiot Exp $
+ * $Id: spdif.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Stéphane Borel <stef@via.ecp.fr>
  *          Juha Yrjola <jyrjola@cc.hut.fi>
@@ -100,7 +100,8 @@ static int OpenDecoder( vlc_object_t *p_this )
 {   
     decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
 
-    if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ') )
+    if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ')
+         && p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') )
     {   
         return VLC_EGENERIC; 
     }
index cb3fae918b1c794bfcb7d2114c23fa0997c795fd..5dba155d6ea4af2d1951aa5bb208eb3283a6fb09 100644 (file)
@@ -2,7 +2,7 @@
  * spudec.c : SPU decoder thread
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: spudec.c,v 1.2 2002/08/16 03:07:56 sam Exp $
+ * $Id: spudec.c,v 1.3 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -68,7 +68,8 @@ static int OpenDecoder( vlc_object_t *p_this )
 {
     decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
 
-    if( p_fifo->i_fourcc == VLC_FOURCC('s','p','u',' ') )
+    if( p_fifo->i_fourcc == VLC_FOURCC('s','p','u',' ')
+         && p_fifo->i_fourcc == VLC_FOURCC('s','p','u','b') )
     {   
         p_fifo->pf_run = RunDecoder;
         return VLC_SUCCESS;
index 8877aeab62db84882d259b423344374a15237513..891f2dbe655dc6be0a4f0ac3a272fbe0defefab4 100644 (file)
@@ -2,7 +2,7 @@
  * ps.c : Program Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: ps.c,v 1.4 2002/08/12 22:48:18 massiot Exp $
+ * $Id: ps.c,v 1.5 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -227,6 +227,7 @@ static int Activate( vlc_object_t * p_this )
                         break;
 
                     case VLC_FOURCC('a','5','2',' '):
+                    case VLC_FOURCC('a','5','2','b'):
                         if( config_GetInt( p_input, "audio-channel" )
                                 == ((p_es->i_id & 0xF00) >> 8) ||
                            ( config_GetInt( p_input, "audio-channel" ) < 0
@@ -240,6 +241,7 @@ static int Activate( vlc_object_t * p_this )
                         break;
 
                     case VLC_FOURCC('s','p','u',' '):
+                    case VLC_FOURCC('s','p','u','b'):
                         if( config_GetInt( p_input, "spu-channel" )
                                 == ((p_es->i_id & 0x1F00) >> 8) )
                         {
@@ -248,6 +250,7 @@ static int Activate( vlc_object_t * p_this )
                         break;
 
                     case VLC_FOURCC('l','p','c','m'):
+                    case VLC_FOURCC('l','p','c','b'):
                         if( config_GetInt( p_input, "audio-channel" )
                                 == ((p_es->i_id & 0x1F00) >> 8) ||
                            ( config_GetInt( p_input, "audio-channel" ) < 0
index c70d9514df4fb8470d86cfb46afffd0b07982389..d8088a5c10f238292339ddfc19cbfe15d1962d83 100644 (file)
@@ -2,7 +2,7 @@
  * system.c: helper module for TS, PS and PES management
  *****************************************************************************
  * Copyright (C) 1998-2002 VideoLAN
- * $Id: system.c,v 1.1 2002/08/07 00:29:36 sam Exp $
+ * $Id: system.c,v 1.2 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Michel Lespinasse <walken@via.ecp.fr>
@@ -363,17 +363,19 @@ static void ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
             break;
         }
 
-        if( p_es->i_stream_id == 0xbd )
+        /* Welcome to the kludge area ! --Meuuh */
+        if( p_es->i_fourcc == VLC_FOURCC('a','5','2','b') )
         {
-            /* With private stream 1, the first byte of the payload
-             * is a stream_private_id, so skip it. */
-            i_pes_header_size++;
+            /* With A/52 audio, we need to skip the first 4 bytes */
+            i_pes_header_size += 4;
         }
-
-        if( p_es->i_fourcc == VLC_FOURCC('a','5','2',' ') )
+        else if( p_es->i_fourcc == VLC_FOURCC('l','p','c','b')
+                  || p_es->i_fourcc == VLC_FOURCC('s','p','u','b')
+                  || p_es->i_fourcc == VLC_FOURCC('d','t','s','b')
+                  || p_es->i_fourcc == VLC_FOURCC('s','d','d','b') )
         {
-            /* With A52 audio, we need to skip first 3 bytes */
-            i_pes_header_size += 3;
+            /* With others, we need to skip the first byte */
+            i_pes_header_size += 1;
         }
 
         /* Now we've parsed the header, we just have to indicate in some
@@ -642,7 +644,7 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
                 p_es->i_cat = VIDEO_ES;
                 break;
             case DVD_SPU_ES:
-                p_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+                p_es->i_fourcc = VLC_FOURCC('s','p','u','b');
                 p_es->i_cat = SPU_ES;
                 break;
             case MPEG1_AUDIO_ES:
@@ -651,11 +653,11 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
                 p_es->i_cat = AUDIO_ES;
                 break;
             case A52_AUDIO_ES:
-                p_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+                p_es->i_fourcc = VLC_FOURCC('a','5','2','b');
                 p_es->i_cat = AUDIO_ES;
                 break;
             case LPCM_AUDIO_ES:
-                p_es->i_fourcc = VLC_FOURCC('l','p','c','m');
+                p_es->i_fourcc = VLC_FOURCC('l','p','c','b');
                 p_es->i_cat = AUDIO_ES;
                 break;
             default:
@@ -876,7 +878,7 @@ static es_descriptor_t * ParsePS( input_thread_t * p_input,
                     else if( (i_id & 0xF0FF) == 0x80BD )
                     {
                         /* A52 audio (0x80->0x8F) */
-                        p_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+                        p_es->i_fourcc = VLC_FOURCC('a','5','2','b');
                         p_es->i_cat = AUDIO_ES;
 #ifdef AUTO_SPAWN
                         if( !p_input->stream.b_seekable )
@@ -895,7 +897,7 @@ static es_descriptor_t * ParsePS( input_thread_t * p_input,
                     else if( (i_id & 0xE0FF) == 0x20BD )
                     {
                         /* Subtitles video (0x20->0x3F) */
-                        p_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+                        p_es->i_fourcc = VLC_FOURCC('s','p','u','b');
                         p_es->i_cat = SPU_ES;
 #ifdef AUTO_SPAWN
                         if( config_GetInt( p_input, "spu-channel" )
@@ -909,7 +911,7 @@ static es_descriptor_t * ParsePS( input_thread_t * p_input,
                     else if( (i_id & 0xF0FF) == 0xA0BD )
                     {
                         /* LPCM audio (0xA0->0xAF) */
-                        p_es->i_fourcc = VLC_FOURCC('l','p','c','m');
+                        p_es->i_fourcc = VLC_FOURCC('l','p','c','b');
                         p_es->i_cat = AUDIO_ES;
                     }
                     else
index 114441ae71ae0dbc361a3118191c82ccbd4fc891..11e152461eae804cf8b54561a9e3d7d2cd8401ca 100644 (file)
@@ -2,7 +2,7 @@
  * system.h: MPEG demultiplexing.
  *****************************************************************************
  * Copyright (C) 1999-2002 VideoLAN
- * $Id: system.h,v 1.1 2002/08/07 00:29:36 sam Exp $
+ * $Id: system.h,v 1.2 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
 #define PSI_IS_PMT          0x01
 #define UNKNOWN_PSI         0xff
 
+/* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers.
+ * these values are used in mpeg_system.c, and in
+ * the following plugins: mpeg_ts, mpeg_ts_dvbpsi, satellite. */
+#define MPEG1_VIDEO_ES      0x01
+#define MPEG2_VIDEO_ES      0x02
+#define MPEG1_AUDIO_ES      0x03
+#define MPEG2_AUDIO_ES      0x04
+#define A52_AUDIO_ES        0x81
+/* These ones might violate the usage : */
+#define DVD_SPU_ES          0x82
+#define LPCM_AUDIO_ES       0x83
+#define SDDS_AUDIO_ES       0x84
+#define DTS_AUDIO_ES        0x85
+/* These ones are only here to work around a bug in VLS - VLS doesn't
+ * skip the first bytes of the PES payload (stream private ID) when
+ * streaming. This is incompatible with all equipments. 'B' is for
+ * buggy. Please note that they are associated with FOURCCs '***b'.
+ * --Meuuh 2002-08-30
+ */
+#define A52B_AUDIO_ES       0x91
+#define DVDB_SPU_ES         0x92
+#define LPCMB_AUDIO_ES      0x93
+
 /****************************************************************************
  * psi_callback_t
  ****************************************************************************
index f6d7365223a75bbf9746177b79c22b557f5f9784..188230a0c5e7a38bd88b0b1e2e3e14eb0262ff08 100644 (file)
@@ -2,7 +2,7 @@
  * mpeg_ts.c : Transport Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: ts.c,v 1.3 2002/08/08 22:28:22 sam Exp $
+ * $Id: ts.c,v 1.4 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Henri Fallon <henri@via.ecp.fr>
  *          Johan Bilien <jobi@via.ecp.fr>
@@ -624,22 +624,47 @@ static void TSDecodePMT( input_thread_t * p_input, es_descriptor_t * p_es )
                             p_new_es->i_fourcc = VLC_FOURCC('m','p','g','a');
                             p_new_es->i_cat = AUDIO_ES;
                             break;
-                        case LPCM_AUDIO_ES:
-                            p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m');
+                        case A52_AUDIO_ES:
+                            p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
                             p_new_es->i_stream_id = 0xBD;
                             p_new_es->i_cat = AUDIO_ES;
                             break;
-                        case A52_AUDIO_ES:
-                            p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+                        case LPCM_AUDIO_ES:
+                            p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m');
                             p_new_es->i_stream_id = 0xBD;
                             p_new_es->i_cat = AUDIO_ES;
                             break;
-                        /* Not sure this one is fully specification-compliant */
                         case DVD_SPU_ES:
                             p_new_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
                             p_new_es->i_stream_id = 0xBD;
                             p_new_es->i_cat = SPU_ES;
                             break;
+                        case SDDS_AUDIO_ES:
+                            p_new_es->i_fourcc = VLC_FOURCC('s','d','d','s');
+                            p_new_es->i_stream_id = 0xBD;
+                            p_new_es->i_cat = AUDIO_ES;
+                            break;
+                        case DTS_AUDIO_ES:
+                            p_new_es->i_fourcc = VLC_FOURCC('d','t','s',' ');
+                            p_new_es->i_stream_id = 0xBD;
+                            p_new_es->i_cat = AUDIO_ES;
+                            break;
+                        /* 'b' stands for 'buggy' */
+                        case A52B_AUDIO_ES:
+                            p_new_es->i_fourcc = VLC_FOURCC('a','5','2','b');
+                            p_new_es->i_stream_id = 0xBD;
+                            p_new_es->i_cat = AUDIO_ES;
+                            break;
+                        case LPCMB_AUDIO_ES:
+                            p_new_es->i_fourcc = VLC_FOURCC('l','p','c','b');
+                            p_new_es->i_stream_id = 0xBD;
+                            p_new_es->i_cat = AUDIO_ES;
+                            break;
+                        case DVDB_SPU_ES:
+                            p_new_es->i_fourcc = VLC_FOURCC('s','p','u','b');
+                            p_new_es->i_stream_id = 0xBD;
+                            p_new_es->i_cat = SPU_ES;
+                            break;
                         default :
                             p_new_es->i_fourcc = 0;
                             p_new_es->i_cat = UNKNOWN_ES;
@@ -857,21 +882,46 @@ void TS_DVBPSI_HandlePMT( input_thread_t * p_input, dvbpsi_pmt_t * p_new_pmt )
                     p_new_es->i_fourcc = VLC_FOURCC('m','p','g','a');
                     p_new_es->i_cat = AUDIO_ES;
                     break;
+                case A52_AUDIO_ES:
+                    p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+                    p_new_es->i_cat = AUDIO_ES;
+                    p_new_es->i_stream_id = 0xBD;
+                    break;
+                case DVD_SPU_ES:
+                    p_new_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+                    p_new_es->i_cat = SPU_ES;
+                    p_new_es->i_stream_id = 0xBD;
+                    break;
                 case LPCM_AUDIO_ES:
                     p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m');
                     p_new_es->i_cat = AUDIO_ES;
                     p_new_es->i_stream_id = 0xBD;
                     break;
-                case A52_AUDIO_ES:
-                    p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+                case SDDS_AUDIO_ES:
+                    p_new_es->i_fourcc = VLC_FOURCC('s','d','d','s');
+                    p_new_es->i_stream_id = 0xBD;
                     p_new_es->i_cat = AUDIO_ES;
+                    break;
+                case DTS_AUDIO_ES:
+                    p_new_es->i_fourcc = VLC_FOURCC('d','t','s',' ');
                     p_new_es->i_stream_id = 0xBD;
+                    p_new_es->i_cat = AUDIO_ES;
                     break;
-                case DVD_SPU_ES:
-                    p_new_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+                case A52B_AUDIO_ES:
+                    p_new_es->i_fourcc = VLC_FOURCC('a','5','2','b');
+                    p_new_es->i_cat = AUDIO_ES;
+                    p_new_es->i_stream_id = 0xBD;
+                    break;
+                case DVDB_SPU_ES:
+                    p_new_es->i_fourcc = VLC_FOURCC('s','p','u','b');
                     p_new_es->i_cat = SPU_ES;
                     p_new_es->i_stream_id = 0xBD;
                     break;
+                case LPCMB_AUDIO_ES:
+                    p_new_es->i_fourcc = VLC_FOURCC('l','p','c','b');
+                    p_new_es->i_cat = AUDIO_ES;
+                    p_new_es->i_stream_id = 0xBD;
+                    break;
                 default:
                     p_new_es->i_fourcc = 0;
                     p_new_es->i_cat = UNKNOWN_ES;
@@ -914,9 +964,11 @@ void TS_DVBPSI_HandlePMT( input_thread_t * p_input, dvbpsi_pmt_t * p_new_pmt )
                         strcat( p_new_es->psz_desc, " (mpeg)" );
                         break;
                     case LPCM_AUDIO_ES:
+                    case LPCMB_AUDIO_ES:
                         strcat( p_new_es->psz_desc, " (lpcm)" );
                         break;
                     case A52_AUDIO_ES:
+                    case A52B_AUDIO_ES:
                         strcat( p_new_es->psz_desc, " (A52)" );
                         break;
                 }
index e9c7246a450602746b27138a0183ac7c1418cebe..18f3ec95f400a33af25c97379ac1a721efd90b96 100644 (file)
@@ -2,7 +2,7 @@
  * aout_dummy.c : dummy audio output plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: aout.c,v 1.6 2002/08/19 23:12:57 massiot Exp $
+ * $Id: aout.c,v 1.7 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -77,8 +77,6 @@ static int SetFormat( aout_instance_t * p_aout )
  *****************************************************************************/
 static void Play( aout_instance_t * p_aout )
 {
-    /* We don't need the mixer lock, since Play is entered _with_ the
-     * mixer lock. */
     aout_buffer_t * p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
     aout_BufferFree( p_buffer );
 }
index a830c4738d437701dc7671800f1969e230591b03..63db8e9756fd4704778a238c5ba2051e8c832cb5 100644 (file)
@@ -2,7 +2,7 @@
  * audio_output.c : audio output instance miscellaneous functions
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: audio_output.c,v 1.99 2002/08/21 22:41:59 massiot Exp $
+ * $Id: audio_output.c,v 1.100 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -55,13 +55,10 @@ aout_instance_t * __aout_NewInstance( vlc_object_t * p_parent )
     }
 
     /* Initialize members. */
-    vlc_mutex_init( p_parent, &p_aout->input_lock );
-    vlc_cond_init( p_parent, &p_aout->input_signal );
-    p_aout->i_inputs_active = 0;
-    p_aout->b_change_requested = 0;
-    p_aout->i_nb_inputs = 0;
-
+    vlc_mutex_init( p_parent, &p_aout->input_fifos_lock );
     vlc_mutex_init( p_parent, &p_aout->mixer_lock );
+    vlc_mutex_init( p_parent, &p_aout->output_fifo_lock );
+    p_aout->i_nb_inputs = 0;
 
     vlc_object_attach( p_aout, p_parent->p_vlc );
 
@@ -73,9 +70,9 @@ aout_instance_t * __aout_NewInstance( vlc_object_t * p_parent )
  *****************************************************************************/
 void aout_DeleteInstance( aout_instance_t * p_aout )
 {
-    vlc_mutex_destroy( &p_aout->input_lock );
-    vlc_cond_destroy( &p_aout->input_signal );
+    vlc_mutex_destroy( &p_aout->input_fifos_lock );
     vlc_mutex_destroy( &p_aout->mixer_lock );
+    vlc_mutex_destroy( &p_aout->output_fifo_lock );
 
     /* Free structure. */
     vlc_object_destroy( p_aout );
index 031729e9b372e1b6b1cbf79e9cb41e65f7800e3a..adaa2eefb1178bc6164925d123d8dd905615234c 100644 (file)
@@ -2,7 +2,7 @@
  * filters.c : audio output filters management
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: filters.c,v 1.7 2002/08/28 22:25:39 massiot Exp $
+ * $Id: filters.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -183,7 +183,7 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
         return 0;
     }
 
-    /* We'll have to split the conversion. We always to the downmixing
+    /* We'll have to split the conversion. We always do the downmixing
      * before the resampling, and the upmixing after the resampling (to
      * maximize the resampling efficiency). */
     b_rate_first = (p_input_format->i_channels < p_output_format->i_channels);
index a12db52b9a2c6edf097f4516073623b5cd66ad40..6a71c85c71bc295be5d89ad8d3be4f679309a733 100644 (file)
@@ -2,7 +2,7 @@
  * input.c : internal management of input streams for the audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: input.c,v 1.10 2002/08/28 22:25:39 massiot Exp $
+ * $Id: input.c,v 1.11 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
 static aout_input_t * InputNew( aout_instance_t * p_aout,
                                 audio_sample_format_t * p_format )
 {
-    aout_input_t * p_input = malloc(sizeof(aout_input_t));
-
-    if ( p_input == NULL ) return NULL;
+    aout_input_t * p_input;
 
     vlc_mutex_lock( &p_aout->mixer_lock );
 
+    if ( p_aout->i_nb_inputs >= AOUT_MAX_INPUTS )
+    {
+        msg_Err( p_aout, "too many inputs already (%d)", p_aout->i_nb_inputs );
+        vlc_mutex_unlock( &p_aout->mixer_lock );
+        return NULL;
+    }
+
+    p_input = malloc(sizeof(aout_input_t));
+    if ( p_input == NULL )
+    {
+        msg_Err( p_aout, "out of memory" );
+        vlc_mutex_unlock( &p_aout->mixer_lock );
+        return NULL;
+    }
+
+    vlc_mutex_init( p_aout, &p_input->lock );
+    vlc_mutex_lock( &p_input->lock );
+
     if ( p_aout->i_nb_inputs == 0 )
     {
         /* Recreate the output using the new format. */
         if ( aout_OutputNew( p_aout, p_format ) < 0 )
         {
+            vlc_mutex_unlock( &p_input->lock );
+            vlc_mutex_destroy( &p_input->lock );
             free( p_input );
+            vlc_mutex_unlock( &p_aout->mixer_lock );
             return NULL;
         }
     }
@@ -70,24 +89,6 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
     aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
     p_input->p_first_byte_to_mix = NULL;
 
-    /* Create filters. */
-    if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
-                                     &p_input->i_nb_filters, &p_input->input,
-                                     &p_aout->mixer.mixer ) < 0 )
-    {
-        msg_Err( p_aout, "couldn't set an input pipeline" );
-
-        aout_FifoDestroy( p_aout, &p_input->fifo );
-
-        free( p_input );
-
-        if ( !p_aout->i_nb_inputs )
-        {
-            aout_OutputDelete( p_aout );
-        }
-        return NULL;
-    }
-
     p_aout->pp_inputs[p_aout->i_nb_inputs] = p_input;
     p_aout->i_nb_inputs++;
 
@@ -98,8 +99,6 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
                                      p_input->i_nb_filters );
         aout_FifoDestroy( p_aout, &p_input->fifo );
 
-        free( p_input );
-
         if ( !p_aout->i_nb_inputs )
         {
             aout_OutputDelete( p_aout );
@@ -108,6 +107,9 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
         {
             aout_MixerNew( p_aout );
         }
+        vlc_mutex_unlock( &p_input->lock );
+        vlc_mutex_destroy( &p_input->lock );
+        free( p_input );
         vlc_mutex_unlock( &p_aout->mixer_lock );
 
         return NULL;
@@ -115,6 +117,27 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
 
     vlc_mutex_unlock( &p_aout->mixer_lock );
 
+    /* Create filters. */
+    if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
+                                     &p_input->i_nb_filters, &p_input->input,
+                                     &p_aout->mixer.mixer ) < 0 )
+    {
+        msg_Err( p_aout, "couldn't set an input pipeline" );
+
+        aout_FifoDestroy( p_aout, &p_input->fifo );
+
+        vlc_mutex_unlock( &p_input->lock );
+        vlc_mutex_destroy( &p_input->lock );
+        free( p_input );
+        vlc_mutex_unlock( &p_aout->mixer_lock );
+
+        if ( !p_aout->i_nb_inputs )
+        {
+            aout_OutputDelete( p_aout );
+        }
+        return NULL;
+    }
+
     /* Prepare hints for the buffer allocator. */
     p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
     p_input->input_alloc.i_bytes_per_sec = -1;
@@ -132,6 +155,8 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
     /* Allocate in the heap, it is more convenient for the decoder. */
     p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
 
+    vlc_mutex_unlock( &p_input->lock );
+
     msg_Dbg( p_aout, "input 0x%x created", p_input );
     return p_input;
 }
@@ -170,6 +195,7 @@ void aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
     int i_input;
 
     vlc_mutex_lock( &p_aout->mixer_lock );
+    vlc_mutex_lock( &p_input->lock );
 
     for ( i_input = 0; i_input < p_aout->i_nb_inputs; i_input++ )
     {
@@ -190,20 +216,22 @@ void aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
              (AOUT_MAX_INPUTS - i_input - 1) * sizeof(aout_input_t *) );
     p_aout->i_nb_inputs--;
 
+    if ( !p_aout->i_nb_inputs )
+    {
+        aout_OutputDelete( p_aout );
+        aout_MixerDelete( p_aout );
+    }
+
     vlc_mutex_unlock( &p_aout->mixer_lock );
 
     aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
                                  p_input->i_nb_filters );
     aout_FifoDestroy( p_aout, &p_input->fifo );
 
+    vlc_mutex_unlock( &p_input->lock );
+    vlc_mutex_destroy( &p_input->lock );
     free( p_input );
 
-    if ( !p_aout->i_nb_inputs )
-    {
-        aout_OutputDelete( p_aout );
-        aout_MixerDelete( p_aout );
-    }
-
     msg_Dbg( p_aout, "input 0x%x destroyed", p_input );
 }
 
@@ -215,13 +243,7 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
 {
     mtime_t start_date, duration;
 
-    vlc_mutex_lock( &p_aout->input_lock );
-    while( p_aout->b_change_requested )
-    {
-        vlc_cond_wait( &p_aout->input_signal, &p_aout->input_lock );
-    }
-    p_aout->i_inputs_active++;
-    vlc_mutex_unlock( &p_aout->input_lock );
+    vlc_mutex_lock( &p_input->lock );
 
     /* We don't care if someone changes the start date behind our back after
      * this. We'll deal with that when pushing the buffer, and compensate
@@ -249,10 +271,7 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                   mdate() - p_buffer->start_date );
         aout_BufferFree( p_buffer );
 
-        vlc_mutex_lock( &p_aout->input_lock );
-        p_aout->i_inputs_active--;
-        vlc_cond_broadcast( &p_aout->input_signal );
-        vlc_mutex_unlock( &p_aout->input_lock );
+        vlc_mutex_unlock( &p_input->lock );
         return;
     }
 
@@ -306,10 +325,7 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
             vlc_mutex_unlock( &p_aout->mixer_lock );
             aout_BufferFree( p_buffer );
 
-            vlc_mutex_lock( &p_aout->input_lock );
-            p_aout->i_inputs_active--;
-            vlc_cond_broadcast( &p_aout->input_signal );
-            vlc_mutex_unlock( &p_aout->input_lock );
+            vlc_mutex_unlock( &p_input->lock );
             return;
         }
 
@@ -348,15 +364,12 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                           &p_buffer );
     }
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    vlc_mutex_unlock( &p_input->lock );
+
+    vlc_mutex_lock( &p_aout->input_fifos_lock );
     /* Adding the start date will be managed by aout_FifoPush(). */
     p_buffer->start_date = start_date;
     p_buffer->end_date = start_date + duration;
     aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
-    vlc_mutex_unlock( &p_aout->mixer_lock );
-
-    vlc_mutex_lock( &p_aout->input_lock );
-    p_aout->i_inputs_active--;
-    vlc_cond_broadcast( &p_aout->input_signal );
-    vlc_mutex_unlock( &p_aout->input_lock );
+    vlc_mutex_unlock( &p_aout->input_fifos_lock );
 }
index 9e9d0d7baf743c20f07ec1e23225dfddc90ca31f..25b7ddbacd26611746029bb6d15bc7bceeabea3f 100644 (file)
@@ -2,7 +2,7 @@
  * mixer.c : audio output mixing operations
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: mixer.c,v 1.10 2002/08/26 23:00:23 massiot Exp $
+ * $Id: mixer.c,v 1.11 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -38,6 +38,8 @@
 
 /*****************************************************************************
  * aout_MixerNew: prepare a mixer plug-in
+ *****************************************************************************
+ * Please note that you must hold the mixer lock.
  *****************************************************************************/
 int aout_MixerNew( aout_instance_t * p_aout )
 {
@@ -52,6 +54,8 @@ int aout_MixerNew( aout_instance_t * p_aout )
 
 /*****************************************************************************
  * aout_MixerDelete: delete the mixer
+ *****************************************************************************
+ * Please note that you must hold the mixer lock.
  *****************************************************************************/
 void aout_MixerDelete( aout_instance_t * p_aout )
 {
@@ -69,6 +73,8 @@ static int MixBuffer( aout_instance_t * p_aout )
     audio_date_t exact_start_date;
 
     vlc_mutex_lock( &p_aout->mixer_lock );
+    vlc_mutex_lock( &p_aout->output_fifo_lock );
+    vlc_mutex_lock( &p_aout->input_fifos_lock );
 
     /* Retrieve the date of the next buffer. */
     memcpy( &exact_start_date, &p_aout->output.fifo.end_date,
@@ -87,6 +93,8 @@ static int MixBuffer( aout_instance_t * p_aout )
         start_date = 0;
     } 
 
+    vlc_mutex_unlock( &p_aout->output_fifo_lock );
+
     /* See if we have enough data to prepare a new buffer for the audio
      * output. First : start date. */
     if ( !start_date )
@@ -114,6 +122,7 @@ static int MixBuffer( aout_instance_t * p_aout )
         if ( i < p_aout->i_nb_inputs )
         {
             /* Interrupted before the end... We can't run. */
+            vlc_mutex_unlock( &p_aout->input_fifos_lock );
             vlc_mutex_unlock( &p_aout->mixer_lock );
             return -1;
         }
@@ -231,6 +240,7 @@ static int MixBuffer( aout_instance_t * p_aout )
     if ( i < p_aout->i_nb_inputs )
     {
         /* Interrupted before the end... We can't run. */
+        vlc_mutex_unlock( &p_aout->input_fifos_lock );
         vlc_mutex_unlock( &p_aout->mixer_lock );
         return -1;
     }
@@ -246,6 +256,7 @@ static int MixBuffer( aout_instance_t * p_aout )
     if ( p_output_buffer == NULL )
     {
         msg_Err( p_aout, "out of memory" );
+        vlc_mutex_unlock( &p_aout->input_fifos_lock );
         vlc_mutex_unlock( &p_aout->mixer_lock );
         return -1;
     }
@@ -262,10 +273,12 @@ static int MixBuffer( aout_instance_t * p_aout )
 
     p_aout->mixer.pf_do_work( p_aout, p_output_buffer );
 
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    vlc_mutex_unlock( &p_aout->input_fifos_lock );
 
     aout_OutputPlay( p_aout, p_output_buffer );
 
+    vlc_mutex_unlock( &p_aout->mixer_lock );
+
     return 0;
 }
 
index e356a005db7f8e63aabcd89c9d800ee3c3bab52a..afa9bc9dc8f5c08bcf0c1be72e0cf731da767d1c 100644 (file)
@@ -2,7 +2,7 @@
  * output.c : internal management of output streams for the audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: output.c,v 1.12 2002/08/25 16:55:55 sam Exp $
+ * $Id: output.c,v 1.13 2002/08/30 22:22:24 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -34,6 +34,8 @@
 
 /*****************************************************************************
  * aout_OutputNew : allocate a new output and rework the filter pipeline
+ *****************************************************************************
+ * This function is entered with the mixer_lock.
  *****************************************************************************/
 int aout_OutputNew( aout_instance_t * p_aout,
                     audio_sample_format_t * p_format )
@@ -67,11 +69,14 @@ int aout_OutputNew( aout_instance_t * p_aout,
                         AOUT_FMT_FLOAT32 : AOUT_FMT_FIXED32;
     }
 
+    vlc_mutex_lock( &p_aout->output_fifo_lock );
+
     /* Find the best output format. */
     if ( p_aout->output.pf_setformat( p_aout ) != 0 )
     {
         msg_Err( p_aout, "couldn't set an output format" );
         module_Unneed( p_aout, p_aout->output.p_module );
+        vlc_mutex_unlock( &p_aout->output_fifo_lock );
         return -1;
     }
     aout_FormatPrepare( &p_aout->output.output );
@@ -79,6 +84,8 @@ int aout_OutputNew( aout_instance_t * p_aout,
     /* Prepare FIFO. */
     aout_FifoInit( p_aout, &p_aout->output.fifo, p_aout->output.output.i_rate );
 
+    vlc_mutex_unlock( &p_aout->output_fifo_lock );
+
     msg_Dbg( p_aout, "output format=%d rate=%d channels=%d",
              p_aout->output.output.i_format, p_aout->output.output.i_rate,
              p_aout->output.output.i_channels );
@@ -130,6 +137,8 @@ int aout_OutputNew( aout_instance_t * p_aout,
 
 /*****************************************************************************
  * aout_OutputDelete : delete the output
+ *****************************************************************************
+ * This function is entered with the mixer_lock.
  *****************************************************************************/
 void aout_OutputDelete( aout_instance_t * p_aout )
 {
@@ -142,6 +151,8 @@ void aout_OutputDelete( aout_instance_t * p_aout )
 
 /*****************************************************************************
  * aout_OutputPlay : play a buffer
+ *****************************************************************************
+ * This function is entered with the mixer_lock.
  *****************************************************************************/
 void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
 {
@@ -149,10 +160,10 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
                       p_aout->output.i_nb_filters,
                       &p_buffer );
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    vlc_mutex_lock( &p_aout->output_fifo_lock );
     aout_FifoPush( p_aout, &p_aout->output.fifo, p_buffer );
     p_aout->output.pf_play( p_aout );
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    vlc_mutex_unlock( &p_aout->output_fifo_lock );
 }
 
 /*****************************************************************************
@@ -168,7 +179,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
 {
     aout_buffer_t * p_buffer;
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    vlc_mutex_lock( &p_aout->output_fifo_lock );
 
     p_buffer = p_aout->output.fifo.p_first;
     while ( p_buffer && p_buffer->start_date < start_date )
@@ -185,7 +196,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
         p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first;
         /* Set date to 0, to allow the mixer to send a new buffer ASAP */
         aout_FifoSet( p_aout, &p_aout->output.fifo, 0 );
-        vlc_mutex_unlock( &p_aout->mixer_lock );
+        vlc_mutex_unlock( &p_aout->output_fifo_lock );
         msg_Dbg( p_aout,
                  "audio output is starving (no input), playing silence" );
         return NULL;
@@ -196,7 +207,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
     if ( p_buffer->start_date > start_date
                          + (p_buffer->end_date - p_buffer->start_date) )
     {
-        vlc_mutex_unlock( &p_aout->mixer_lock );
+        vlc_mutex_unlock( &p_aout->output_fifo_lock );
         msg_Dbg( p_aout, "audio output is starving (%lld), playing silence",
                  p_buffer->start_date - start_date );
         return NULL;
@@ -212,7 +223,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
         msg_Warn( p_aout, "output date isn't PTS date, resampling (%lld)",
                   difference );
 
-        /* Remember that we still own the mixer lock. */
+        vlc_mutex_lock( &p_aout->input_fifos_lock );
         for ( i = 0; i < p_aout->i_nb_inputs; i++ )
         {
             aout_fifo_t * p_fifo = &p_aout->pp_inputs[i]->fifo;
@@ -221,6 +232,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
         }
 
         aout_FifoMoveDates( p_aout, &p_aout->output.fifo, difference );
+        vlc_mutex_unlock( &p_aout->input_fifos_lock );
     }
 
     p_aout->output.fifo.p_first = p_buffer->p_next;
@@ -229,6 +241,6 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
         p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first;
     }
 
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    vlc_mutex_unlock( &p_aout->output_fifo_lock );
     return p_buffer;
 }