[vlc-commits] medialib: use new requestThumbnail() API

Romain Vimont git at videolan.org
Mon Jan 25 17:47:01 UTC 2021


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Tue Jan  5 14:49:46 2021 +0100| [570e30eba13fd7b1ca825c52ae585484dfa48905] | committer: Hugo Beauzée-Luyssen

medialib: use new requestThumbnail() API

A new medialibrary API has been added to request asynchronous thumbnail
generation from a media id:
https://code.videolan.org/videolan/medialibrary/-/merge_requests/350

This avoids to retrieve a Media from the media id beforehand via a
blocking call (executing SQL queries) on the UI thread.

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=570e30eba13fd7b1ca825c52ae585484dfa48905
---

 modules/misc/medialibrary/medialibrary.cpp | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/modules/misc/medialibrary/medialibrary.cpp b/modules/misc/medialibrary/medialibrary.cpp
index 1d7a12547c..6c4583f66e 100644
--- a/modules/misc/medialibrary/medialibrary.cpp
+++ b/modules/misc/medialibrary/medialibrary.cpp
@@ -598,13 +598,24 @@ int MediaLibrary::Control( int query, va_list args )
             *va_arg( args, vlc_ml_media_t**) = CreateAndConvert<vlc_ml_media_t>( media.get() );
             return VLC_SUCCESS;
         }
+        case VLC_ML_MEDIA_GENERATE_THUMBNAIL:
+        {
+            auto mediaId = va_arg( args, int64_t );
+            auto sizeType = va_arg( args, int );
+            auto width = va_arg( args, uint32_t );
+            auto height = va_arg( args, uint32_t );
+            auto position = va_arg( args, double );
+            auto res = m_ml->requestThumbnail( mediaId,
+                                               static_cast<medialibrary::ThumbnailSizeType>( sizeType ),
+                                               width, height, position );
+            return res == true ? VLC_SUCCESS : VLC_EGENERIC;
+        }
         case VLC_ML_MEDIA_UPDATE_PROGRESS:
         case VLC_ML_MEDIA_GET_MEDIA_PLAYBACK_STATE:
         case VLC_ML_MEDIA_SET_MEDIA_PLAYBACK_STATE:
         case VLC_ML_MEDIA_GET_ALL_MEDIA_PLAYBACK_STATES:
         case VLC_ML_MEDIA_SET_ALL_MEDIA_PLAYBACK_STATES:
         case VLC_ML_MEDIA_SET_THUMBNAIL:
-        case VLC_ML_MEDIA_GENERATE_THUMBNAIL:
         case VLC_ML_MEDIA_ADD_EXTERNAL_MRL:
         case VLC_ML_MEDIA_SET_TYPE:
         case VLC_ML_MEDIA_ADD_BOOKMARK:
@@ -1228,16 +1239,6 @@ int MediaLibrary::controlMedia( int query, va_list args )
             m->setThumbnail( mrl, static_cast<medialibrary::ThumbnailSizeType>( sizeType ) );
             return VLC_SUCCESS;
         }
-        case VLC_ML_MEDIA_GENERATE_THUMBNAIL:
-        {
-            auto sizeType = va_arg( args, int );
-            auto width = va_arg( args, uint32_t );
-            auto height = va_arg( args, uint32_t );
-            auto position = va_arg( args, double );
-            auto res = m->requestThumbnail( static_cast<medialibrary::ThumbnailSizeType>( sizeType ),
-                                            width, height, position );
-            return res == true ? VLC_SUCCESS : VLC_EGENERIC;
-        }
         case VLC_ML_MEDIA_ADD_EXTERNAL_MRL:
         {
             auto mrl = va_arg( args, const char* );



More information about the vlc-commits mailing list