]> git.sesse.net Git - vlc/blobdiff - src/input/input.c
* Fixed a warning for *BSD compilation.
[vlc] / src / input / input.c
index 1c29372b6505289678d9a327c7047201fc9a6810..975c02ece4c31fdabbfb306a9f1145b05fdff780 100644 (file)
@@ -4,7 +4,7 @@
  * decoders.
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.103 2001/04/28 23:19:19 henri Exp $
+ * $Id: input.c,v 1.109 2001/05/25 13:20:10 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -73,8 +73,6 @@
 
 #include "main.h"
 
- /* #include <netutils.h> */
-
 
 /*****************************************************************************
  * Local prototypes
@@ -133,6 +131,7 @@ input_thread_t *input_CreateThread ( playlist_item_t *p_item, int *pi_status )
     p_input->stream.i_area_nb = 0;
     p_input->stream.pp_areas = NULL;
     p_input->stream.p_selected_area = NULL;
+    p_input->stream.p_new_area = NULL;
     /* By default there is one areas in a stream */
     input_AddArea( p_input );
     p_input->stream.p_selected_area = p_input->stream.pp_areas[0];
@@ -143,10 +142,6 @@ input_thread_t *input_CreateThread ( playlist_item_t *p_item, int *pi_status )
     p_input->stream.control.b_mute = 0;
     p_input->stream.control.b_bw = 0;
 
-    /* Initialize default settings for spawned decoders */
-    p_input->p_default_aout = p_main->p_aout;
-    p_input->p_default_vout = p_main->p_vout;
-
     /* Create thread and set locks. */
     vlc_mutex_init( &p_input->stream.stream_lock );
     vlc_cond_init( &p_input->stream.stream_wait );
@@ -243,6 +238,12 @@ static void RunThread( input_thread_t *p_input )
 
         vlc_mutex_lock( &p_input->stream.stream_lock );
 
+        if( p_input->stream.p_new_area )
+        {
+            p_input->pf_set_area( p_input, p_input->stream.p_new_area );
+            p_input->stream.p_new_area = NULL;
+        }
+
         if( p_input->stream.p_selected_area->i_seek != NO_SEEK )
         {
             if( p_input->stream.b_seekable && p_input->pf_seek != NULL )
@@ -265,6 +266,18 @@ static void RunThread( input_thread_t *p_input )
             p_input->stream.p_selected_area->i_seek = NO_SEEK;
         }
 
+        if( p_input->stream.p_removed_es )
+        {
+            input_UnselectES( p_input, p_input->stream.p_removed_es );
+            p_input->stream.p_removed_es = NULL;
+        }
+
+        if( p_input->stream.p_newly_selected_es )
+        {
+            input_SelectES( p_input, p_input->stream.p_newly_selected_es );
+            p_input->stream.p_newly_selected_es = NULL;
+        }
+
         vlc_mutex_unlock( &p_input->stream.stream_lock );
 
         i_error = p_input->pf_read( p_input, pp_packets );
@@ -281,7 +294,7 @@ static void RunThread( input_thread_t *p_input )
             {
                 /* End of file - we do not set b_die because only the
                  * interface is allowed to do so. */
-                intf_WarnMsg( 1, "input: EOF reached" );
+                intf_WarnMsg( 3, "input: EOF reached" );
                 p_input->b_eof = 1;
             }
             else
@@ -318,8 +331,7 @@ static int InitThread( input_thread_t * p_input )
     p_input->c_packets_trashed          = 0;
 #endif
 
-    p_input->p_input_module = module_Need( p_main->p_bank,
-                                           MODULE_CAPABILITY_INPUT,
+    p_input->p_input_module = module_Need( MODULE_CAPABILITY_INPUT,
                                            (probedata_t *)p_input );
 
     if( p_input->p_input_module == NULL )
@@ -350,7 +362,7 @@ static int InitThread( input_thread_t * p_input )
     {
         /* We barfed -- exit nicely */
         p_input->pf_close( p_input );
-        module_Unneed( p_main->p_bank, p_input->p_input_module );
+        module_Unneed( p_input->p_input_module );
         return( -1 );
     }
 
@@ -360,7 +372,7 @@ static int InitThread( input_thread_t * p_input )
     {
         /* We barfed -- exit nicely */
         p_input->pf_close( p_input );
-        module_Unneed( p_main->p_bank, p_input->p_input_module );
+        module_Unneed( p_input->p_input_module );
         return( -1 );
     }
 
@@ -414,7 +426,7 @@ static void EndThread( input_thread_t * p_input )
     p_input->pf_close( p_input );
 
     /* Release modules */
-    module_Unneed( p_main->p_bank, p_input->p_input_module );
+    module_Unneed( p_input->p_input_module );
 
 }
 
@@ -511,7 +523,7 @@ void input_FileOpen( input_thread_t * p_input )
     p_input->stream.p_selected_area->i_tell = 0;
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
-    intf_Msg( "input: opening file `%s'", p_input->p_source );
+    intf_WarnMsg( 1, "input: opening file `%s'", p_input->p_source );
 #ifndef WIN32
     if( (p_input->i_handle = open( psz_name,
                                    /*O_NONBLOCK | O_LARGEFILE*/0 )) == (-1) )
@@ -532,7 +544,7 @@ void input_FileOpen( input_thread_t * p_input )
  *****************************************************************************/
 void input_FileClose( input_thread_t * p_input )
 {
-    intf_Msg( "input: closing file `%s'", p_input->p_source );
+    intf_WarnMsg( 1, "input: closing file `%s'", p_input->p_source );
     close( p_input->i_handle );
 
     return;
@@ -546,13 +558,10 @@ void input_FileClose( input_thread_t * p_input )
 void input_NetworkOpen( input_thread_t * p_input )
 {
     char                *psz_server = NULL;
+    char                *psz_broadcast = NULL;
     int                 i_port = 0;
     int                 i_opt;
     struct sockaddr_in  sock;
-    char *              psz_broadcast;
-    
-    /* Are we broadcasting ? */
-    psz_broadcast = main_GetPszVariable( INPUT_BROADCAST_VAR, NULL );
     
     /* Get the remote server */
     if( p_input->p_source != NULL )
@@ -589,7 +598,31 @@ void input_NetworkOpen( input_thread_t * p_input )
                 *psz_port = '\0';
                 psz_port++;
 
-                i_port = atoi( psz_port );
+                psz_broadcast = psz_port;
+                while( *psz_broadcast && *psz_broadcast != ':' )
+                {
+                    psz_broadcast++;
+                }
+
+                if( *psz_broadcast )
+                {
+                    *psz_broadcast = '\0';
+                    psz_broadcast++;
+                    while( *psz_broadcast && *psz_broadcast == ':' )
+                    {
+                        psz_broadcast++;
+                    }
+                }
+                else
+                {
+                    psz_broadcast = NULL;
+                }
+
+                /* port before broadcast address */
+                if( *psz_port != ':' )
+                {
+                    i_port = atoi( psz_port );
+                }
             }
         }
         else
@@ -610,7 +643,16 @@ void input_NetworkOpen( input_thread_t * p_input )
     {
         i_port = main_GetIntVariable( INPUT_PORT_VAR, INPUT_PORT_DEFAULT );
     }
-    
+
+    if( psz_broadcast == NULL )
+    {
+        /* Are we broadcasting ? */
+        psz_broadcast = main_GetPszVariable( INPUT_BROADCAST_VAR, NULL );
+    }
+
+    intf_WarnMsg( 2, "input: server: %s port: %d broadcast: %s",
+                     psz_server, i_port, psz_broadcast );
+
     /* Open a SOCK_DGRAM (UDP) socket, in the AF_INET domain, automatic (0)
      * protocol */
     p_input->i_handle = socket( AF_INET, SOCK_DGRAM, 0 );