From 46ea6dedfa4f9423783327adccdac9f0a2d603ce Mon Sep 17 00:00:00 2001 From: Tyler Luu Date: Tue, 13 Sep 2011 11:03:04 -0500 Subject: CameraHal: Modify exit behavior of notify thread When the camera app dies, sometimes the release() call is coming from the same thread as a callback instead of the main thread. When this happens, it causes a segfault in AppCallbackNotifier because we end up destroying AppCallbackNotifier without the NotificationThread knowing. The subsequent waitForMsg() after release() will result in a segfault since the message queues are deleted. Instead of looping forever in a while loop in the notification thread, return bool value in looper function. This gives the Thread class a chance to exit in case of a requestExit() in the same thread. Looper function will automatically will be called again if exit is not pending and previous looper function call returned true. Change-Id: I6bdc65df71e2c3ebcbd409654b828edef29b1a0e Signed-off-by: Tyler Luu --- camera/inc/CameraHal.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'camera/inc') diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h index 38727a2..47bd589 100644 --- a/camera/inc/CameraHal.h +++ b/camera/inc/CameraHal.h @@ -523,7 +523,7 @@ public: void setMeasurements(bool enable); //thread loops - void notificationThread(); + bool notificationThread(); ///Notification callback functions static void frameCallbackRelay(CameraFrame* caFrame); @@ -568,8 +568,7 @@ public: NotificationThread(AppCallbackNotifier* nh) : Thread(false), mAppCallbackNotifier(nh) { } virtual bool threadLoop() { - mAppCallbackNotifier->notificationThread(); - return false; + return mAppCallbackNotifier->notificationThread(); } TIUTILS::MessageQueue &msgQ() { return mNotificationThreadQ;} -- cgit v1.1