[vlc-commits] playlist: rationalize playlist_Export() prototype
Rémi Denis-Courmont
git at videolan.org
Wed Nov 16 23:05:06 CET 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov 16 23:22:59 2016 +0200| [77207fe1c111d6c080e818e6e97fccdb5b781c1f] | committer: Rémi Denis-Courmont
playlist: rationalize playlist_Export() prototype
Passing a playlist item parameter to a locked playlist function cannot
make sense. This replaces the parameter with a boolean to select the
playlist or media lirary - like playlist_AddInput().
The prototype bug was introduced ed0b72e3 before the playlist tree
locking was defined/implemented, and somehow did not get corrected
until now.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=77207fe1c111d6c080e818e6e97fccdb5b781c1f
---
include/vlc_playlist.h | 6 +++---
modules/gui/macosx/VLCMainMenu.m | 6 +++---
modules/gui/qt/dialogs_provider.cpp | 2 +-
modules/gui/skins2/commands/cmd_playlist.cpp | 3 +--
src/playlist/loadsave.c | 13 ++++++-------
5 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 748e5d2..d0ee7b0 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -299,13 +299,13 @@ VLC_API int playlist_Status( playlist_t * );
/**
* Export a node of the playlist to a certain type of playlistfile
- * \param p_playlist the playlist to export
+ * \param b_playlist true for the playlist, false for the media library
* \param psz_filename the location where the exported file will be saved
- * \param p_export_root the root node to export
* \param psz_type the type of playlist file to create (m3u, pls, ..)
* \return VLC_SUCCESS on success
*/
-VLC_API int playlist_Export( playlist_t *p_playlist, const char *psz_name, playlist_item_t *p_export_root, const char *psz_type );
+VLC_API int playlist_Export( playlist_t *p_playlist, const char *psz_name,
+ bool b_playlist, const char *psz_type );
/**
* Open a playlist file, add its content to the current playlist
diff --git a/modules/gui/macosx/VLCMainMenu.m b/modules/gui/macosx/VLCMainMenu.m
index 28d2f18..46634b7 100644
--- a/modules/gui/macosx/VLCMainMenu.m
+++ b/modules/gui/macosx/VLCMainMenu.m
@@ -1133,7 +1133,7 @@
playlist_Export(p_playlist,
[actualFilename fileSystemRepresentation],
- p_playlist->p_playing, "export-m3u");
+ true, "export-m3u");
} else if ([_playlistSaveAccessoryPopup indexOfSelectedItem] == 1) {
NSString *actualFilename;
NSRange range;
@@ -1147,7 +1147,7 @@
playlist_Export(p_playlist,
[actualFilename fileSystemRepresentation],
- p_playlist->p_playing, "export-xspf");
+ true, "export-xspf");
} else {
NSString *actualFilename;
NSRange range;
@@ -1161,7 +1161,7 @@
playlist_Export(p_playlist,
[actualFilename fileSystemRepresentation],
- p_playlist->p_playing, "export-html");
+ true, "export-html");
}
}
}
diff --git a/modules/gui/qt/dialogs_provider.cpp b/modules/gui/qt/dialogs_provider.cpp
index f322b8c..64a7deb 100644
--- a/modules/gui/qt/dialogs_provider.cpp
+++ b/modules/gui/qt/dialogs_provider.cpp
@@ -660,7 +660,7 @@ void DialogsProvider::saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_n
if ( psz_selected_module )
{
playlist_Export( p_playlist, qtu( toNativeSeparators( file ) ),
- p_node, psz_selected_module );
+ true, psz_selected_module );
getSettings()->setValue( "last-playlist-ext", psz_last_playlist_ext );
}
}
diff --git a/modules/gui/skins2/commands/cmd_playlist.cpp b/modules/gui/skins2/commands/cmd_playlist.cpp
index f87b93b..7cfe8d5 100644
--- a/modules/gui/skins2/commands/cmd_playlist.cpp
+++ b/modules/gui/skins2/commands/cmd_playlist.cpp
@@ -98,8 +98,7 @@ void CmdPlaylistSave::execute()
return;
}
- playlist_Export( pPlaylist, m_file.c_str(),
- pPlaylist->p_playing, psz_module );
+ playlist_Export( pPlaylist, m_file.c_str(), true, psz_module );
}
}
diff --git a/src/playlist/loadsave.c b/src/playlist/loadsave.c
index adbc92d..0114cef 100644
--- a/src/playlist/loadsave.c
+++ b/src/playlist/loadsave.c
@@ -39,22 +39,19 @@
#include <vlc_modules.h>
int playlist_Export( playlist_t * p_playlist, const char *psz_filename,
- playlist_item_t *p_export_root, const char *psz_type )
+ bool b_playlist, const char *psz_type )
{
- if( p_export_root == NULL ) return VLC_EGENERIC;
-
playlist_export_t *p_export =
vlc_custom_create( p_playlist, sizeof( *p_export ), "playlist export" );
if( unlikely(p_export == NULL) )
return VLC_ENOMEM;
msg_Dbg( p_export, "saving %s to file %s",
- p_export_root->p_input->psz_name, psz_filename );
+ b_playlist ? "playlist" : "media library", psz_filename );
int ret = VLC_EGENERIC;
/* Prepare the playlist_export_t structure */
- p_export->p_root = p_export_root;
p_export->psz_filename = psz_filename;
p_export->p_file = vlc_fopen( psz_filename, "wt" );
if( p_export->p_file == NULL )
@@ -68,6 +65,9 @@ int playlist_Export( playlist_t * p_playlist, const char *psz_filename,
/* And call the module ! All work is done now */
playlist_Lock( p_playlist );
+ p_export->p_root = b_playlist ? p_playlist->p_playing
+ : p_playlist->p_media_library;
+
p_module = module_need( p_export, "playlist export", psz_type, true );
playlist_Unlock( p_playlist );
@@ -209,8 +209,7 @@ int playlist_MLDump( playlist_t *p_playlist )
if ( asprintf( &psz_temp, "%s.tmp%"PRIu32, psz_dirname, (uint32_t)getpid() ) < 1 )
return VLC_EGENERIC;
- int i_ret = playlist_Export( p_playlist, psz_temp, p_playlist->p_media_library,
- "export-xspf" );
+ int i_ret = playlist_Export( p_playlist, psz_temp, false, "export-xspf" );
if ( i_ret != VLC_SUCCESS )
{
vlc_unlink( psz_temp );
More information about the vlc-commits
mailing list