diff --git a/tools/emulator/system/camera/CallbackNotifier.cpp b/tools/emulator/system/camera/CallbackNotifier.cpp index c2a84e266..e6ec37e00 100755 --- a/tools/emulator/system/camera/CallbackNotifier.cpp +++ b/tools/emulator/system/camera/CallbackNotifier.cpp @@ -257,6 +257,13 @@ void CallbackNotifier::onNextFrameAvailable(const void* frame, } } +void CallbackNotifier::onCameraDeviceError(int err) +{ + if (isMessageEnabled(CAMERA_MSG_ERROR) && mNotifyCB != NULL) { + mNotifyCB(CAMERA_MSG_ERROR, err, 0, mCBOpaque); + } +} + /**************************************************************************** * Private API ***************************************************************************/ diff --git a/tools/emulator/system/camera/CallbackNotifier.h b/tools/emulator/system/camera/CallbackNotifier.h index 3722d21b4..63301d2e3 100755 --- a/tools/emulator/system/camera/CallbackNotifier.h +++ b/tools/emulator/system/camera/CallbackNotifier.h @@ -159,6 +159,12 @@ public: nsecs_t timestamp, EmulatedCameraDevice* camera_dev); + /* Entry point for notifications that occur in camera device. + * Param: + * err - CAMERA_ERROR_XXX error code. + */ + void onCameraDeviceError(int err); + /* Sets, or resets taking picture state. * This state control whether or not to notify the framework about compressed * image, shutter, and other picture related events. diff --git a/tools/emulator/system/camera/EmulatedCamera.cpp b/tools/emulator/system/camera/EmulatedCamera.cpp index 80e723914..b8cec0eab 100755 --- a/tools/emulator/system/camera/EmulatedCamera.cpp +++ b/tools/emulator/system/camera/EmulatedCamera.cpp @@ -149,6 +149,12 @@ void EmulatedCamera::onNextFrameAvailable(const void* frame, mCallbackNotifier.onNextFrameAvailable(frame, timestamp, camera_dev); } +void EmulatedCamera::onCameraDeviceError(int err) +{ + /* Errors are reported through the callback notifier */ + mCallbackNotifier.onCameraDeviceError(err); +} + /**************************************************************************** * Camera API implementation. ***************************************************************************/ @@ -559,7 +565,8 @@ status_t EmulatedCamera::doStartPreview() mPreviewWindow.stopPreview(); return EINVAL; } - LOGD("Starting camera: %dx%d -> %.4s", width, height, pix_fmt); + LOGD("Starting camera: %dx%d -> %.4s(%s)", + width, height, reinterpret_cast(&org_fmt), pix_fmt); res = camera_dev->startDevice(width, height, org_fmt); if (res != NO_ERROR) { mPreviewWindow.stopPreview(); diff --git a/tools/emulator/system/camera/EmulatedCamera.h b/tools/emulator/system/camera/EmulatedCamera.h index 8b04de22c..8afdd8306 100755 --- a/tools/emulator/system/camera/EmulatedCamera.h +++ b/tools/emulator/system/camera/EmulatedCamera.h @@ -94,6 +94,12 @@ public: nsecs_t timestamp, EmulatedCameraDevice* camera_dev); + /* Entry point for notifications that occur in camera device. + * Param: + * err - CAMERA_ERROR_XXX error code. + */ + virtual void onCameraDeviceError(int err); + /**************************************************************************** * Camera API implementation ***************************************************************************/ diff --git a/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp b/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp index 5117a84aa..57dbc987f 100755 --- a/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp +++ b/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp @@ -249,12 +249,13 @@ bool EmulatedQemuCameraDevice::inWorkerThread() /* Timestamp the current frame, and notify the camera HAL. */ mCurFrameTimestamp = systemTime(SYSTEM_TIME_MONOTONIC); mCameraHAL->onNextFrameAvailable(mCurrentFrame, mCurFrameTimestamp, this); + return true; } else { LOGE("%s: Unable to get current video frame: %s", __FUNCTION__, strerror(query_res)); + mCameraHAL->onCameraDeviceError(CAMERA_ERROR_SERVER_DIED); + return false; } - - return true; } }; /* namespace android */