diff --git a/android/YoPme/src/com/mapswithme/yopme/util/EglOperationException.java b/android/YoPme/src/com/mapswithme/yopme/util/EglOperationException.java index 3a04f77af9..88f51e5c6a 100644 --- a/android/YoPme/src/com/mapswithme/yopme/util/EglOperationException.java +++ b/android/YoPme/src/com/mapswithme/yopme/util/EglOperationException.java @@ -17,6 +17,12 @@ public class EglOperationException extends RuntimeException { return mErrorCode; } + + @Override + public String toString() + { + return super.toString() + " EGL code = " + Integer.toHexString(mErrorCode); + } private int mErrorCode; } diff --git a/android/YoPme/src/com/mapswithme/yopme/util/PixelBuffer.java b/android/YoPme/src/com/mapswithme/yopme/util/PixelBuffer.java index 950aa5d554..2fa5d3312c 100644 --- a/android/YoPme/src/com/mapswithme/yopme/util/PixelBuffer.java +++ b/android/YoPme/src/com/mapswithme/yopme/util/PixelBuffer.java @@ -103,51 +103,22 @@ public class PixelBuffer public void attachToThread() { - int attempt = 0; - boolean succeed = false; - - while ((attempt < MAX_TRY) && !succeed) - { - succeed = EGL14.eglMakeCurrent(mDisplay, mSurface, mSurface, mContext); - if (!succeed) - { - someSleep(); - ++attempt; - } - else - Log.d(TAG, "Pixel buffer attached"); - } - - if (!succeed) + if (!EGL14.eglMakeCurrent(mDisplay, mSurface, mSurface, mContext)) { - Log.d(TAG, "Throwed"); - throw new EglOperationException("EGL error : Context was not binded to thread", EGL14.eglGetError()); + terminate(); + init(); + if (!EGL14.eglMakeCurrent(mDisplay, mSurface, mSurface, mContext)) + throw new EglOperationException("EGL error : Context was not binded to thread", EGL14.eglGetError()); } - } public void detachFromThread() { - int attempt = 0; - boolean succeed = false; - - while ((attempt < MAX_TRY) && !succeed) - { - succeed = EGL14.eglMakeCurrent(mDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT); - if (!succeed) - { - someSleep(); - ++attempt; - } - else - Log.d(TAG, "Pixel buffer detached"); - } - - if (!succeed) - { - Log.d(TAG, "Throwed"); - throw new EglOperationException("EGL error : Context was not binded to the thread", EGL14.eglGetError()); - } + if (!EGL14.eglMakeCurrent(mDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT)) + { + terminate(); + init(); + } } public Bitmap readBitmap()