]> git.sesse.net Git - vlc/blobdiff - src/misc/netutils.c
* ./configure.in: do not try to link with -lrt if not using pthreads. This
[vlc] / src / misc / netutils.c
index 72d3cfbd8c351201b6126e3cac7e7ab6a3838683..03601ddea0c9bc6c366081439b39ef1a6815ef52 100644 (file)
@@ -2,7 +2,7 @@
  * netutils.c: various network functions
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: netutils.c,v 1.68 2002/06/01 18:04:49 sam Exp $
+ * $Id: netutils.c,v 1.73 2002/07/31 20:56:53 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Benoit Steiner <benny@via.ecp.fr>
@@ -75,6 +75,7 @@
 #endif
 
 #include "netutils.h"
+#include "vlc_playlist.h"
 
 #include "network.h"
 
@@ -86,7 +87,7 @@
  * as it depends on the VideoLAN channel server, which isn't frozen for
  * the time being.
  *****************************************************************************/
-struct input_channel_s
+struct input_channel_t
 {
     int         i_channel;                         /* current channel number */
     mtime_t     last_change;                             /* last change date */
@@ -156,6 +157,11 @@ int __network_ChannelJoin( vlc_object_t *p_this, int i_channel )
     struct timeval delay;
     fd_set fds;
 
+    if( p_this->p_vlc->p_channel->i_channel == i_channel )
+    {
+        return 0;
+    }
+
     if( !config_GetInt( p_this, "network-channel" ) )
     {
         msg_Err( p_this, "channels disabled, to enable them, use the"
@@ -163,18 +169,6 @@ int __network_ChannelJoin( vlc_object_t *p_this, int i_channel )
         return -1;
     }
 
-    /* If last change is too recent, wait a while */
-//    if( mdate() - p_this->p_vlc->p_channel->last_change
-//            < INPUT_CHANNEL_CHANGE_DELAY )
-//    {
-//        msg_Warn( p_this, "waiting before changing channel" );
-        /* XXX Isn't this completely brain-damaged ??? -- Sam */
-        /* Yes it is. I don't think this is still justified with the new
-         * vlanserver --Meuuh */
-//        mwait( p_this->p_vlc->p_channel->last_change
-//                   + INPUT_CHANNEL_CHANGE_DELAY );
-//    }
-
     if( config_GetInt( p_this, "ipv4" ) )
     {
         psz_network = "ipv4";
@@ -203,13 +197,12 @@ int __network_ChannelJoin( vlc_object_t *p_this, int i_channel )
     socket_desc.i_server_port = i_port;
 
     /* Find an appropriate network module */
-    p_network = module_Need( p_this, MODULE_CAPABILITY_NETWORK, psz_network,
-                             &socket_desc );
+    p_network = module_Need( p_this, "network", psz_network/*, &socket_desc*/ );
     if( p_network == NULL )
     {
         return( -1 );
     }
-    module_Unneed( p_network );
+    module_Unneed( p_this, p_network );
 
     free( psz_vlcs ); /* Do we really need this ? -- Meuuh */
     i_fd = socket_desc.i_handle;
@@ -270,26 +263,18 @@ int __network_ChannelJoin( vlc_object_t *p_this, int i_channel )
     {
         msg_Dbg( p_this, "vlcs said '%s'", psz_mess + 2 );
     }
-    else /* We got something to play ! FIXME: not very nice */
+    else
     {
-#if 0
-#   define p_item (&p_this->p_vlc->p_playlist->p_item \
-                       [ p_this->p_vlc->p_playlist->i_index + 1])
-        vlc_mutex_lock( &p_this->p_vlc->p_playlist->change_lock );
-        if( p_item )
-        {
-            free( p_item->psz_name );
-            p_item->psz_name = strdup( psz_mess );
-            /* Unlock _afterwards_ */
-            vlc_mutex_unlock( &p_this->p_vlc->p_playlist->change_lock );
-        }
-        else
+        /* We got something to play ! */
+        playlist_t *p_playlist;
+        p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
+                                              FIND_ANYWHERE );
+        if( p_playlist != NULL )
         {
-            /* Unlock _before_ */
-            vlc_mutex_unlock( &p_this->p_vlc->p_playlist->change_lock );
-            intf_PlaylistAdd( p_this->p_vlc->p_playlist, 0, psz_mess );
+            playlist_Add( p_playlist, psz_mess,
+                          PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+            vlc_object_release( p_playlist );
         }
-#endif
     }
 
     /* Close the socket and return nicely */