X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fservices_discovery%2Fmtp.c;h=a0e4ed5105d59b2df72493c4d9ccc77866c43325;hb=439a6cf0b81ae925dad94444affb915c32590be8;hp=55d0004d2420061017b601a018433be7939d079c;hpb=d601e4ed290edf58e9ace5c28f06c77ebf072004;p=vlc diff --git a/modules/services_discovery/mtp.c b/modules/services_discovery/mtp.c index 55d0004d24..a0e4ed5105 100644 --- a/modules/services_discovery/mtp.c +++ b/modules/services_discovery/mtp.c @@ -25,12 +25,10 @@ #endif #include -#include #include -#include #include -#include "libmtp.h" +#include /***************************************************************************** * Module descriptor @@ -38,7 +36,7 @@ static int Open( vlc_object_t * ); static void Close( vlc_object_t * ); -VLC_SD_PROBE_HELPER("mtp", N_("MTP devices")) +VLC_SD_PROBE_HELPER("mtp", "MTP devices", SD_CAT_DEVICES) vlc_module_begin() set_shortname( "MTP" ) @@ -47,7 +45,7 @@ vlc_module_begin() set_subcategory( SUBCAT_PLAYLIST_SD ) set_capability( "services_discovery", 0 ) set_callbacks( Open, Close ) - linked_with_a_crap_library_which_uses_atexit() + cannot_unload_broken_library() VLC_SD_PROBE_SUBMODULE vlc_module_end() @@ -120,8 +118,8 @@ static void Close( vlc_object_t *p_this ) services_discovery_t *p_sd = ( services_discovery_t * )p_this; free( p_sd->p_sys->psz_name ); - vlc_cancel (p_sd->p_sys->thread); - vlc_join (p_sd->p_sys->thread, NULL); + vlc_cancel( p_sd->p_sys->thread ); + vlc_join( p_sd->p_sys->thread, NULL ); free( p_sd->p_sys ); } @@ -147,6 +145,8 @@ static void *Run( void *data ) msg_Dbg( p_sd, "New device found" ); if( AddDevice( p_sd, &p_rawdevices[0] ) == VLC_SUCCESS ) i_status = 1; + else + i_status = 2; } else { @@ -161,7 +161,13 @@ static void *Run( void *data ) } free( p_rawdevices ); vlc_restorecancel(canc); - msleep( 500000 ); + if( i_status == 2 ) + { + msleep( 5000000 ); + i_status = 0; + } + else + msleep( 500000 ); } return NULL; } @@ -216,7 +222,7 @@ static int AddDevice( services_discovery_t *p_sd, } else { - msg_Warn( p_sd, "No device found, after all" ); + msg_Info( p_sd, "The device seems to be mounted, unmount it first" ); return VLC_EGENERIC; } } @@ -236,8 +242,7 @@ static void AddTrack( services_discovery_t *p_sd, LIBMTP_track_t *p_track ) msg_Err( p_sd, "Error adding %s, skipping it", p_track->filename ); return; } - if( ( p_input = input_item_New( p_sd, psz_string, - p_track->title ) ) == NULL ) + if( ( p_input = input_item_New( psz_string, p_track->title ) ) == NULL ) { msg_Err( p_sd, "Error adding %s, skipping it", p_track->filename ); free( psz_string ); @@ -267,11 +272,10 @@ static void AddTrack( services_discovery_t *p_sd, LIBMTP_track_t *p_track ) static void CloseDevice( services_discovery_t *p_sd ) { input_item_t **pp_items = p_sd->p_sys->pp_items; - int i_i; if( pp_items != NULL ) { - for( i_i = 0; i_i < p_sd->p_sys->i_count; i_i++ ) + for( int i_i = 0; i_i < p_sd->p_sys->i_count; i_i++ ) { if( pp_items[i_i] != NULL ) {