]> git.sesse.net Git - vlc/commitdiff
*slight modification in input_dvd since Getiovec wasn't at the right
authorStéphane Borel <stef@videolan.org>
Tue, 12 Jun 2001 18:16:49 +0000 (18:16 +0000)
committerStéphane Borel <stef@videolan.org>
Tue, 12 Jun 2001 18:16:49 +0000 (18:16 +0000)
place

*send escape packet when changing title, not to be stuck in some
decoder.

*the position in the title is now resetted when we change title to
prevent a title from being unavailable because we're stuck at the end

*fixed a bug with 1-chapter-long title that displayed chapter 0.

*added a _temporary_ field in p_main to know whether the audio stream is
ac3 (ugly). It allows a vlc launched in spdif mode to play mpeg or lpcm
audio.

*cleaned the title property messages to get rid of the ugly stars.

include/main.h
plugins/dvd/dvd_summary.c
plugins/dvd/input_dvd.c
src/audio_output/aout_ext-dec.c
src/audio_output/aout_spdif.c
src/audio_output/audio_output.c
src/input/input.c
src/input/input_programs.c

index d9bc4c7ca16a3b31c3faeba30b07b0ec7337af7a..e9476da6c24e78b075097d1d058aad27688ede37 100644 (file)
@@ -3,7 +3,7 @@
  * Declaration and extern access to global program object.
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: main.h,v 1.20 2001/05/30 23:02:03 stef Exp $
+ * $Id: main.h,v 1.21 2001/06/12 18:16:49 stef Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
@@ -47,6 +47,7 @@ typedef struct main_s
     /* Generic settings */
     boolean_t              b_audio;             /* is audio output allowed ? */
     boolean_t              b_video;             /* is video output allowed ? */
+    boolean_t              b_ac3;
 
     /* Unique threads */
     p_intf_thread_t        p_intf;                  /* main interface thread */
index 6c2ede655f471d3933dc566e1e44f8005e8ca949..3bd13adde5345b029b2d01d51776c296ef5acb04 100644 (file)
@@ -3,7 +3,7 @@
  * found in .ifo.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: dvd_summary.c,v 1.4 2001/06/07 22:25:42 sam Exp $
+ * $Id: dvd_summary.c,v 1.5 2001/06/12 18:16:49 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -259,13 +259,11 @@ char * IfoLanguage( u16 i_code )
  ****************************************************************************/
 void IfoPrintTitle( thread_dvd_data_t * p_dvd )
 {
-    intf_WarnMsg( 5, "***************************************************" );
     intf_WarnMsg( 5, "dvd info: title: %d", p_dvd->i_title );
     intf_WarnMsg( 5, "    vobstart at: %lld", p_dvd->i_start );
     intf_WarnMsg( 5, "    stream size: %lld", p_dvd->i_size );
     intf_WarnMsg( 5, "    number of chapters: %d", p_dvd->i_chapter_nb );
     intf_WarnMsg( 5, "    number of angles: %d", p_dvd->i_angle_nb );
-    intf_WarnMsg( 5, "***************************************************\n" );
 }
 
 /****************************************************************************
@@ -304,7 +302,6 @@ void IfoPrintVideo( thread_dvd_data_t * p_dvd )
         break;
     }
 
-    intf_WarnMsg( 5, "***********************************************" );
     intf_WarnMsg( 5, "dvd info: video" );
     intf_WarnMsg( 5, "    compression: mpeg-%d", video.i_compression+1 );
     intf_WarnMsg( 5, "    tv system: %s Hz",
@@ -322,7 +319,6 @@ void IfoPrintVideo( thread_dvd_data_t * p_dvd )
                      video.i_letterboxed ? "yes" : "no" );
     intf_WarnMsg( 5, "    mode: %s",
                      video.i_mode ? "film (625/50 only)" : "camera");
-    intf_WarnMsg( 5, "***********************************************\n" );
 }
 #undef video
 
@@ -345,7 +341,6 @@ void IfoPrintAudio( thread_dvd_data_t * p_dvd, int i )
         char    ppsz_quant[4][10] =
                 { "16 bits", "20 bits", "24 bits", "drc" };
     
-        intf_WarnMsg( 5, "***********************************************" );
         intf_WarnMsg( 5, "dvd info: audio %d" , i );
         intf_WarnMsg( 5, "    language: %s", 
                          IfoLanguage( hton16( audio.i_lang_code ) ) );
@@ -374,7 +369,6 @@ void IfoPrintAudio( thread_dvd_data_t * p_dvd, int i )
                          ppsz_quant[audio.i_quantization & 0x3] );
     
         intf_WarnMsg( 5, "    status: %x", audio_status.i_position );
-        intf_WarnMsg( 5, "***********************************************\n" );
     }
 
 
@@ -393,7 +387,6 @@ void IfoPrintSpu( thread_dvd_data_t * p_dvd, int i )
 {
     if( spu_status.i_available )
     {
-        intf_WarnMsg( 5, "***********************************************" );
         intf_WarnMsg( 5, "dvd info: spu %d", i );
         intf_WarnMsg( 5, "    caption: %d", spu.i_caption );
         intf_WarnMsg( 5, "    language: %s",
@@ -405,7 +398,6 @@ void IfoPrintSpu( thread_dvd_data_t * p_dvd, int i )
             spu_status.i_position_wide,
             spu_status.i_position_letter,
             spu_status.i_position_pan );
-        intf_WarnMsg( 5, "***********************************************\n" );
     }
 
 }
index 5a82c5412228467e10a5f2089170885feaa96c0e..877458a82ee8b772623ffd40b00a6f5c2453e7c0 100644 (file)
@@ -10,7 +10,7 @@
  *  -dvd_udf to find files
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_dvd.c,v 1.69 2001/06/09 17:01:22 stef Exp $
+ * $Id: input_dvd.c,v 1.70 2001/06/12 18:16:49 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
 #include "modules_export.h"
 
 /* how many blocks DVDRead will read in each loop */
-#define DVD_BLOCK_READ_ONCE 32
+#define DVD_BLOCK_READ_ONCE 64
 #define DVD_DATA_READ_ONCE  4*DVD_BLOCK_READ_ONCE
 
 /* Size of netlist */
-#define DVD_NETLIST_SIZE    2048
+#define DVD_NETLIST_SIZE    1024
 
 /*****************************************************************************
  * Local prototypes
@@ -427,9 +427,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
         p_input->stream.p_selected_area =
                     p_input->stream.pp_areas[p_area->i_id];
 
-        /* release the lock to to let the interface go */
-//        vlc_mutex_unlock( &p_input->stream.stream_lock );
-
         /* title number: it is not vts nb!,
          * it is what appears in the interface list */
         p_dvd->i_title = p_area->i_id;
@@ -539,14 +536,18 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
 
         IfoPrintTitle( p_dvd );
 
-//        vlc_mutex_lock( &p_input->stream.stream_lock );
-
         /* Area definition */
         p_input->stream.p_selected_area->i_start = p_dvd->i_start;
         p_input->stream.p_selected_area->i_size = p_dvd->i_size;
         p_input->stream.p_selected_area->i_angle_nb = p_dvd->i_angle_nb;
         p_input->stream.p_selected_area->i_angle = p_dvd->i_angle;
 
+        /* start at the beginning of the title */
+        /* FIXME: create a conf option to select whether to restart
+         * title or not */
+        p_input->stream.p_selected_area->i_tell = 0;
+        p_input->stream.p_selected_area->i_part = 1;
+
         /*
          * Destroy obsolete ES by reinitializing program 0
          * and find all ES in title with ifo data
@@ -571,7 +572,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
 
         /* No PSM to read in DVD mode, we already have all information */
         p_input->stream.pp_programs[0]->b_is_ok = 1;
-        p_input->stream.pp_programs[0]->i_synchro_state = SYNCHRO_START;
 
         p_es = NULL;
 
@@ -582,12 +582,10 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
         p_es->i_stream_id = 0xe0;
         p_es->i_type = MPEG2_VIDEO_ES;
         p_es->i_cat = VIDEO_ES;
-        intf_WarnMsg( 1, "dvd info: video mpeg2 stream" );
         if( p_main->b_video )
         {
             input_SelectES( p_input, p_es );
         }
-        intf_WarnMsg( 4, "dvd info: video selected" );
 
 #define audio_status \
     vts.title_unit.p_title[p_dvd->i_title_id-1].title.pi_audio_status[i-1]
@@ -613,9 +611,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
                         vts.manager_inf.p_audio_attr[i-1].i_lang_code ) ) ); 
                     strcat( p_es->psz_desc, " (ac3)" );
     
-                    intf_WarnMsg( 3, "dvd info: audio stream %d %s\t(0x%x)",
-                                  i, p_es->psz_desc, i_id );
-    
                     break;
                 case 0x02:
                 case 0x03:              /* MPEG audio */
@@ -630,9 +625,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
                         vts.manager_inf.p_audio_attr[i-1].i_lang_code ) ) ); 
                     strcat( p_es->psz_desc, " (mpeg)" );
     
-                    intf_WarnMsg( 3, "dvd info: audio stream %d %s\t(0x%x)",
-                                  i, p_es->psz_desc, i_id );
-    
                     break;
                 case 0x04:              /* LPCM */
     
@@ -647,8 +639,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
                         vts.manager_inf.p_audio_attr[i-1].i_lang_code ) ) ); 
                     strcat( p_es->psz_desc, " (lpcm)" );
     
-                    intf_WarnMsg( 3, "dvd info: audio stream %d %s\t(0x%x)",
-                                  i, p_es->psz_desc, i_id );
                     break;
                 case 0x06:              /* DTS */
                     i_id = ( ( 0x88 + audio_status.i_position ) << 8 ) | 0xbd;
@@ -707,8 +697,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
                 p_es->i_cat = SPU_ES;
                 strcpy( p_es->psz_desc, IfoLanguage( hton16(
                     vts.manager_inf.p_spu_attr[i-1].i_lang_code ) ) ); 
-                intf_WarnMsg( 3, "dvd info: spu stream %d %s\t(0x%x)",
-                              i, p_es->psz_desc, i_id );
             }
         }
 #undef spu_status
@@ -771,7 +759,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
                                                       p_area->i_start;
             p_input->stream.p_selected_area->i_part = p_dvd->i_chapter;
     
-            intf_WarnMsg( 2, "dvd info: chapter %d start at: %lld",
+            intf_WarnMsg( 4, "dvd info: chapter %d start at: %lld",
                                         p_area->i_part, p_area->i_tell );
         }
         else
@@ -796,19 +784,13 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
     
             DVDFindSector( p_dvd );
             p_dvd->i_cell += p_dvd->i_angle_cell;
-
-            if( p_input->stream.pp_programs[0]->i_synchro_state == SYNCHRO_OK )
-            {
-                p_input->stream.pp_programs[0]->i_synchro_state =
-                    SYNCHRO_REINIT;
-            }
         }
         else
         {
             p_dvd->i_angle = p_area->i_angle;
         }
 
-        intf_WarnMsg( 2, "dvd info: angle %d selected", p_area->i_angle );
+        intf_WarnMsg( 3, "dvd info: angle %d selected", p_area->i_angle );
     }
 
     /* warn interface that something has changed */
@@ -848,13 +830,6 @@ static int DVDRead( input_thread_t * p_input,
     p_dvd = (thread_dvd_data_t *)p_input->p_plugin_data;
     p_netlist = (dvd_netlist_t *)p_input->p_method_data;
 
-    /* Get an iovec pointer */
-    if( ( p_vec = DVDGetiovec( p_netlist ) ) == NULL )
-    {
-        intf_ErrMsg( "dvd error: can't get iovec" );
-        return -1;
-    }
-
     i_block_once = p_dvd->i_end_sector - p_dvd->i_sector + 1;
 
     /* Get the position of the next cell if we're at cell end */
@@ -903,9 +878,6 @@ static int DVDRead( input_thread_t * p_input,
                                     p_input->stream.p_selected_area->i_start;
         p_input->stream.p_selected_area->i_part = p_dvd->i_chapter;
 
-        /* the synchro has to be reinitialized when we change cell */
-//        p_input->stream.pp_programs[0]->i_synchro_state = SYNCHRO_REINIT;
-
         vlc_mutex_unlock( &p_input->stream.stream_lock );
 
         i_block_once = p_dvd->i_end_sector - p_dvd->i_sector + 1;
@@ -921,6 +893,13 @@ static int DVDRead( input_thread_t * p_input,
 
     p_netlist->i_read_once = i_block_once;
 
+    /* Get an iovec pointer */
+    if( ( p_vec = DVDGetiovec( p_netlist ) ) == NULL )
+    {
+        intf_ErrMsg( "dvd error: can't get iovec" );
+        return -1;
+    }
+
     /* Reads from DVD */
 #if !defined( WIN32 )
     i_read_bytes = readv( p_dvd->i_fd, p_vec, i_block_once );
@@ -929,7 +908,8 @@ static int DVDRead( input_thread_t * p_input,
 #endif
     i_read_blocks = ( i_read_bytes + 0x7ff ) >> 11;
 
-    /* Update netlist indexes */
+    /* Update netlist indexes: we don't do it in DVDGetiovec since we
+     * need know the real number of blocks read */
     DVDMviovec( p_netlist, i_read_blocks, pp_data );
 
     /* Update global position */
@@ -1131,11 +1111,18 @@ static void DVDSeek( input_thread_t * p_input, off_t i_off )
     {
         i_angle = 0;
     }
-    while( ( title.chapter_map.pi_start_cell[i_chapter] <=
-                ( p_dvd->i_prg_cell - i_angle + 1 ) ) &&
-           ( i_chapter < ( p_dvd->i_chapter_nb - 1 ) ) )
+    if( p_dvd->i_chapter_nb > 1 )
     {
-        i_chapter++;
+        while( ( title.chapter_map.pi_start_cell[i_chapter] <=
+                    ( p_dvd->i_prg_cell - i_angle + 1 ) ) &&
+               ( i_chapter < ( p_dvd->i_chapter_nb - 1 ) ) )
+        {
+            i_chapter++;
+        }
+    }
+    else
+    {
+        i_chapter = 1;
     }
 
     p_dvd->i_chapter = i_chapter;
@@ -1153,8 +1140,8 @@ static void DVDSeek( input_thread_t * p_input, off_t i_off )
                          p_input->stream.p_selected_area->i_start;
 
 #endif
-/*
-    intf_WarnMsg( 3, "Program Cell: %d Cell: %d Chapter: %d",
+
+/*    intf_WarnMsg( 3, "Program Cell: %d Cell: %d Chapter: %d",
                      p_dvd->i_prg_cell, p_dvd->i_cell, p_dvd->i_chapter );
 */
 
index 611be152c97db5db43c6bf941d07c6629a569de7..29b19bb849f39c15dfe0b00516bae6d0502db702 100644 (file)
@@ -2,7 +2,7 @@
  * aout_ext-dec.c : exported fifo management functions
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: aout_ext-dec.c,v 1.4 2001/05/07 03:14:09 stef Exp $
+ * $Id: aout_ext-dec.c,v 1.5 2001/06/12 18:16:49 stef Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *
@@ -70,6 +70,26 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate,
         p_aout_bank->pp_aout[ p_aout_bank->i_count ] = p_aout;
         p_aout_bank->i_count++;
     }
+    /* temporary hack to switch output type (mainly for spdif)
+     * FIXME: to be adapted when several output are available */
+    else if( p_aout_bank->pp_aout[0]->fifo[0].i_type != i_type )
+    {
+        intf_WarnMsg( 1, "aout: changing aout type" );
+
+        aout_DestroyThread( p_aout_bank->pp_aout[0], NULL );
+
+        p_aout = aout_CreateThread( NULL );
+
+        /* Everything failed */
+        if( p_aout == NULL )
+        {
+            vlc_mutex_unlock( &p_aout_bank->lock );
+            return NULL;
+        }
+
+        p_aout_bank->pp_aout[0] = p_aout;
+
+    }
     else
     {
         /* Take the first audio output FIXME: take the best one */
index 5b55943234ba576fe5f85f656db95327c0c63668..04d6f8cdefcce1036e14622a7222cee3ed798360 100644 (file)
@@ -2,7 +2,7 @@
  * aout_spdif: ac3 passthrough output
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: aout_spdif.c,v 1.12 2001/06/09 17:01:22 stef Exp $
+ * $Id: aout_spdif.c,v 1.13 2001/06/12 18:16:49 stef Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Stéphane Borel <stef@via.ecp.fr>
@@ -63,7 +63,6 @@ void aout_SpdifThread( aout_thread_t * p_aout )
     int         i_blank;
     mtime_t     mplay;
     mtime_t     mdelta;
-    mtime_t     mlast = 0;
 
     /* get a blank frame ready */
     memset( pi_blank, 0, sizeof(pi_blank) );
@@ -105,14 +104,8 @@ void aout_SpdifThread( aout_thread_t * p_aout )
                                 l_start_frame];
                     mdelta = mplay - mdate();
 
-                    if( mdelta < ( 3 * SLEEP_TIME ) )
+                    if( mdelta < ( 2 * SLEEP_TIME ) )
                     {
-                        intf_WarnMsg( 12, "spdif out (%d):"
-                                          "playing frame %lld (%lld)",
-                                           i_fifo,
-                                           mdelta,
-                                           mplay-mlast );
-                        mlast = mplay;
                         /* play spdif frame to the external decoder */
                         p_aout->pf_play( p_aout,
                                      ( (byte_t *)p_aout->fifo[i_fifo].buffer
@@ -123,7 +116,12 @@ void aout_SpdifThread( aout_thread_t * p_aout )
                         p_aout->fifo[i_fifo].l_start_frame = 
                             (p_aout->fifo[i_fifo].l_start_frame + 1 )
                             & AOUT_FIFO_SIZE;
-                        
+
+                        intf_WarnMsg( 12, "spdif out (%d):"
+                                          "playing frame %lld",
+                                           i_fifo,
+                                           mdelta );
+                       
                         i_frame++;
                         i_blank = 0;
                     }
@@ -143,16 +141,7 @@ void aout_SpdifThread( aout_thread_t * p_aout )
 
         if( i_frame )
         {
-            if( mdelta > 0 )
-            {
-                /* we leave some time for aout fifo to fill and not to stress
-                 * the external decoder too much */
-                msleep( mdelta + SLEEP_TIME );
-            }
-            else if( mdelta > -SLEEP_TIME )
-            {
-                msleep( SLEEP_TIME );
-            }
+            mwait( mplay );
         }
         else
         {
index 1c0633ffd3e077cfabcd9dba12282a49e6a3f01b..9e272c5ba1193f40daf74d1ec64f5b63b3483c64 100644 (file)
@@ -2,7 +2,7 @@
  * audio_output.c : audio output thread
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: audio_output.c,v 1.63 2001/05/31 01:37:08 sam Exp $
+ * $Id: audio_output.c,v 1.64 2001/06/12 18:16:49 stef Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *
@@ -150,9 +150,10 @@ aout_thread_t *aout_CreateThread( int *pi_status )
     }
 
     /* special setting for ac3 pass-through mode */
-    if( main_GetIntVariable( AOUT_SPDIF_VAR, 0 ) )
+    if( main_GetIntVariable( AOUT_SPDIF_VAR, 0 ) && p_main->b_ac3 )
     {
-        p_aout->i_format   = AOUT_FMT_AC3;
+        intf_WarnMsg( 4, "aout info: setting ac3 spdif" );
+        p_aout->i_format = AOUT_FMT_AC3;
         p_aout->l_rate = 48000;
     }
 
index 225a23380ebcbc6abeea1f26860b91f33c2c9061..bac0a0506efedcb179a6e403b0c41d3f54f36cc6 100644 (file)
@@ -4,7 +4,7 @@
  * decoders.
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.119 2001/06/07 01:10:33 sam Exp $
+ * $Id: input.c,v 1.120 2001/06/12 18:16:49 stef Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -269,7 +269,23 @@ static void RunThread( input_thread_t *p_input )
 
         if( p_input->stream.p_new_area )
         {
-            p_input->pf_set_area( p_input, p_input->stream.p_new_area );
+            if( p_input->stream.b_seekable && p_input->pf_set_area != NULL )
+            {
+
+                p_input->pf_set_area( p_input, p_input->stream.p_new_area );
+
+                for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
+                {
+                    pgrm_descriptor_t * p_pgrm
+                                            = p_input->stream.pp_programs[i];
+                    /* Escape all decoders for the stream discontinuity they
+                     * will encounter. */
+                    input_EscapeDiscontinuity( p_input, p_pgrm );
+
+                    /* Reinitialize synchro. */
+                    p_pgrm->i_synchro_state = SYNCHRO_REINIT;
+                }
+            }
             p_input->stream.p_new_area = NULL;
         }
 
index e0f63273bcdf871fff66d8a6afcfdf79ce211ce0..b4df05a0abfa816cc9b7efa7e57132c614fde217 100644 (file)
@@ -2,7 +2,7 @@
  * input_programs.c: es_descriptor_t, pgrm_descriptor_t management
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_programs.c,v 1.57 2001/05/23 17:47:34 stef Exp $
+ * $Id: input_programs.c,v 1.58 2001/06/12 18:16:49 stef Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -631,6 +631,7 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
         {
             decoder.pf_create_thread = adec_CreateThread;
             p_config = (void *)GetAdecConfig( p_input, p_es );
+            p_main->b_ac3 = 0;
 
             /* Release the lock, not to block the input thread during
              * the creation of the thread. */
@@ -668,6 +669,7 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
             }
 
             p_config = (void *)GetAdecConfig( p_input, p_es );
+            p_main->b_ac3 = 1;
 
             /* Release the lock, not to block the input thread during
              * the creation of the thread. */
@@ -681,6 +683,7 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
         {
             decoder.pf_create_thread = lpcmdec_CreateThread;
             p_config = (void *)GetAdecConfig( p_input, p_es );
+            p_main->b_ac3 = 0;
 
             /* Release the lock, not to block the input thread during
              * the creation of the thread. */