summaryrefslogtreecommitdiff
path: root/cpp/RenderScript.cpp
diff options
context:
space:
mode:
authorXiaofei Wan <xiaofei.wan@intel.com>2014-03-31 16:43:15 +0800
committerXiaofei Wan <xiaofei.wan@intel.com>2014-03-31 16:43:20 +0800
commitfea96e8d145b1915b7bd66f68e973dd572a469e3 (patch)
tree0b9a01564f8189e02e113d7a9d337067a58e7c2d /cpp/RenderScript.cpp
parent43f7bffe3972887347afede7001992c90fd633f7 (diff)
Add error check when init RS thread in sync mode.
RS should return false and stop further waiting when it failed to init RS thread, otherwise it will cause RS caller ANR errors. Update destructor function for the exception handling accordingly. Change-Id: I80a946e6be6b23cc93388b5f56d58ad6dc809d8b Signed-off-by: Xiaofei Wan <xiaofei.wan@intel.com>
Diffstat (limited to 'cpp/RenderScript.cpp')
-rw-r--r--cpp/RenderScript.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/cpp/RenderScript.cpp b/cpp/RenderScript.cpp
index 5709f799..d05e4cd2 100644
--- a/cpp/RenderScript.cpp
+++ b/cpp/RenderScript.cpp
@@ -58,15 +58,19 @@ RS::~RS() {
if (mInit == true) {
mMessageRun = false;
- RS::dispatch->ContextDeinitToClient(mContext);
+ if (mContext) {
+ RS::dispatch->ContextDeinitToClient(mContext);
- void *res = NULL;
- int status = pthread_join(mMessageThreadId, &res);
+ void *res = NULL;
+ int status = pthread_join(mMessageThreadId, &res);
- RS::dispatch->ContextDestroy(mContext);
- mContext = NULL;
- RS::dispatch->DeviceDestroy(mDev);
- mDev = NULL;
+ RS::dispatch->ContextDestroy(mContext);
+ mContext = NULL;
+ }
+ if (mDev) {
+ RS::dispatch->DeviceDestroy(mDev);
+ mDev = NULL;
+ }
}
}