OSDN Git Service

Additional fixes for bug 5357970: Handle exceptions in async runner.
authorMarius Renn <renn@google.com>
Thu, 29 Sep 2011 16:41:52 +0000 (09:41 -0700)
committerMarius Renn <renn@google.com>
Thu, 29 Sep 2011 16:43:27 +0000 (09:43 -0700)
The AsyncRunner now attempts to deactivate the GL context when an error
occurs.

Also, a minor patch to error reporting that has been causing some
confusion lately.

Change-Id: I1e18b5611cf5c048ef83a4659be221e02accd69f

mca/filterfw/java/android/filterfw/core/AsyncRunner.java
mca/filterfw/java/android/filterfw/core/GraphRunner.java
mca/filterfw/java/android/filterfw/core/SyncRunner.java
mca/filterfw/native/core/native_program.cpp

index 34b601a..fc16444 100644 (file)
@@ -87,12 +87,19 @@ public class AsyncRunner extends GraphRunner{
                 if (isCancelled()) {
                     result.status = RESULT_STOPPED;
                 }
+            } catch (Exception exception) {
+                result.exception = exception;
+                result.status = RESULT_ERROR;
+            }
 
+            // Deactivate context.
+            try {
                 deactivateGlContext();
             } catch (Exception exception) {
                 result.exception = exception;
                 result.status = RESULT_ERROR;
             }
+
             if (mLogVerbose) Log.v(TAG, "Done with background graph processing.");
             return result;
         }
@@ -219,6 +226,7 @@ public class AsyncRunner extends GraphRunner{
         return isProcessing;
     }
 
+    @Override
     synchronized public Exception getError() {
         return mException;
     }
index 96fda1b..b496c54 100644 (file)
@@ -91,4 +91,10 @@ public abstract class GraphRunner {
 
     /** Closes the filters in a graph. Can only be called if the graph is not running. */
     public abstract void close();
+
+    /**
+     * Returns the last exception that happened during an asynchronous run. Returns null if
+     * there is nothing to report.
+     */
+    public abstract Exception getError();
 }
index 4b4187e..abbd359 100644 (file)
@@ -150,6 +150,11 @@ public class SyncRunner extends GraphRunner {
         throw new RuntimeException("SyncRunner does not support stopping a graph!");
     }
 
+    @Override
+    synchronized public Exception getError() {
+        return null;
+    }
+
     protected void waitUntilWake() {
         mWakeCondition.block();
     }
index 53c9113..e67a58d 100644 (file)
@@ -46,7 +46,7 @@ bool NativeProgram::OpenLibrary(const std::string& lib_name) {
   if (!lib_handle_) {
     lib_handle_ = dlopen(lib_name.c_str(), RTLD_NOW);
     if (!lib_handle_) {
-      LOGE("NativeProgram: Could not find library: '%s'!", lib_name.c_str());
+      LOGE("NativeProgram: Error opening library: '%s': %s", lib_name.c_str(), dlerror());
       return false;
     }
     return true;