[Android] AWindow: fix possible deadlock with setBuffersGeometry and surfaceDestroyed cb
Thomas Guillem
git at videolan.org
Thu Jul 2 14:54:25 CEST 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jul 2 14:52:39 2015 +0200| [4b4ce0be6e6ebde3ca25c6ccf5fe604f7b089b70] | committer: Thomas Guillem
AWindow: fix possible deadlock with setBuffersGeometry and surfaceDestroyed cb
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=4b4ce0be6e6ebde3ca25c6ccf5fe604f7b089b70
---
libvlc/src/org/videolan/libvlc/AWindow.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/libvlc/src/org/videolan/libvlc/AWindow.java b/libvlc/src/org/videolan/libvlc/AWindow.java
index 97f658f..3389f67 100644
--- a/libvlc/src/org/videolan/libvlc/AWindow.java
+++ b/libvlc/src/org/videolan/libvlc/AWindow.java
@@ -292,6 +292,10 @@ class AWindow implements IAWindowNativeHandler, IVLCVout {
if (mSurfacesState.get() != SURFACE_STATE_INIT || mSurfaceHelpers[ID_VIDEO] == null)
throw new IllegalStateException("already attached or video view not configured");
mSurfacesState.set(SURFACE_STATE_ATTACHED);
+ synchronized (mBuffersGeometryCond) {
+ mBuffersGeometryCond.configured = false;
+ mBuffersGeometryCond.abort = false;
+ }
for (int id = 0; id < ID_MAX; ++id) {
final SurfaceHelper surfaceHelper = mSurfaceHelpers[id];
if (surfaceHelper != null)
@@ -305,6 +309,11 @@ class AWindow implements IAWindowNativeHandler, IVLCVout {
if (mSurfacesState.get() == SURFACE_STATE_INIT)
return;
mSurfacesState.set(SURFACE_STATE_INIT);
+ mHandler.removeCallbacksAndMessages(null);
+ synchronized (mBuffersGeometryCond) {
+ mBuffersGeometryCond.abort = true;
+ mBuffersGeometryCond.notifyAll();
+ }
for (int id = 0; id < ID_MAX; ++id) {
final SurfaceHelper surfaceHelper = mSurfaceHelpers[id];
if (surfaceHelper != null)
@@ -415,6 +424,7 @@ class AWindow implements IAWindowNativeHandler, IVLCVout {
private static class BuffersGeometryCond {
private boolean configured = false;
+ private boolean abort = false;
}
private final BuffersGeometryCond mBuffersGeometryCond = new BuffersGeometryCond();
@@ -427,13 +437,11 @@ class AWindow implements IAWindowNativeHandler, IVLCVout {
Log.d(TAG, "configureSurface: " + width + "x" + height);
synchronized (mBuffersGeometryCond) {
- if (mBuffersGeometryCond.configured)
+ if (mBuffersGeometryCond.configured || mBuffersGeometryCond.abort)
return false;
}
- final Handler handler = new Handler(Looper.getMainLooper());
- handler.post(new Runnable() {
-
+ mHandler.post(new Runnable() {
private SurfaceHelper getSurfaceHelper(Surface surface) {
for (int id = 0; id < ID_MAX; ++id) {
final SurfaceHelper surfaceHelper = mSurfaceHelpers[id];
@@ -465,7 +473,7 @@ class AWindow implements IAWindowNativeHandler, IVLCVout {
try {
synchronized (mBuffersGeometryCond) {
- while (!mBuffersGeometryCond.configured)
+ while (!mBuffersGeometryCond.configured && !mBuffersGeometryCond.abort)
mBuffersGeometryCond.wait();
mBuffersGeometryCond.configured = false;
}
More information about the Android
mailing list