]> git.sesse.net Git - vlc/blobdiff - modules/services_discovery/mtp.c
Remove useless <sys/stat.h> includes
[vlc] / modules / services_discovery / mtp.c
index 55c104ea4f315dcf40778767e3eb3283fed009a4..f82edf12509033e910a88e43d7aef3dfeb91c3d5 100644 (file)
 #include <vlc_common.h>
 #include <vlc_playlist.h>
 #include <vlc_plugin.h>
-#include <errno.h>
 #include <vlc_charset.h>
 #include <vlc_interface.h>
 #include <vlc_services_discovery.h>
 
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
 #include "libmtp.h"
 
 /*****************************************************************************
@@ -44,6 +39,8 @@
 static int Open( vlc_object_t * );
 static void Close( vlc_object_t * );
 
+VLC_SD_PROBE_HELPER("mtp", N_("MTP devices"))
+
 vlc_module_begin()
     set_shortname( "MTP" )
     set_description( N_( "MTP devices" ) )
@@ -52,6 +49,8 @@ vlc_module_begin()
     set_capability( "services_discovery", 0 )
     set_callbacks( Open, Close )
     linked_with_a_crap_library_which_uses_atexit()
+
+    VLC_SD_PROBE_SUBMODULE
 vlc_module_end()
 
 
@@ -121,8 +120,7 @@ static void Close( vlc_object_t *p_this )
 {
     services_discovery_t *p_sd = ( services_discovery_t * )p_this;
 
-    if( p_sd->p_sys->psz_name != NULL )
-        free( p_sd->p_sys->psz_name );
+    free( p_sd->p_sys->psz_name );
     vlc_cancel (p_sd->p_sys->thread);
     vlc_join (p_sd->p_sys->thread, NULL);
     free( p_sd->p_sys );
@@ -147,7 +145,7 @@ static void *Run( void *data )
              i_status == 0 )
         {
             /* Found a new device, add it */
-            msg_Info( p_sd, "New device found" );
+            msg_Dbg( p_sd, "New device found" );
             if( AddDevice( p_sd, &p_rawdevices[0] ) == VLC_SUCCESS )
                 i_status = 1;
         }
@@ -191,12 +189,17 @@ static int AddDevice( services_discovery_t *p_sd,
         p_sd->p_sys->i_product_id = p_raw_device->device_entry.product_id;
         if( ( p_track = LIBMTP_Get_Tracklisting_With_Callback( p_device,
                             CountTracks, p_sd ) ) == NULL )
-            msg_Info( p_sd, "No tracks on the device" );
+        {
+            msg_Warn( p_sd, "No tracks on the device" );
+        }
         else
         {
             if( !( p_sd->p_sys->pp_items = calloc( p_sd->p_sys->i_tracks_num,
                                                    sizeof( input_item_t * ) ) ) )
+            {
+                free( psz_name );
                 return VLC_ENOMEM;
+            }
             p_sd->p_sys->i_count = 0;
             while( p_track != NULL )
             {
@@ -214,7 +217,7 @@ static int AddDevice( services_discovery_t *p_sd,
     }
     else
     {
-        msg_Info( p_sd, "No device found, after all" );
+        msg_Warn( p_sd, "No device found, after all" );
         return VLC_EGENERIC;
     }
 }
@@ -238,12 +241,14 @@ static void AddTrack( services_discovery_t *p_sd, LIBMTP_track_t *p_track )
                                     p_track->title ) ) == NULL )
     {
         msg_Err( p_sd, "Error adding %s, skipping it", p_track->filename );
+        free( psz_string );
         return;
     }
+    free( psz_string );
+
     input_item_SetArtist( p_input, p_track->artist );
     input_item_SetGenre( p_input, p_track->genre );
     input_item_SetAlbum( p_input, p_track->album );
-    free( psz_string );
     if( asprintf( &psz_string, "%d", p_track->tracknumber ) != -1 )
     {
         input_item_SetTrackNum( p_input, psz_string );