[Android] Don't fetch Android thumbnails in parallel

Geoffrey Métais git at videolan.org
Wed Feb 20 09:43:10 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 19 18:19:36 2019 +0100| [830bebff0fb1f1c1b4fbbd6ab107a0f34127ec96] | committer: Geoffrey Métais

Don't fetch Android thumbnails in parallel

> https://code.videolan.org/videolan/vlc-android/commit/830bebff0fb1f1c1b4fbbd6ab107a0f34127ec96
---

 vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java b/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
index 22c57e123..351c76392 100644
--- a/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
+++ b/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
@@ -36,6 +36,7 @@ public class ThumbnailsProvider {
     private static File appDir;
     private static String cacheDir;
     private static final int MAX_IMAGES = 4;
+    private static final Object lock = new Object();
 
     @WorkerThread
     public static Bitmap getFolderThumbnail(final Folder folder, int width) {
@@ -71,7 +72,10 @@ public class ThumbnailsProvider {
         if (cacheBM != null) return cacheBM;
         if (hasCache && new File(thumbPath).exists()) return readCoverBitmap(thumbPath, width);
         if (media.isThumbnailGenerated()) return null;
-        final Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Video.Thumbnails.MINI_KIND);
+        final Bitmap bitmap;
+        synchronized (lock) {
+            bitmap = ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Video.Thumbnails.MINI_KIND);
+        }
         if (bitmap != null) {
             BitmapCache.getInstance().addBitmapToMemCache(thumbPath, bitmap);
             if (hasCache) {



More information about the Android mailing list