[vlc-commits] medialibrary: Fix and update the playlist 'Convert' function
Benjamin Arnaud
git at videolan.org
Fri Apr 16 11:56:29 UTC 2021
vlc | branch: master | Benjamin Arnaud <benjamin.arnaud at videolabs.io> | Fri Apr 9 10:00:44 2021 +0200| [d5836cb3994137ea4fe3ee60d0470cfa88cd3367] | committer: Pierre Lamot
medialibrary: Fix and update the playlist 'Convert' function
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d5836cb3994137ea4fe3ee60d0470cfa88cd3367
---
include/vlc_media_library.h | 9 ++++++++-
modules/misc/medialibrary/entities.cpp | 11 +++++++++++
src/misc/medialibrary.c | 3 ++-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index eeaa1460f6..b038566d7a 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -229,9 +229,16 @@ typedef struct vlc_ml_media_t
typedef struct vlc_ml_playlist_t
{
int64_t i_id;
+
char* psz_name;
- uint32_t i_creation_date;
+
+ char* psz_mrl;
+
char* psz_artwork_mrl;
+
+ uint32_t i_creation_date;
+
+ bool b_is_read_only;
} vlc_ml_playlist_t;
typedef struct vlc_ml_artist_t
diff --git a/modules/misc/medialibrary/entities.cpp b/modules/misc/medialibrary/entities.cpp
index 02c106e4e1..1e7bbd1cef 100644
--- a/modules/misc/medialibrary/entities.cpp
+++ b/modules/misc/medialibrary/entities.cpp
@@ -410,9 +410,20 @@ bool Convert( const medialibrary::IPlaylist* input, vlc_ml_playlist_t& output )
{
output.i_id = input->id();
+ output.i_creation_date = input->creationDate();
+
+ output.b_is_read_only = input->isReadOnly();
+
if( !strdup_helper( input->name(), output.psz_name ) ||
!strdup_helper( input->artworkMrl(), output.psz_artwork_mrl ) )
return false;
+
+ // NOTE: mrl() must only be called when isReadOnly() is true.
+ if( output.b_is_read_only && !strdup_helper( input->mrl(), output.psz_mrl ) )
+ return false;
+ else
+ output.psz_mrl = nullptr;
+
return true;
}
diff --git a/src/misc/medialibrary.c b/src/misc/medialibrary.c
index 140f055b5f..f83fc8584b 100644
--- a/src/misc/medialibrary.c
+++ b/src/misc/medialibrary.c
@@ -233,8 +233,9 @@ void vlc_ml_genre_release( vlc_ml_genre_t* p_genre )
static void vlc_ml_playlist_release_inner( vlc_ml_playlist_t* p_playlist )
{
- free( p_playlist->psz_artwork_mrl );
free( p_playlist->psz_name );
+ free( p_playlist->psz_mrl );
+ free( p_playlist->psz_artwork_mrl );
}
void vlc_ml_playlist_release( vlc_ml_playlist_t* p_playlist )
More information about the vlc-commits
mailing list