]> git.sesse.net Git - vlc/blobdiff - modules/services_discovery/upnp_intel.cpp
udev: handle "change" action properly, fix disc ejection/insertion
[vlc] / modules / services_discovery / upnp_intel.cpp
index 3876947df76f57816e0652c14af796d16b80c0d0..53558b7edc182a793cc5a13758698040c67529d5 100644 (file)
@@ -49,7 +49,7 @@ struct services_discovery_sys_t
 {
     UpnpClient_Handle clientHandle;
     MediaServerList* serverList;
-    Lockable* callbackLock;
+    vlc_mutex_t callbackLock;
 };
 
 // VLC callback prototypes
@@ -90,17 +90,16 @@ static int Open( vlc_object_t *p_this )
     if(!(p_sd->p_sys = p_sys))
         return VLC_ENOMEM;
 
-    services_discovery_SetLocalizedName( p_sd, _("UPnP devices") );
-
     res = UpnpInit( 0, 0 );
     if( res != UPNP_E_SUCCESS )
     {
         msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
+        free( p_sys );
         return VLC_EGENERIC;
     }
 
     p_sys->serverList = new MediaServerList( p_sd );
-    p_sys->callbackLock = new Lockable();
+    vlc_mutex_init( &p_sys->callbackLock );
 
     res = UpnpRegisterClient( Callback, p_sd, &p_sys->clientHandle );
     if( res != UPNP_E_SUCCESS )
@@ -112,7 +111,7 @@ static int Open( vlc_object_t *p_this )
 
     res = UpnpSearchAsync( p_sys->clientHandle, 5,
             MEDIA_SERVER_DEVICE_TYPE, p_sd );
-    
+
     if( res != UPNP_E_SUCCESS )
     {
         msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
@@ -129,7 +128,7 @@ static void Close( vlc_object_t *p_this )
 
     UpnpFinish();
     delete p_sd->p_sys->serverList;
-    delete p_sd->p_sys->callbackLock;
+    vlc_mutex_destroy( &p_sd->p_sys->callbackLock );
 
     free( p_sd->p_sys );
 }
@@ -195,7 +194,7 @@ static int Callback( Upnp_EventType eventType, void* event, void* user_data )
 {
     services_discovery_t *p_sd = ( services_discovery_t* ) user_data;
     services_discovery_sys_t* p_sys = p_sd->p_sys;
-    Locker locker( p_sys->callbackLock );
+    vlc_mutex_locker locker( &p_sys->callbackLock );
 
     switch( eventType ) {
 
@@ -654,14 +653,6 @@ void MediaServer::fetchContents()
     Container* root = new Container( 0, "0", getFriendlyName() );
     _fetchContents( root );
 
-   // if ( _contents )
-   // {
-   //     PL_LOCK;
-   //     playlist_NodeEmpty( p_playlist, _playlistNode, true );
-   //     PL_UNLOCK;
-   //     delete _contents;
-   // }
-
     _contents = root;
     _contents->setInputItem( _inputItem );