Implements camera error reporting.
Change-Id: I5f4f4cd1baab60053e827e0605a92a123c7a086f
diff --git a/tools/emulator/system/camera/CallbackNotifier.cpp b/tools/emulator/system/camera/CallbackNotifier.cpp
index c2a84e2..e6ec37e 100755
--- a/tools/emulator/system/camera/CallbackNotifier.cpp
+++ b/tools/emulator/system/camera/CallbackNotifier.cpp
@@ -257,6 +257,13 @@
}
}
+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 3722d21..63301d2 100755
--- a/tools/emulator/system/camera/CallbackNotifier.h
+++ b/tools/emulator/system/camera/CallbackNotifier.h
@@ -159,6 +159,12 @@
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 80e7239..b8cec0e 100755
--- a/tools/emulator/system/camera/EmulatedCamera.cpp
+++ b/tools/emulator/system/camera/EmulatedCamera.cpp
@@ -149,6 +149,12 @@
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 @@
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<const char*>(&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 8b04de2..8afdd83 100755
--- a/tools/emulator/system/camera/EmulatedCamera.h
+++ b/tools/emulator/system/camera/EmulatedCamera.h
@@ -94,6 +94,12 @@
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 5117a84..57dbc98 100755
--- a/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp
+++ b/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp
@@ -249,12 +249,13 @@
/* 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 */