[Android] AWindow: more verbose exception

Thomas Guillem git at videolan.org
Thu Oct 8 16:10:35 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Oct  8 16:10:14 2015 +0200| [233f45a3541a21a0b115ffa0ba30c3e87fff8522] | committer: Thomas Guillem

AWindow: more verbose exception

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

 libvlc/src/org/videolan/libvlc/AWindow.java |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/AWindow.java b/libvlc/src/org/videolan/libvlc/AWindow.java
index 4cf582f..00f5953 100644
--- a/libvlc/src/org/videolan/libvlc/AWindow.java
+++ b/libvlc/src/org/videolan/libvlc/AWindow.java
@@ -215,9 +215,16 @@ class AWindow implements IAWindowNativeHandler, IVLCVout {
         mSurfaces[ID_SUBTITLES] = null;
     }
 
-    private void setView(int id, SurfaceView view) {
+    private void ensureInitState() throws IllegalStateException {
         if (mSurfacesState.get() != SURFACE_STATE_INIT)
-            throw new IllegalStateException("Can't set view when already attached");
+            throw new IllegalStateException("Can't set view when already attached. " +
+                    "Current state: " + mSurfacesState.get() + ", " +
+                    "mSurfaces[ID_VIDEO]: " + mSurfaceHelpers[ID_VIDEO] + " / " + mSurfaces[ID_VIDEO] + ", " +
+                    "mSurfaces[ID_SUBTITLES]: " + mSurfaceHelpers[ID_SUBTITLES] + " / " + mSurfaces[ID_SUBTITLES]);
+    }
+
+    private void setView(int id, SurfaceView view) {
+        ensureInitState();
         if (view == null)
             throw new NullPointerException("view is null");
         final SurfaceHelper surfaceHelper = mSurfaceHelpers[id];
@@ -230,8 +237,7 @@ class AWindow implements IAWindowNativeHandler, IVLCVout {
     private void setView(int id, TextureView view) {
         if (!AndroidUtil.isICSOrLater())
             throw new IllegalArgumentException("TextureView not implemented in this android version");
-        if (mSurfacesState.get() != SURFACE_STATE_INIT)
-            throw new IllegalStateException("Can't set view when already attached");
+        ensureInitState();
         if (view == null)
             throw new NullPointerException("view is null");
         final SurfaceHelper surfaceHelper = mSurfaceHelpers[id];
@@ -242,8 +248,7 @@ class AWindow implements IAWindowNativeHandler, IVLCVout {
     }
 
     private void setSurface(int id, Surface surface, SurfaceHolder surfaceHolder) {
-        if (mSurfacesState.get() != SURFACE_STATE_INIT)
-            throw new IllegalStateException("Can't set surface when already attached");
+        ensureInitState();
         if (!surface.isValid() || surfaceHolder == null)
             throw new IllegalStateException("surface is not attached and holder is null");
         final SurfaceHelper surfaceHelper = mSurfaceHelpers[id];



More information about the Android mailing list