Commit f2513588 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

dvdnav: clean up, fix error message and probing encoding (fix #3816)

Paths for error message must be UTF-8; they were locale.
Paths for probing must be UTF-8 also, as vlc_fopen() does the
conversion to locale internally.
parent 140a43f3
...@@ -186,7 +186,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -186,7 +186,7 @@ static int Open( vlc_object_t *p_this )
demux_sys_t *p_sys; demux_sys_t *p_sys;
dvdnav_t *p_dvdnav; dvdnav_t *p_dvdnav;
int i_angle; int i_angle;
char *psz_name; char *psz_file;
char *psz_code; char *psz_code;
if( !p_demux->psz_file || !*p_demux->psz_file ) if( !p_demux->psz_file || !*p_demux->psz_file )
...@@ -195,38 +195,44 @@ static int Open( vlc_object_t *p_this ) ...@@ -195,38 +195,44 @@ static int Open( vlc_object_t *p_this )
if( !p_demux->psz_access || !*p_demux->psz_access ) if( !p_demux->psz_access || !*p_demux->psz_access )
return VLC_EGENERIC; return VLC_EGENERIC;
psz_name = var_CreateGetString( p_this, "dvd" ); psz_file = var_InheritString( p_this, "dvd" );
if( !psz_name )
{
psz_name = strdup("");
}
} }
else else
psz_name = ToLocaleDup( p_demux->psz_file ); psz_file = strdup( p_demux->psz_file );
#ifdef WIN32 #ifdef WIN32
/* Remove trailing backslash, otherwise dvdnav_open will fail */ if( psz_file != NULL )
if( *psz_name && *(psz_name + strlen(psz_name) - 1) == '\\' )
{ {
*(psz_name + strlen(psz_name) - 1) = '\0'; /* Remove trailing backslash, otherwise dvdnav_open will fail */
size_t flen = strlen( psz_file );
if( flen > 0 && psz_file[flen - 1] == '\\' )
psz_file[flen - 1] = '\0';
} }
else
psz_file = strdup("");
#endif #endif
if( unlikely(psz_file == NULL) )
return VLC_EGENERIC;
/* Try some simple probing to avoid going through dvdnav_open too often */ /* Try some simple probing to avoid going through dvdnav_open too often */
if( ProbeDVD( p_demux, psz_name ) != VLC_SUCCESS ) if( ProbeDVD( p_demux, psz_file ) != VLC_SUCCESS )
{ {
free( psz_name ); free( psz_file );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Open dvdnav */ /* Open dvdnav */
if( dvdnav_open( &p_dvdnav, psz_name ) != DVDNAV_STATUS_OK ) const char *psz_path = ToLocale( psz_file );
{ if( dvdnav_open( &p_dvdnav, psz_path ) != DVDNAV_STATUS_OK )
msg_Warn( p_demux, "cannot open dvdnav" ); p_dvdnav = NULL;
free( psz_name ); LocaleFree( psz_path );
if( p_dvdnav == NULL )
{
msg_Warn( p_demux, "cannot open DVD (%s)", psz_file);
free( psz_file );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
free( psz_name ); free( psz_file );
/* Fill p_demux field */ /* Fill p_demux field */
DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys; DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment