Skip to content
Snippets Groups Projects
Commit 20b82357 authored by Romain Vimont's avatar Romain Vimont Committed by Hugo Beauzée-Luyssen
Browse files

mtp: fix device name

LIBMTP_Get_Friendlyname() may return an empty string. Since it is not
NULL, this name was used as the device name.

Instead, in that case, fallback to the model name.
parent 71955299
No related branches found
No related tags found
1 merge request!945services discovery: mtp: rework implementation
......@@ -174,6 +174,19 @@ static void *Run( void *data )
return NULL;
}
static char *GetDeviceName( LIBMTP_mtpdevice_t *p_device )
{
char *name = LIBMTP_Get_Friendlyname( p_device );
if ( !EMPTY_STR( name ) )
return name;
name = LIBMTP_Get_Modelname( p_device );
if ( !EMPTY_STR( name ) )
return name;
return strdup( "MTP Device" );
}
/*****************************************************************************
* Everything else
*****************************************************************************/
......@@ -187,10 +200,9 @@ static int AddDevice( services_discovery_t *p_sd,
if( ( p_device = LIBMTP_Open_Raw_Device( p_raw_device ) ) != NULL )
{
if( !( psz_name = LIBMTP_Get_Friendlyname( p_device ) ) )
if( !( psz_name = LIBMTP_Get_Modelname( p_device ) ) )
if( !( psz_name = strdup( N_( "MTP Device" ) ) ) )
return VLC_ENOMEM;
psz_name = GetDeviceName( p_device );
if ( !psz_name )
return VLC_ENOMEM;
msg_Info( p_sd, "Found device: %s", psz_name );
p_sys->i_bus = p_raw_device->bus_location;
p_sys->i_dev = p_raw_device->devnum;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment