[vlc-devel] commit: UPnP CyberLink: do not spawn a useless poll thread (untested) ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Aug 28 20:19:32 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Thu Aug 28 21:22:23 2008 +0300| [d20d0224fd61c40e7bf95e9d01aaa547abeb074e] | committer: Rémi Denis-Courmont 

UPnP CyberLink: do not spawn a useless poll thread (untested)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d20d0224fd61c40e7bf95e9d01aaa547abeb074e
---

 modules/services_discovery/upnp_cc.cpp |   64 +++++++++++--------------------
 1 files changed, 23 insertions(+), 41 deletions(-)

diff --git a/modules/services_discovery/upnp_cc.cpp b/modules/services_discovery/upnp_cc.cpp
index 7dfe82d..209225c 100644
--- a/modules/services_discovery/upnp_cc.cpp
+++ b/modules/services_discovery/upnp_cc.cpp
@@ -69,35 +69,6 @@ vlc_module_begin();
 vlc_module_end();
 
 /*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-
-/* Main functions */
-    static void Run    ( services_discovery_t *p_sd );
-
-/*****************************************************************************
- * Open: initialize and create stuff
- *****************************************************************************/
-static int Open( vlc_object_t *p_this )
-{
-    services_discovery_t *p_sd = ( services_discovery_t* )p_this;
-
-    p_sd->pf_run = Run;
-
-    services_discovery_SetLocalizedName( p_sd, _("Devices") );
-
-    return VLC_SUCCESS;
-}
-
-
-/*****************************************************************************
- * Close:
- *****************************************************************************/
-static void Close( vlc_object_t *p_this )
-{
-}
-
-/*****************************************************************************
  * Run: main UPnP thread
  *****************************************************************************
  * Processes UPnP events
@@ -145,24 +116,35 @@ class UPnPHandler : public MediaPlayer, public DeviceChangeListener,
             addSearchResponseListener( this );
             //addEventListener( this );
         }
-
 };
 
-static void Run( services_discovery_t *p_sd )
+/*****************************************************************************
+ * Open: initialize and create stuff
+ *****************************************************************************/
+static int Open( vlc_object_t *p_this )
 {
-    UPnPHandler u( p_sd );
+    services_discovery_t *p_sd = ( services_discovery_t* )p_this;
 
-    u.start();
+    services_discovery_SetLocalizedName( p_sd, _("Devices") );
 
-    msg_Dbg( p_sd, "UPnP discovery started" );
-    /* read SAP packets */
-    while( vlc_object_alive (p_sd) )
-    {
-        msleep( 500 );
-    }
+    UPnPHandler *u = new UPnPHandler( p_sd );
+    u->start( );
+    msg_Dbg( p_sd, "upnp discovery started" );
+    p_sd->p_private = u;
+
+    return VLC_SUCCESS;
+}
+
+
+/*****************************************************************************
+ * Close:
+ *****************************************************************************/
+static void Close( vlc_object_t *p_this )
+{
+    UPnPHandler *u = (UPnPHandler *)p_this->p_private;
+    u->stop( );
 
-    u.stop();
-    msg_Dbg( p_sd, "UPnP discovery stopped" );
+    msg_Dbg( p_this, "upnp discovery started" );
 }
 
 




More information about the vlc-devel mailing list