[vlc-commits] [Git][videolan/vlc][master] 6 commits: contrib: medialibrary: update to 0.13.1
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Sep 30 16:13:27 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
6fd2d7eb by Alaric Senat at 2024-09-30T15:28:54+00:00
contrib: medialibrary: update to 0.13.1
This release brings fixes to 0.13.0 and a small set of non-breaking
changes.
Medialibrary 0.13.1 new non breaking features:
* Media manipulation in playlists can now be done in ranges
(videolan/medialibrary!777)
* All media can now be retrieved in a single request
(videolan/medialibrary!773)
Medialibrary 0.13.1 fixes:
* Fixed a FS discover crash on Windows (videolan/medialibrary#483) Fixed
* a startup crash for applications not implementing a cache worker
(videolan/medialibrary!770)
All the contrib patches have been included in this release.
- - - - -
776080ed by Alaric Senat at 2024-09-30T15:28:54+00:00
medialibrary: expose "all media" listing
A method listing all media indexed from the medialibrary was missing and
was introduced in 0.13.1.
- - - - -
7d2b096d by Alaric Senat at 2024-09-30T15:28:54+00:00
medialibrary: playlist: allow appending a range of media
- - - - -
9e686dca by Alaric Senat at 2024-09-30T15:28:54+00:00
medialibrary: playlist: allow inserting a range of media
- - - - -
31e76890 by Alaric Senat at 2024-09-30T15:28:54+00:00
medialibrary: playlist: allow moving a range of media
- - - - -
8b78a74a by Alaric Senat at 2024-09-30T15:28:54+00:00
medialibrary: playlist: allow removing a range of media
- - - - -
13 changed files:
- − contrib/src/medialibrary/0002-win32-DeviceLister-don-t-use-wchar_t-string-if-they-.patch
- − contrib/src/medialibrary/0003-utils-Directory-don-t-use-wchar_t-string-if-they-are.patch
- − contrib/src/medialibrary/0004-test-common-don-t-use-wchar_t-string-if-they-are-NUL.patch
- − contrib/src/medialibrary/0005-LockFile-don-t-use-char-string-if-they-are-NULL.patch
- − contrib/src/medialibrary/0006-fs-Directory-don-t-use-char-string-if-they-are-NULL.patch
- − contrib/src/medialibrary/0007-utils-Directory-don-t-use-char-string-if-they-are-NU.patch
- − contrib/src/medialibrary/Fix-CacheWorker.patch
- contrib/src/medialibrary/SHA512SUMS
- contrib/src/medialibrary/rules.mak
- include/vlc_media_library.h
- modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp
- modules/gui/qt/medialibrary/mlplaylistmodel.cpp
- modules/misc/medialibrary/medialibrary.cpp
Changes:
=====================================
contrib/src/medialibrary/0002-win32-DeviceLister-don-t-use-wchar_t-string-if-they-.patch deleted
=====================================
@@ -1,57 +0,0 @@
-From af536d9421c471b386c1e2f308cc515679f8e26a Mon Sep 17 00:00:00 2001
-From: Steve Lhomme <robux4 at ycbcr.xyz>
-Date: Fri, 28 Jun 2024 07:59:28 +0200
-Subject: [PATCH 2/7] win32: DeviceLister: don't use wchar_t string if they are
- NULL
-
----
- src/filesystem/win32/DeviceLister.cpp | 19 +++++++++++++++----
- 1 file changed, 15 insertions(+), 4 deletions(-)
-
-diff --git a/src/filesystem/win32/DeviceLister.cpp b/src/filesystem/win32/DeviceLister.cpp
-index 1f8c2a13..f784190c 100644
---- a/src/filesystem/win32/DeviceLister.cpp
-+++ b/src/filesystem/win32/DeviceLister.cpp
-@@ -74,8 +74,13 @@ std::vector<CommonDeviceLister::Device> DeviceLister::networkDevices() const
- ss << "WNetEnumResource error: #" << GetLastError();
- throw fs::errors::DeviceListing{ ss.str() };
- }
-- std::string mountpoint = charset::FromWide( netResources->lpLocalName ).get();
-- std::string uuid = charset::FromWide( netResources->lpRemoteName ).get();
-+ auto utf8_local = charset::FromWide( netResources->lpLocalName );
-+ auto utf8_remote = charset::FromWide( netResources->lpRemoteName );
-+ if ( !utf8_local || !utf8_remote )
-+ continue;
-+
-+ std::string mountpoint = utf8_local.get();
-+ std::string uuid = utf8_remote.get();
- devs.emplace_back( std::move( uuid ),
- std::vector<std::string>{ utils::file::toMrl( mountpoint ) }, true );
- } while ( true );
-@@ -118,7 +123,10 @@ std::vector<CommonDeviceLister::Device> DeviceLister::localDevices() const
-
- if ( GetVolumePathNamesForVolumeName( volumeName, buffer, buffLength, &buffLength ) == 0 )
- continue;
-- std::string mountpoint = charset::FromWide( buffer ).get();
-+ auto utf8_buffer = charset::FromWide( buffer );
-+ if ( !utf8_buffer )
-+ continue;
-+ std::string mountpoint = utf8_buffer.get();
-
- // Filter out anything which isn't a removable or fixed drive. We don't care about network
- // drive here.
-@@ -126,7 +134,10 @@ std::vector<CommonDeviceLister::Device> DeviceLister::localDevices() const
- if ( type != DRIVE_REMOVABLE && type != DRIVE_FIXED && type != DRIVE_REMOTE )
- continue;
-
-- std::string uuid = charset::FromWide( volumeName ).get();
-+ auto utf8_volume = charset::FromWide( volumeName );
-+ if ( !utf8_volume )
-+ continue;
-+ std::string uuid = utf8_volume.get();
-
- LOG_INFO( "Discovered device ", uuid, "; mounted on ", mountpoint, "; removable: ",
- type == DRIVE_REMOVABLE ? "yes" : "no" );
---
-2.45.0.windows.1
-
=====================================
contrib/src/medialibrary/0003-utils-Directory-don-t-use-wchar_t-string-if-they-are.patch deleted
=====================================
@@ -1,38 +0,0 @@
-From 9245cc70cbae11d2a5d1d97c9e5f4a5a921119f3 Mon Sep 17 00:00:00 2001
-From: Steve Lhomme <robux4 at ycbcr.xyz>
-Date: Fri, 28 Jun 2024 08:00:14 +0200
-Subject: [PATCH 3/7] utils: Directory: don't use wchar_t string if they are
- NULL
-
----
- src/utils/Directory.cpp | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/src/utils/Directory.cpp b/src/utils/Directory.cpp
-index a5c3684f..463b0c26 100644
---- a/src/utils/Directory.cpp
-+++ b/src/utils/Directory.cpp
-@@ -104,6 +104,11 @@ std::string toAbsolute( const std::string& path )
- throw errors::System{ GetLastError(), "Failed to convert to absolute path" };
- }
- auto upath = charset::FromWide( buff );
-+ if ( !upath )
-+ {
-+ LOG_ERROR( "Failed to convert ", path, " to UTF8" );
-+ throw errors::System{ GetLastError(), "Failed to convert to UTF8" };
-+ }
- return file::toFolderPath( upath.get() );
- #endif
- }
-@@ -209,6 +214,8 @@ bool rmdir( std::string path )
- do
- {
- auto file = charset::FromWide( f.cFileName );
-+ if ( !file )
-+ continue;
- if ( strcmp( file.get(), "." ) == 0 ||
- strcmp( file.get(), ".." ) == 0 )
- continue;
---
-2.45.0.windows.1
-
=====================================
contrib/src/medialibrary/0004-test-common-don-t-use-wchar_t-string-if-they-are-NUL.patch deleted
=====================================
@@ -1,25 +0,0 @@
-From 19b3e069d3485f5bccc2712d9f96da1628800a22 Mon Sep 17 00:00:00 2001
-From: Steve Lhomme <robux4 at ycbcr.xyz>
-Date: Fri, 28 Jun 2024 08:00:31 +0200
-Subject: [PATCH 4/7] test: common: don't use wchar_t string if they are NULL
-
----
- test/common/util.h | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/test/common/util.h b/test/common/util.h
-index d0ff02ce..79d92fe0 100644
---- a/test/common/util.h
-+++ b/test/common/util.h
-@@ -36,6 +36,8 @@ static inline std::string getTempDir()
- WCHAR path[MAX_PATH];
- GetTempPathW( MAX_PATH, path );
- auto utf8 = medialibrary::charset::FromWide( path );
-+ if ( !utf8 )
-+ return {};
- return utf8.get();
- #else
- return "/tmp/";
---
-2.45.0.windows.1
-
=====================================
contrib/src/medialibrary/0005-LockFile-don-t-use-char-string-if-they-are-NULL.patch deleted
=====================================
@@ -1,26 +0,0 @@
-From fce5e4d3a7d9cc199dcc530b6f2d2dae0a544aa7 Mon Sep 17 00:00:00 2001
-From: Steve Lhomme <robux4 at ycbcr.xyz>
-Date: Fri, 28 Jun 2024 08:17:23 +0200
-Subject: [PATCH 5/7] LockFile: don't use char string if they are NULL
-
----
- src/LockFile.cpp | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/src/LockFile.cpp b/src/LockFile.cpp
-index acd65502..75f224dc 100644
---- a/src/LockFile.cpp
-+++ b/src/LockFile.cpp
-@@ -50,6 +50,9 @@ std::unique_ptr<LockFile> LockFile::lock( const std::string& mlFolderPath )
- Handle handle;
- #ifdef _WIN32
- auto wide = charset::ToWide( lockFile.c_str() );
-+ if ( !wide )
-+ handle = INVALID_HANDLE_VALUE;
-+ else
- # if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
- handle = CreateFile2(wide.get(), GENERIC_WRITE, 0, CREATE_ALWAYS, NULL);
- # else
---
-2.45.0.windows.1
-
=====================================
contrib/src/medialibrary/0006-fs-Directory-don-t-use-char-string-if-they-are-NULL.patch deleted
=====================================
@@ -1,28 +0,0 @@
-From 154cccbef7e6be13f9f57d9eeef5eabfb5182a6a Mon Sep 17 00:00:00 2001
-From: Steve Lhomme <robux4 at ycbcr.xyz>
-Date: Fri, 28 Jun 2024 08:17:58 +0200
-Subject: [PATCH 6/7] fs: Directory: don't use char string if they are NULL
-
----
- src/filesystem/libvlc/Directory.cpp | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/src/filesystem/libvlc/Directory.cpp b/src/filesystem/libvlc/Directory.cpp
-index 17594ab7..b08813c5 100644
---- a/src/filesystem/libvlc/Directory.cpp
-+++ b/src/filesystem/libvlc/Directory.cpp
-@@ -174,8 +174,10 @@ void Directory::addFile( std::string mrl, fs::IFile::LinkedFileType linkedType,
-
- #ifdef _WIN32
- /* We can't use _wstat here, see #323 */
-+ auto wpath = charset::ToWide( path.c_str() );
- WIN32_FILE_ATTRIBUTE_DATA attributes;
-- if ( GetFileAttributesExW( charset::ToWide( path.c_str() ).get(),
-+ if ( !wpath ||
-+ GetFileAttributesExW( wpath.get(),
- GetFileExInfoStandard, &attributes ) == 0 )
- {
- LOG_ERROR( "Failed to get ", path, " attributes" );
---
-2.45.0.windows.1
-
=====================================
contrib/src/medialibrary/0007-utils-Directory-don-t-use-char-string-if-they-are-NU.patch deleted
=====================================
@@ -1,61 +0,0 @@
-From 71eb7e35818a03b0d0dc71ce45ea4ead406e5278 Mon Sep 17 00:00:00 2001
-From: Steve Lhomme <robux4 at ycbcr.xyz>
-Date: Fri, 28 Jun 2024 08:23:47 +0200
-Subject: [PATCH 7/7] utils: Directory: don't use char string if they are NULL
-
----
- src/utils/Directory.cpp | 10 ++++++++--
- 1 file changed, 8 insertions(+), 2 deletions(-)
-
-diff --git a/src/utils/Directory.cpp b/src/utils/Directory.cpp
-index 463b0c26..a0ff15ad 100644
---- a/src/utils/Directory.cpp
-+++ b/src/utils/Directory.cpp
-@@ -73,6 +73,8 @@ bool isDirectory( const std::string& path )
- {
- #ifdef _WIN32
- auto wpath = charset::ToWide( path.c_str() );
-+ if ( !wpath )
-+ throw errors::System{ GetLastError(), ERR_FS_OBJECT_ACCESS + path };
- auto attr = GetFileAttributes( wpath.get() );
- if ( attr == INVALID_FILE_ATTRIBUTES )
- throw errors::System{ GetLastError(), ERR_FS_OBJECT_ACCESS + path };
-@@ -98,7 +100,7 @@ std::string toAbsolute( const std::string& path )
- #else
- wchar_t buff[MAX_PATH];
- auto wpath = charset::ToWide( path.c_str() );
-- if ( GetFullPathNameW( wpath.get(), MAX_PATH, buff, nullptr ) == 0 )
-+ if ( !wpath || GetFullPathNameW( wpath.get(), MAX_PATH, buff, nullptr ) == 0 )
- {
- LOG_ERROR( "Failed to convert ", path, " to absolute path" );
- throw errors::System{ GetLastError(), "Failed to convert to absolute path" };
-@@ -136,7 +138,7 @@ bool mkdir( const std::string& path )
- continue;
- }
- auto wFullPath = charset::ToWide( fullPath.c_str() );
-- if ( _wmkdir( wFullPath.get() ) != 0 )
-+ if ( !wFullPath || _wmkdir( wFullPath.get() ) != 0 )
- #else
- if ( ::mkdir( fullPath.c_str(), S_IRWXU ) != 0 )
- #endif
-@@ -203,6 +205,8 @@ bool rmdir( std::string path )
- WIN32_FIND_DATA f;
- auto pattern = path + '*';
- auto wpattern = charset::ToWide( pattern.c_str() );
-+ if ( !wpattern )
-+ return false;
- auto h = FindFirstFile( wpattern.get(), &f );
- if ( h == INVALID_HANDLE_VALUE )
- {
-@@ -231,6 +235,8 @@ bool rmdir( std::string path )
- }
- } while ( FindNextFile( h, &f ) != 0 );
- auto wPath = charset::ToWide( path.c_str() );
-+ if ( !wPath )
-+ return false;
- auto res = _wrmdir( wPath.get() );
- if ( res == 0 )
- return true;
---
-2.45.0.windows.1
-
=====================================
contrib/src/medialibrary/Fix-CacheWorker.patch deleted
=====================================
@@ -1,87 +0,0 @@
-From ab1de729b73138b1a7b6dfa5e17a6a63063dd2ab Mon Sep 17 00:00:00 2001
-From: Alaric Senat <alaric at videolabs.io>
-Date: Wed, 27 Mar 2024 11:42:57 +0100
-Subject: [PATCH] CacheWorker: Fail when the cache implementation isn't
- provided
-
-Allow the library users not to provide an implementation for the cacher.
----
- src/CacheWorker.cpp | 20 ++++++++++++++------
- src/CacheWorker.h | 2 +-
- 2 files changed, 15 insertions(+), 7 deletions(-)
-
-diff --git a/src/CacheWorker.cpp b/src/CacheWorker.cpp
-index 0b08267a..06b1dfa7 100644
---- a/src/CacheWorker.cpp
-+++ b/src/CacheWorker.cpp
-@@ -58,14 +58,22 @@ void CacheWorker::setCacher( std::shared_ptr<ICacher> cacher )
- m_cacher = std::move( cacher );
- }
-
--void CacheWorker::queueTask( std::shared_ptr<Media> m, bool cache )
-+bool CacheWorker::queueTask( std::shared_ptr<Media> m, bool cache )
- {
- std::lock_guard<compat::Mutex> lock{ m_mutex };
-+
-+ if ( m_cacher == nullptr )
-+ {
-+ LOG_WARN( "Cache implementation not provided" );
-+ return false;
-+ }
-+
- m_tasks.emplace( std::move( m ), cache );
- if ( m_thread.joinable() == false )
- m_thread = compat::Thread{ &CacheWorker::run, this };
- else
- m_cond.notify_all();
-+ return true;
- }
-
- bool CacheWorker::cacheMedia( std::shared_ptr<Media> m )
-@@ -78,8 +86,7 @@ bool CacheWorker::cacheMedia( std::shared_ptr<Media> m )
- LOG_DEBUG( "Media ", m->id(), " is already cached" );
- return true;
- }
-- queueTask( std::move( m ), true );
-- return true;
-+ return queueTask( std::move( m ), true );
- }
-
- bool CacheWorker::removeCached( std::shared_ptr<Media> m )
-@@ -92,8 +99,7 @@ bool CacheWorker::removeCached( std::shared_ptr<Media> m )
- LOG_DEBUG( "Media ", m->id(), " is not cached" );
- return false;
- }
-- queueTask( std::move( m ), false );
-- return true;
-+ return queueTask( std::move( m ), false );
- }
-
- void CacheWorker::cacheSubscriptions()
-@@ -117,7 +123,9 @@ void CacheWorker::resume()
-
- void CacheWorker::stop()
- {
-- m_cacher->interrupt();
-+ if ( m_cacher != nullptr )
-+ m_cacher->interrupt();
-+
- {
- std::lock_guard<compat::Mutex> lock{ m_mutex };
- if ( m_thread.joinable() == false )
-diff --git a/src/CacheWorker.h b/src/CacheWorker.h
-index 57088c92..01e33c0c 100644
---- a/src/CacheWorker.h
-+++ b/src/CacheWorker.h
-@@ -73,7 +73,7 @@ private:
- void checkCache();
- bool removeFromCache( const std::string& mrl );
- bool evictIfNeeded( const File& file, Subscription* s, IFile::CacheType cacheType );
-- void queueTask( std::shared_ptr<Media> m, bool cache );
-+ bool queueTask( std::shared_ptr<Media> m, bool cache );
- uint64_t availableSubscriptionCacheSize() const;
- uint64_t availableCacheSize() const;
-
---
-2.43.0
-
=====================================
contrib/src/medialibrary/SHA512SUMS
=====================================
@@ -1 +1 @@
-e2a75a1c59c899a7a8828e6b8bf7e106f50ad896e42f3888ab6a9423eddcdde75f4889120781f303a30d182421cf179698e0a5c968d8b0523d5a874274428289 medialibrary-0.13.0.tar.bz2
+b57d03623bad9e67a179b78543b9994a39619b14dbdce8f069485a1ceee6623826a37a401a7b5bbe1fb042a0fcf14d18ee67f5b431600963fa14da9006e275d1 medialibrary-0.13.1.tar.bz2
=====================================
contrib/src/medialibrary/rules.mak
=====================================
@@ -1,4 +1,4 @@
-MEDIALIBRARY_VERSION := 0.13.0
+MEDIALIBRARY_VERSION := 0.13.1
MEDIALIBRARY_URL := https://code.videolan.org/videolan/medialibrary/-/archive/$(MEDIALIBRARY_VERSION)/medialibrary-$(MEDIALIBRARY_VERSION).tar.bz2
PKGS += medialibrary
@@ -15,13 +15,6 @@ $(TARBALLS)/medialibrary-$(MEDIALIBRARY_VERSION).tar.bz2:
medialibrary: medialibrary-$(MEDIALIBRARY_VERSION).tar.bz2 .sum-medialibrary
$(UNPACK)
- $(APPLY) $(SRC)/medialibrary/Fix-CacheWorker.patch
- $(APPLY) $(SRC)/medialibrary/0002-win32-DeviceLister-don-t-use-wchar_t-string-if-they-.patch
- $(APPLY) $(SRC)/medialibrary/0003-utils-Directory-don-t-use-wchar_t-string-if-they-are.patch
- $(APPLY) $(SRC)/medialibrary/0004-test-common-don-t-use-wchar_t-string-if-they-are-NUL.patch
- $(APPLY) $(SRC)/medialibrary/0005-LockFile-don-t-use-char-string-if-they-are-NULL.patch
- $(APPLY) $(SRC)/medialibrary/0006-fs-Directory-don-t-use-char-string-if-they-are-NULL.patch
- $(APPLY) $(SRC)/medialibrary/0007-utils-Directory-don-t-use-char-string-if-they-are-NU.patch
$(MOVE)
.medialibrary: medialibrary crossfile.meson
=====================================
include/vlc_media_library.h
=====================================
@@ -477,6 +477,8 @@ enum vlc_ml_list_queries
{
/* General listing: */
+ VLC_ML_LIST_MEDIA, /**< arg1 (out): vlc_ml_media_list_t** */
+ VLC_ML_COUNT_MEDIA, /**< arg1 (out): size_t* */
VLC_ML_LIST_VIDEOS, /**< arg1 (out): vlc_ml_media_list_t** */
VLC_ML_COUNT_VIDEOS, /**< arg1 (out): size_t* */
VLC_ML_LIST_AUDIOS, /**< arg1 (out): vlc_ml_media_list_t** */
@@ -626,10 +628,10 @@ enum vlc_ml_control
/* Playlist management */
VLC_ML_PLAYLIST_CREATE, /**< arg1: const char*; arg2(out): vlc_ml_playlist_t**; can fail */
VLC_ML_PLAYLIST_DELETE, /**< arg1: playlist id; can fail */
- VLC_ML_PLAYLIST_APPEND, /**< arg1: playlist id; arg2: media id; can fail */
- VLC_ML_PLAYLIST_INSERT, /**< arg1: playlist id; arg2: media id; arg3: position; can fail */
- VLC_ML_PLAYLIST_MOVE, /**< arg1: playlist id; arg2: from; arg3: to; can fail */
- VLC_ML_PLAYLIST_REMOVE, /**< arg1: playlist id; arg2: position; can fail */
+ VLC_ML_PLAYLIST_APPEND, /**< arg1: playlist id; arg2: pointer on media ids; arg3: media ids count; can fail */
+ VLC_ML_PLAYLIST_INSERT, /**< arg1: playlist id; arg2: pointer on media ids; arg3: media ids count; arg4: position; can fail */
+ VLC_ML_PLAYLIST_MOVE, /**< arg1: playlist id; arg2: from; arg3: to; arg4: count; can fail */
+ VLC_ML_PLAYLIST_REMOVE, /**< arg1: playlist id; arg2: position; arg3: count; can fail */
VLC_ML_PLAYLIST_RENAME, /**< arg1: playlist id; arg2: const char*; can fail */
/* Set Favorites */
@@ -1221,37 +1223,37 @@ vlc_ml_playlist_delete( vlc_medialibrary_t * p_ml, int64_t i_playlist_id )
}
static inline int
-vlc_ml_playlist_append( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, int64_t i_media_id )
+vlc_ml_playlist_append( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, const int64_t *i_media_ids, size_t i_media_id_count )
{
assert( p_ml != NULL );
- return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_APPEND, i_playlist_id, i_media_id );
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_APPEND, i_playlist_id, i_media_ids, i_media_id_count );
}
static inline int
-vlc_ml_playlist_insert( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, int64_t i_media_id,
- uint32_t i_position )
+vlc_ml_playlist_insert( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, const int64_t *i_media_ids,
+ size_t i_media_id_count, uint32_t i_position )
{
assert( p_ml != NULL );
- return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_INSERT, i_playlist_id, i_media_id, i_position );
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_INSERT, i_playlist_id, i_media_ids, i_media_id_count, i_position );
}
static inline int
vlc_ml_playlist_move( vlc_medialibrary_t * p_ml,
- int64_t i_playlist_id, uint32_t i_from, uint32_t i_to )
+ int64_t i_playlist_id, uint32_t i_from, uint32_t i_to, uint32_t i_count )
{
assert( p_ml != NULL );
- return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_MOVE, i_playlist_id, i_from, i_to );
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_MOVE, i_playlist_id, i_from, i_to, i_count );
}
static inline int
-vlc_ml_playlist_remove( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, uint32_t i_position )
+vlc_ml_playlist_remove( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, uint32_t i_position, uint32_t i_count )
{
assert( p_ml != NULL );
- return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_REMOVE, i_playlist_id, i_position );
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_REMOVE, i_playlist_id, i_position, i_count );
}
static inline int
@@ -1505,6 +1507,24 @@ static inline size_t vlc_ml_count_artist_tracks( vlc_medialibrary_t* p_ml, const
return count;
}
+static inline vlc_ml_media_list_t* vlc_ml_list_media( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
+{
+ vlc_assert( p_ml != NULL );
+ vlc_ml_media_list_t* res;
+ if ( vlc_ml_list( p_ml, VLC_ML_LIST_MEDIA, params, &res ) != VLC_SUCCESS )
+ return NULL;
+ return res;
+}
+
+static inline size_t vlc_ml_count_media( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
+{
+ vlc_assert( p_ml != NULL );
+ size_t count;
+ if ( vlc_ml_list( p_ml, VLC_ML_COUNT_MEDIA, params, &count ) != VLC_SUCCESS )
+ return 0;
+ return count;
+}
+
static inline vlc_ml_media_list_t* vlc_ml_list_video_media( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
{
vlc_assert( p_ml != NULL );
=====================================
modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp
=====================================
@@ -64,11 +64,11 @@ void appendMediaIntoPlaylist(vlc_medialibrary_t* ml, int64_t playlistId, const s
continue;
for (const vlc_ml_media_t & media : ml_range_iterate<vlc_ml_media_t>(list))
- vlc_ml_playlist_append(ml, playlistId, media.i_id);
+ vlc_ml_playlist_append(ml, playlistId, &media.i_id, 1);
}
// NOTE: Otherwise we add the media directly.
else
- vlc_ml_playlist_append(ml, playlistId, itemId.id);
+ vlc_ml_playlist_append(ml, playlistId, &itemId.id, 1);
}
}
@@ -160,7 +160,7 @@ void appendMediaIntoPlaylist(vlc_medialibrary_t* ml, int64_t playlistId, const s
continue;
}
- vlc_ml_playlist_append(ml, playlistId.id, ml_media->i_id);
+ vlc_ml_playlist_append(ml, playlistId.id, &ml_media->i_id, 1);
vlc_ml_media_release(ml_media);
}
}
=====================================
modules/gui/qt/medialibrary/mlplaylistmodel.cpp
=====================================
@@ -78,7 +78,7 @@
continue;
}
- vlc_ml_playlist_insert(ml, id, ml_media->i_id, insertPos);
+ vlc_ml_playlist_insert(ml, id, &ml_media->i_id, 1, insertPos);
vlc_ml_media_release(ml_media);
insertPos++;
@@ -112,7 +112,7 @@ void MLPlaylistModel::moveImpl(int64_t playlistId, HighLowRanges&& ranges)
int localTo = to;
for (int i = high; i >= low; i--)
{
- vlc_ml_playlist_move(ml, playlistId, i, localTo - 1);
+ vlc_ml_playlist_move(ml, playlistId, i, localTo - 1, 1);
localTo--;
}
ctx.newTo = localTo;
@@ -136,7 +136,7 @@ void MLPlaylistModel::moveImpl(int64_t playlistId, HighLowRanges&& ranges)
int localTo = to;
for (int i = low; i <= high; i++)
{
- vlc_ml_playlist_move(ml, playlistId, i, localTo);
+ vlc_ml_playlist_move(ml, playlistId, i, localTo, 1);
localTo++;
}
ctx.newTo = localTo;
@@ -238,7 +238,7 @@ void MLPlaylistModel::removeImpl(int64_t playlistId, const std::vector<std::pair
[playlistId, range](vlc_medialibrary_t* ml) {
for (int i = range.second; i >= range.first; i--)
{
- vlc_ml_playlist_remove(ml, playlistId, i);
+ vlc_ml_playlist_remove(ml, playlistId, i, 1);
}
},
//UI thread
=====================================
modules/misc/medialibrary/medialibrary.cpp
=====================================
@@ -710,10 +710,18 @@ int MediaLibrary::Control( int query, va_list args )
{
auto priorityAccess = m_ml->acquirePriorityAccess();
- auto playlist = m_ml->playlist( va_arg( args, int64_t ) );
+ const auto playlist_id = va_arg( args, int64_t );
+ const auto *media_ids = va_arg( args, int64_t* );
+ const auto media_id_count = va_arg( args, size_t );
+ if (media_id_count == 0)
+ return VLC_EINVAL;
+
+ auto playlist = m_ml->playlist( playlist_id );
if ( playlist == nullptr )
return VLC_EGENERIC;
- if ( playlist->append(va_arg( args, int64_t )) == false )
+ if ( media_id_count > 1 && playlist->append(std::vector<int64_t>{media_ids, media_ids + media_id_count}) == false )
+ return VLC_EGENERIC;
+ else if ( media_id_count == 1 && playlist->append(*media_ids) == false )
return VLC_EGENERIC;
return VLC_SUCCESS;
}
@@ -721,12 +729,19 @@ int MediaLibrary::Control( int query, va_list args )
{
auto priorityAccess = m_ml->acquirePriorityAccess();
- auto playlist = m_ml->playlist( va_arg( args, int64_t ) );
+ const auto playlist_id = va_arg( args, int64_t );
+ const auto *media_ids = va_arg( args, int64_t* );
+ const auto media_id_count = va_arg( args, size_t );
+ if (media_id_count == 0)
+ return VLC_EINVAL;
+
+ auto playlist = m_ml->playlist( playlist_id );
if ( playlist == nullptr )
return VLC_EGENERIC;
- int64_t mediaId = va_arg( args, int64_t );
uint32_t position = va_arg( args, uint32_t );
- if ( playlist->add(mediaId, position) == false )
+ if ( media_id_count > 1 && playlist->add(std::vector<int64_t>{media_ids, media_ids + media_id_count}, position) == false )
+ return VLC_EGENERIC;
+ else if ( media_id_count == 1 && playlist->add(*media_ids, position) == false )
return VLC_EGENERIC;
return VLC_SUCCESS;
}
@@ -739,7 +754,8 @@ int MediaLibrary::Control( int query, va_list args )
return VLC_EGENERIC;
uint32_t from = va_arg( args, uint32_t );
uint32_t to = va_arg( args, uint32_t );
- if ( playlist->move(from, to) == false )
+ const uint32_t count = va_arg( args, uint32_t );
+ if ( playlist->move(from, to, count) == false )
return VLC_EGENERIC;
return VLC_SUCCESS;
}
@@ -751,7 +767,8 @@ int MediaLibrary::Control( int query, va_list args )
if ( playlist == nullptr )
return VLC_EGENERIC;
uint32_t position = va_arg( args, uint32_t );
- if ( playlist->remove(position) == false )
+ uint32_t count = va_arg( args, uint32_t );
+ if ( playlist->remove(position, count) == false )
return VLC_EGENERIC;
return VLC_SUCCESS;
}
@@ -910,6 +927,32 @@ int MediaLibrary::List( int listQuery, const vlc_ml_query_params_t* params, va_l
case VLC_ML_COUNT_ARTIST_TRACKS:
return listArtists( listQuery, paramsPtr, psz_pattern, nbItems, offset, args );
+ case VLC_ML_LIST_MEDIA:
+ {
+ medialibrary::Query<medialibrary::IMedia> query;
+ if ( psz_pattern != nullptr )
+ query = m_ml->searchMedia( psz_pattern, paramsPtr );
+ else
+ query = m_ml->mediaFiles( paramsPtr );
+ if ( query == nullptr )
+ return VLC_EGENERIC;
+ auto res = ml_convert_list<vlc_ml_media_list_t, vlc_ml_media_t>(
+ query->items( nbItems, offset ) );
+ *va_arg( args, vlc_ml_media_list_t**) = res;
+ break;
+ }
+ case VLC_ML_COUNT_MEDIA:
+ {
+ medialibrary::Query<medialibrary::IMedia> query;
+ if ( psz_pattern != nullptr )
+ query = m_ml->searchMedia( psz_pattern, paramsPtr );
+ else
+ query = m_ml->mediaFiles( paramsPtr );
+ if ( query == nullptr )
+ return VLC_EGENERIC;
+ *va_arg( args, size_t* ) = query->count();
+ break;
+ }
case VLC_ML_LIST_VIDEOS:
{
medialibrary::Query<medialibrary::IMedia> query;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/42d0ca063f7fd63c8ccc5ab521ee2cf7a0b149cc...8b78a74aa27eb048543f1ef3284b5332bb8b02cd
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/42d0ca063f7fd63c8ccc5ab521ee2cf7a0b149cc...8b78a74aa27eb048543f1ef3284b5332bb8b02cd
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list