From 2ffa2bd3d0a506be2a6c9e53edffeee442350397 Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Sun, 1 Oct 2006 19:07:48 +0000 Subject: [PATCH] src/input/item.c: if we don't have an item name and item is a file, then only use the filename (and not the full path) as the item's name others: if we only have a path and no interesting name, let the core decide what name to use --- modules/control/http/rpn.c | 9 +-------- modules/control/rc.c | 2 +- modules/demux/playlist/gvp.c | 1 + modules/demux/playlist/qtl.c | 2 +- modules/gui/beos/InterfaceWindow.cpp | 2 +- modules/gui/qt4/dialogs_provider.cpp | 8 ++++---- modules/gui/skins2/commands/cmd_add_item.cpp | 4 ++-- modules/gui/wxwidgets/dialogs.cpp | 6 +++--- modules/gui/wxwidgets/dialogs/open.cpp | 2 +- modules/gui/wxwidgets/interface.cpp | 2 +- src/input/item.c | 19 ++++++++++++++----- src/libvlc-common.c | 2 -- src/libvlc.c | 2 +- src/misc/win32_specific.c | 4 ++-- 14 files changed, 33 insertions(+), 32 deletions(-) diff --git a/modules/control/http/rpn.c b/modules/control/http/rpn.c index ee9291bd23..598b874c59 100644 --- a/modules/control/http/rpn.c +++ b/modules/control/http/rpn.c @@ -843,14 +843,7 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t *vars, free( mrl ); mrl = tmp; - if( !*psz_name ) - { - p_input = E_(MRLParse)( p_intf, mrl, mrl ); - } - else - { - p_input = E_(MRLParse)( p_intf, mrl, psz_name ); - } + p_input = E_(MRLParse)( p_intf, mrl, psz_name ); if( !p_input || !p_input->psz_uri || !*p_input->psz_uri ) { diff --git a/modules/control/rc.c b/modules/control/rc.c index b6fab5e45f..6e89bf2644 100644 --- a/modules/control/rc.c +++ b/modules/control/rc.c @@ -2290,7 +2290,7 @@ static input_item_t *parse_MRL( intf_thread_t *p_intf, char *psz_mrl ) /* Now create a playlist item */ if( psz_item_mrl ) { - p_item = input_ItemNew( p_intf, psz_item_mrl, psz_item_mrl ); + p_item = input_ItemNew( p_intf, psz_item_mrl, NULL ); for( i = 0; i < i_options; i++ ) { input_ItemAddOption( p_item, ppsz_options[i] ); diff --git a/modules/demux/playlist/gvp.c b/modules/demux/playlist/gvp.c index fe3033a0fd..e88dce2293 100644 --- a/modules/demux/playlist/gvp.c +++ b/modules/demux/playlist/gvp.c @@ -68,6 +68,7 @@ int E_(Import_GVP)( vlc_object_t *p_this ) demux_t *p_demux = (demux_t *)p_this; byte_t *p_peek; + /* FIXME: we need to skip comment lines !!!! */ CHECK_PEEK( p_peek, 12 ); if( !POKE( p_peek, "gvp_version:", 12 ) ) { diff --git a/modules/demux/playlist/qtl.c b/modules/demux/playlist/qtl.c index 841d074508..eabd67464b 100644 --- a/modules/demux/playlist/qtl.c +++ b/modules/demux/playlist/qtl.c @@ -369,7 +369,7 @@ static int Demux( demux_t *p_demux ) if( psz_qtnext ) { p_input = input_ItemNewExt( p_sys->p_playlist, - psz_qtnext, psz_qtnext, 0, NULL, -1 ); + psz_qtnext, NULL, 0, NULL, -1 ); playlist_AddWhereverNeeded( p_sys->p_playlist, p_input, p_sys->p_current, p_sys->p_item_in_category, (p_sys->i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE, diff --git a/modules/gui/beos/InterfaceWindow.cpp b/modules/gui/beos/InterfaceWindow.cpp index 84b1db9881..b883bfb486 100644 --- a/modules/gui/beos/InterfaceWindow.cpp +++ b/modules/gui/beos/InterfaceWindow.cpp @@ -749,7 +749,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) if( p_playlist ) { - playlist_PlaylistAdd( p_playlist, path.Path(), path.Path(), + playlist_PlaylistAdd( p_playlist, path.Path(), NULL, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); } } diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp index 83cf198b3c..d35805a3d0 100644 --- a/modules/gui/qt4/dialogs_provider.cpp +++ b/modules/gui/qt4/dialogs_provider.cpp @@ -207,7 +207,7 @@ void DialogsProvider::simplePLAppendDialog() foreach( file, files ) { const char * psz_utf8 = qtu( file ); - playlist_PlaylistAdd( THEPL, psz_utf8, psz_utf8, + playlist_PlaylistAdd( THEPL, psz_utf8, NULL, PLAYLIST_APPEND | PLAYLIST_PREPARSE, PLAYLIST_END ); } } @@ -232,7 +232,7 @@ void DialogsProvider::simpleOpenDialog() { const char * psz_utf8 = qtu( files[i] ); /* Play the first one, parse and enqueue the other ones */ - playlist_PlaylistAdd( THEPL, psz_utf8, psz_utf8, + playlist_PlaylistAdd( THEPL, psz_utf8, NULL, PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) | ( i ? PLAYLIST_PREPARSE : 0 ), PLAYLIST_END ); @@ -256,7 +256,7 @@ void DialogsProvider::openDirectory() QString dir = QFileDialog::getExistingDirectory ( 0, _("Open directory") ); const char *psz_utf8 = qtu( dir ); - input_item_t *p_input = input_ItemNewExt( THEPL, psz_utf8, psz_utf8, + input_item_t *p_input = input_ItemNewExt( THEPL, psz_utf8, NULL, 0, NULL, -1 ); playlist_PlaylistAddInput( THEPL, p_input, PLAYLIST_APPEND, PLAYLIST_END ); @@ -267,7 +267,7 @@ void DialogsProvider::openMLDirectory() QString dir = QFileDialog::getExistingDirectory ( 0, _("Open directory") ); const char *psz_utf8 = qtu( dir ); - input_item_t *p_input = input_ItemNewExt( THEPL, psz_utf8, psz_utf8, + input_item_t *p_input = input_ItemNewExt( THEPL, psz_utf8, NULL, 0, NULL, -1 ); playlist_MLAddInput( THEPL, p_input, PLAYLIST_APPEND, PLAYLIST_END ); input_Read( THEPL, p_input, VLC_FALSE ); diff --git a/modules/gui/skins2/commands/cmd_add_item.cpp b/modules/gui/skins2/commands/cmd_add_item.cpp index 771ec13c91..dbfdea032a 100644 --- a/modules/gui/skins2/commands/cmd_add_item.cpp +++ b/modules/gui/skins2/commands/cmd_add_item.cpp @@ -37,13 +37,13 @@ void CmdAddItem::execute() if( m_playNow ) { // Enqueue and play the item - playlist_PlaylistAdd( pPlaylist, m_name.c_str(),m_name.c_str(), + playlist_PlaylistAdd( pPlaylist, m_name.c_str(), NULL, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); } else { // Enqueue the item only - playlist_PlaylistAdd( pPlaylist, m_name.c_str(), m_name.c_str(), + playlist_PlaylistAdd( pPlaylist, m_name.c_str(), NULL, PLAYLIST_APPEND, PLAYLIST_END ); } } diff --git a/modules/gui/wxwidgets/dialogs.cpp b/modules/gui/wxwidgets/dialogs.cpp index 23ac8f78da..34a1fe4858 100644 --- a/modules/gui/wxwidgets/dialogs.cpp +++ b/modules/gui/wxwidgets/dialogs.cpp @@ -446,12 +446,12 @@ void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event ) { char *psz_utf8 = wxFromLocale( paths[i] ); if( event.GetInt() ) - playlist_PlaylistAdd( p_playlist, psz_utf8, psz_utf8, + playlist_PlaylistAdd( p_playlist, psz_utf8, NULL, PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) | (i ? PLAYLIST_PREPARSE : 0 ), PLAYLIST_END ); else - playlist_PlaylistAdd( p_playlist, psz_utf8, psz_utf8, + playlist_PlaylistAdd( p_playlist, psz_utf8, NULL, PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END ); wxLocaleFree( psz_utf8 ); } @@ -477,7 +477,7 @@ void DialogsProvider::OnOpenDirectory( wxCommandEvent& event ) { wxString path = p_dir_dialog->GetPath(); char *psz_utf8 = wxFromLocale( path ); - playlist_PlaylistAdd( p_playlist, psz_utf8, psz_utf8, + playlist_PlaylistAdd( p_playlist, psz_utf8, NULL, PLAYLIST_APPEND | (event.GetInt() ? PLAYLIST_GO : 0), PLAYLIST_END ); wxLocaleFree( psz_utf8 ); diff --git a/modules/gui/wxwidgets/dialogs/open.cpp b/modules/gui/wxwidgets/dialogs/open.cpp index 375c8d52ee..b30fe5044b 100644 --- a/modules/gui/wxwidgets/dialogs/open.cpp +++ b/modules/gui/wxwidgets/dialogs/open.cpp @@ -1169,7 +1169,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) char *psz_utf8; psz_utf8 = wxFromLocale( mrl[i] ); - p_input = input_ItemNew( p_intf, psz_utf8, psz_utf8 ); + p_input = input_ItemNew( p_intf, psz_utf8, NULL ); wxLocaleFree( psz_utf8 ); /* Insert options */ diff --git a/modules/gui/wxwidgets/interface.cpp b/modules/gui/wxwidgets/interface.cpp index 83c9325d82..608f065f8d 100644 --- a/modules/gui/wxwidgets/interface.cpp +++ b/modules/gui/wxwidgets/interface.cpp @@ -1304,7 +1304,7 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord, { char *psz_utf8 = wxDnDFromLocale( filenames[i] ); - playlist_PlaylistAdd( p_playlist, psz_utf8, psz_utf8, + playlist_PlaylistAdd( p_playlist, psz_utf8, NULL, PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO), PLAYLIST_END ); diff --git a/src/input/item.c b/src/input/item.c index c47aba83c6..f07b1aae46 100644 --- a/src/input/item.c +++ b/src/input/item.c @@ -241,17 +241,26 @@ input_item_t *input_ItemNewWithType( vlc_object_t *p_obj, const char *psz_uri, else p_input->psz_uri = NULL; - if( psz_name != NULL ) - p_input->psz_name = strdup( psz_name ); - else - p_input->psz_name = strdup ( p_input->psz_uri ); - p_input->i_type = i_type; p_input->b_prefers_tree = VLC_FALSE; if( p_input->i_type == ITEM_TYPE_UNKNOWN ) GuessType( p_input ); + if( psz_name != NULL ) + p_input->psz_name = strdup( psz_name ); + else if( p_input->i_type == ITEM_TYPE_AFILE + || p_input->i_type == ITEM_TYPE_VFILE ) + { + 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 = strdup( p_input->psz_uri ); + p_input->i_duration = i_duration; p_input->ppsz_options = NULL; diff --git a/src/libvlc-common.c b/src/libvlc-common.c index f7d5029b9b..a997b2e896 100644 --- a/src/libvlc-common.c +++ b/src/libvlc-common.c @@ -162,8 +162,6 @@ libvlc_int_t * libvlc_InternalCreate( void ) var_Get( p_libvlc_global, "libvlc", &lockval ); vlc_mutex_lock( lockval.p_address ); - - i_instances++; if( !libvlc_global.b_ready ) diff --git a/src/libvlc.c b/src/libvlc.c index 72e96f9c46..469c3ad42f 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -315,7 +315,7 @@ int VLC_AddTarget( int i_object, char const *psz_target, int i_err; LIBVLC_PLAYLIST_FUNC; i_err = playlist_PlaylistAddExt( p_libvlc->p_playlist, psz_target, - psz_target, i_mode, i_pos, -1, + NULL, i_mode, i_pos, -1, ppsz_options, i_options ); LIBVLC_PLAYLIST_FUNC_END; return i_err; diff --git a/src/misc/win32_specific.c b/src/misc/win32_specific.c index 3d816322d2..a01f10ebd1 100644 --- a/src/misc/win32_specific.c +++ b/src/misc/win32_specific.c @@ -322,13 +322,13 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam, if( i_opt || config_GetInt( p_this, "playlist-enqueue" ) ) { playlist_PlaylistAddExt( p_playlist, ppsz_argv[i_opt], - ppsz_argv[i_opt], PLAYLIST_APPEND , + NULL, PLAYLIST_APPEND , PLAYLIST_END, -1, (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ), i_options ); } else { playlist_PlaylistAddExt( p_playlist, ppsz_argv[i_opt], - ppsz_argv[i_opt], PLAYLIST_APPEND | PLAYLIST_GO, + NULL, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, -1, (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ), i_options ); -- 2.39.2