]> git.sesse.net Git - vlc/commitdiff
-added eof for ts seekable streams
authorStéphane Borel <stef@videolan.org>
Mon, 3 Dec 2001 17:34:08 +0000 (17:34 +0000)
committerStéphane Borel <stef@videolan.org>
Mon, 3 Dec 2001 17:34:08 +0000 (17:34 +0000)
-close netlist when ts input ends

plugins/mpeg/input_ts.c
src/input/input_netlist.c

index 5968162fa687ad2177b373bf74d7c9fa936101a1..bf9ee96f68df1334a43c3258689dab21beaa5c45 100644 (file)
@@ -2,7 +2,7 @@
  * input_ts.c: TS demux and netlist management
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_ts.c,v 1.39 2001/11/28 15:08:05 massiot Exp $
+ * $Id: input_ts.c,v 1.40 2001/12/03 17:34:08 stef Exp $
  *
  * Authors: Henri Fallon <henri@videolan.org>
  *
@@ -225,7 +225,9 @@ static void TSEnd( input_thread_t * p_input )
 
     if( p_pat_es != NULL )
         input_DelES( p_input, p_pat_es );
+
     free(p_input->p_plugin_data);
+    input_NetlistEnd( p_input );
 }
 
 /*****************************************************************************
@@ -300,6 +302,7 @@ static int TSRead( input_thread_t * p_input,
         if( (i_read == -1) && ( (errno == EAGAIN) || (errno = EWOULDBLOCK) ) )
         {
             /* just ignore that error */
+            intf_ErrMsg( "input error: 0 bytes read" );
             i_read = 0;
         }
 #endif
@@ -308,9 +311,15 @@ static int TSRead( input_thread_t * p_input,
             intf_ErrMsg( "input error: TS readv error" );
             return( -1 );
         }
-       
+
+        /* EOF */
+        if( i_read == 0 && p_input->stream.b_seekable )
+        {
+            return( 1 );
+        }
+
         input_NetlistMviovec( p_input->p_method_data,
-                (int)(i_read/TS_PACKET_SIZE) , pp_packets );
+                (int)(((i_read-1)/TS_PACKET_SIZE)+1) , pp_packets );
 
         /* check correct TS header */
         for( i_loop=0; i_loop * TS_PACKET_SIZE < i_read; i_loop++ )
@@ -320,6 +329,10 @@ static int TSRead( input_thread_t * p_input,
                              "0x%.2x, should be 0x47)",
                              pp_packets[i_loop]->p_buffer[0] );
         }
+        for( ; i_loop < INPUT_READ_ONCE ; i_loop++ )
+        {
+            pp_packets[i_loop] = NULL;
+        }
 
         p_input->stream.p_selected_area->i_tell += i_read;
     }
index 286e9007652429cfb54d2cc4ade67809ee091b3d..4437675899a70d4a5c32f94d22b310f9747775d7 100644 (file)
@@ -6,7 +6,7 @@
  * will only be given back to netlist when refcount is zero.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_netlist.c,v 1.46 2001/12/02 17:32:19 stef Exp $
+ * $Id: input_netlist.c,v 1.47 2001/12/03 17:34:08 stef Exp $
  *
  * Authors: Henri Fallon <henri@videolan.org>
  *          Stéphane Borel <stef@videolan.org>
@@ -289,7 +289,7 @@ struct iovec * input_NetlistGetiovec( void * p_method_data )
      (p_netlist->i_iovec_end - p_netlist->i_iovec_start)
         & p_netlist->i_nb_iovec ) < p_netlist->i_read_once )
     {
-        intf_WarnMsg( 12, "input info: waiting for free iovec" );
+        intf_WarnMsg( 4, "input info: waiting for free iovec" );
         msleep( INPUT_IDLE_SLEEP );
 
         while( (
@@ -299,14 +299,14 @@ struct iovec * input_NetlistGetiovec( void * p_method_data )
             msleep( INPUT_IDLE_SLEEP );
         }
 
-        intf_WarnMsg( 12, "input info: found free iovec" );
+        intf_WarnMsg( 4, "input info: found free iovec" );
     }
 
     if( (
      (p_netlist->i_data_end - p_netlist->i_data_start)
         & p_netlist->i_nb_data ) < p_netlist->i_read_once )
     {
-        intf_WarnMsg( 12, "input info: waiting for free data packet" );
+        intf_WarnMsg( 4, "input info: waiting for free data packet" );
         msleep( INPUT_IDLE_SLEEP );
 
         while( (
@@ -316,7 +316,7 @@ struct iovec * input_NetlistGetiovec( void * p_method_data )
             msleep( INPUT_IDLE_SLEEP );
         }
 
-        intf_WarnMsg( 12, "input info: found free data packet" );
+        intf_WarnMsg( 4, "input info: found free data packet" );
     }
 
     /* readv only takes contiguous buffers 
@@ -373,7 +373,11 @@ void input_NetlistMviovec( void * p_method_data, int i_nb_iovec,
 
         pp_data[i_loop]->pi_refcount = p_netlist->pi_refcount +
                                        p_netlist->i_iovec_start;
-        //(*pp_data[i_loop]->pi_refcount)++;
+        if( (*pp_data[i_loop]->pi_refcount) != 0)
+        {
+            intf_ErrMsg( "netlist error: refcount should be 0 (%d)",
+                  (*pp_data[i_loop]->pi_refcount) );
+        }
         (*pp_data[i_loop]->pi_refcount) = 1;
 
         p_netlist->i_iovec_start ++;
@@ -485,7 +489,11 @@ struct data_packet_s * input_NetlistNewPacket( void * p_method_data,
     p_packet->b_discard_payload = 0;
 
     p_packet->pi_refcount = p_netlist->pi_refcount + p_netlist->i_iovec_start;
-    //(*p_packet->pi_refcount)++;
+    if( (*p_packet->pi_refcount) != 0)
+    {
+        intf_ErrMsg( "netlist error: refcount should be 0 (%d)",
+                     (*p_packet->pi_refcount) );
+    }
     (*p_packet->pi_refcount) = 1;
 
     p_netlist->i_iovec_start ++;
@@ -568,7 +576,7 @@ void input_NetlistDeletePacket( void * p_method_data, data_packet_t * p_data )
     /* Update reference counter */
     (*p_data->pi_refcount)--;
 
-    if( (*p_data->pi_refcount) <= 0 )
+    if( (*p_data->pi_refcount) == 0 )
     {
         (*p_data->pi_refcount) = 0;
         p_netlist->i_iovec_end++;
@@ -576,6 +584,11 @@ void input_NetlistDeletePacket( void * p_method_data, data_packet_t * p_data )
         p_netlist->p_free_iovec[p_netlist->i_iovec_end].iov_base =
                                                             p_data->p_buffer;
     }
+    else if( (*p_data->pi_refcount) < 0 )
+    {
+        intf_ErrMsg( "netlist error: refcount can't be negative (%d)",
+                     (*p_data->pi_refcount) );
+    }
  
     /* unlock */
     vlc_mutex_unlock (&p_netlist->lock);
@@ -615,7 +628,7 @@ void input_NetlistDeletePES( void * p_method_data, pes_packet_t * p_pes )
         /* Update reference counter */
         (*p_current_packet->pi_refcount)--;
 
-        if( (*p_current_packet->pi_refcount) <= 0 )
+        if( (*p_current_packet->pi_refcount) == 0 )
         {
             (*p_current_packet->pi_refcount) = 0;
             p_netlist->i_iovec_end++;
@@ -623,6 +636,11 @@ void input_NetlistDeletePES( void * p_method_data, pes_packet_t * p_pes )
             p_netlist->p_free_iovec[p_netlist->i_iovec_end].iov_base =
                     p_current_packet->p_buffer;
         }
+        else if( (*p_current_packet->pi_refcount) < 0 )
+        {
+            intf_ErrMsg( "netlist error: refcount can't be negative (%d)",
+                         (*p_current_packet->pi_refcount) );
+        }
     
         p_next_packet = p_current_packet->p_next;
         p_current_packet->p_next = NULL;