[vlc-devel] commit: Set default item name on input_item_SetURI. (Laurent Aimar )
git version control
git at videolan.org
Wed Jan 7 20:29:35 CET 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Jan 6 21:59:33 2009 +0100| [3c4599a8fdab98cef6a4942c2601426b5bc6eb97] | committer: Laurent Aimar
Set default item name on input_item_SetURI.
It fixes item name with xpsf playlist (at least).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3c4599a8fdab98cef6a4942c2601426b5bc6eb97
---
src/input/item.c | 39 ++++++++++++++++++++-------------------
1 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/src/input/item.c b/src/input/item.c
index eacd66e..84b88ec 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -337,8 +337,21 @@ void input_item_SetURI( input_item_t *p_i, const char *psz_uri )
free( p_i->psz_uri );
p_i->psz_uri = strdup( psz_uri );
+
GuessType( p_i );
+ if( !p_i->psz_name && p_i->i_type == ITEM_TYPE_FILE )
+ {
+ const char *psz_filename = strrchr( p_i->psz_uri, DIR_SEP_CHAR );
+ if( psz_filename && *psz_filename == DIR_SEP_CHAR )
+ psz_filename++;
+ if( psz_filename && *psz_filename )
+ p_i->psz_name = strdup( psz_filename );
+ }
+
+ if( !p_i->psz_name )
+ p_i->psz_name = strdup( p_i->psz_uri );
+
vlc_mutex_unlock( &p_i->lock );
}
@@ -649,29 +662,17 @@ input_item_t *input_item_NewWithType( vlc_object_t *p_obj, const char *psz_uri,
p_input->b_fixed_name = false;
- if( psz_uri )
- p_input->psz_uri = strdup( psz_uri );
- else
- p_input->psz_uri = NULL;
-
p_input->i_type = i_type;
p_input->b_prefers_tree = false;
- if( p_input->i_type == ITEM_TYPE_UNKNOWN )
- GuessType( p_input );
+ if( psz_uri )
+ input_item_SetURI( p_input, psz_uri );
- if( psz_name != NULL )
- p_input->psz_name = strdup( psz_name );
- else if( p_input->i_type == ITEM_TYPE_FILE && p_input->psz_uri )
- {
- const char *psz_filename = strrchr( p_input->psz_uri, DIR_SEP_CHAR );
- if( psz_filename && *psz_filename == DIR_SEP_CHAR )
- psz_filename++;
- p_input->psz_name = strdup( psz_filename && *psz_filename
- ? psz_filename : p_input->psz_uri );
- }
- else
- p_input->psz_name = p_input->psz_uri ? strdup( p_input->psz_uri ) : NULL;
+ if( i_type != ITEM_TYPE_UNKNOWN )
+ p_input->i_type = i_type;
+
+ if( psz_name )
+ input_item_SetName( p_input, psz_name );
p_input->i_duration = i_duration;
More information about the vlc-devel
mailing list