[Android] ThumbnailerManager: repair the barrier after an InterruptedException

Ludovic Fauvet git at videolan.org
Tue Oct 2 02:48:40 CEST 2012


vlc-ports/android | branch: master | Ludovic Fauvet <etix at videolan.org> | Tue Oct  2 02:41:13 2012 +0200| [a4a3e5ed2ad0baf5f986166c1a7a8c1ef5e90c18] | committer: Ludovic Fauvet

ThumbnailerManager: repair the barrier after an InterruptedException

The barrier needs to be reset after an InterruptedException, but sadly
we can't do that safely in the catch block. And because doing a reset on
a sane barrier is perfectly valid we'll do it at the beginning of each
loop.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=a4a3e5ed2ad0baf5f986166c1a7a8c1ef5e90c18
---

 vlc-android/src/org/videolan/vlc/ThumbnailerManager.java          |    1 +
 vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java |    4 ++++
 2 files changed, 5 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java b/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
index 15ff40d..8f7d8a1 100644
--- a/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
+++ b/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
@@ -120,6 +120,7 @@ public class ThumbnailerManager implements Runnable {
         String prefix = mContext.getResources().getString(R.string.thumbnail);
 
         while (!isStopping) {
+            mVideoListFragment.resetBarrier();
             lock.lock();
             // Get the id of the file browser item to create its thumbnail.
             boolean interrupted = false;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java
index 804b1e6..8492f93 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListFragment.java
@@ -287,6 +287,10 @@ public class VideoListFragment extends SherlockListFragment implements ISortable
         mBarrier.await();
     }
 
+    public void resetBarrier() {
+        mBarrier.reset();
+    }
+
     private final BroadcastReceiver messageReceiverVideoListFragment = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {



More information about the Android mailing list