diff options
author | Joel Teichroeb | 2014-01-27 18:29:00 -0800 |
---|---|---|
committer | Joel Teichroeb | 2014-01-27 18:29:00 -0800 |
commit | 2d903d966875bb2bc665cd33d3514fb6b2dcf7f5 (patch) | |
tree | 104e58d60f6e5d0d53772d87006f5df1d27176cc /backends/platform/android/org | |
parent | 07568931cef05d609e4a2335593fb9ed53ecee57 (diff) | |
download | scummvm-rg350-2d903d966875bb2bc665cd33d3514fb6b2dcf7f5.tar.gz scummvm-rg350-2d903d966875bb2bc665cd33d3514fb6b2dcf7f5.tar.bz2 scummvm-rg350-2d903d966875bb2bc665cd33d3514fb6b2dcf7f5.zip |
ANDROID: Fix a race condition
setSurface is done in a different thread than the one that starts
the scummvm main. The main thread would then wait until the setSurface
thread notifies. The setSurface thread would notify before it actually
calls setSurface, meaning if the thread is preemted before calling
setSurface, initSurface will assert, causing the app to crash.
Diffstat (limited to 'backends/platform/android/org')
-rw-r--r-- | backends/platform/android/org/scummvm/scummvm/ScummVM.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java index 3a25b54eeb..5047502e61 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java @@ -86,13 +86,15 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable { Log.d(LOG_TAG, String.format("surfaceChanged: %dx%d (%d)", width, height, format)); + // store values for the native code + // make sure to do it before notifying the lock + // as it leads to a race condition otherwise + setSurface(width, height); + synchronized(_sem_surface) { _surface_holder = holder; _sem_surface.notifyAll(); } - - // store values for the native code - setSurface(width, height); } // SurfaceHolder callback |