From fea96e8d145b1915b7bd66f68e973dd572a469e3 Mon Sep 17 00:00:00 2001 From: Xiaofei Wan Date: Mon, 31 Mar 2014 16:43:15 +0800 Subject: 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 --- cpp/RenderScript.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'cpp/RenderScript.cpp') 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; + } } } -- cgit v1.2.3