Fix callback sequence on picture taking
Also fixes a bug in JPEG converter. Change-Id: I5bbeec96ec2bb0a9a6a333a3798880bb0b837c65
This commit is contained in:
@@ -217,6 +217,16 @@ void CallbackNotifier::onNextFrameAvailable(const void* frame,
|
||||
}
|
||||
|
||||
if (mTakingPicture) {
|
||||
/* This happens just once. */
|
||||
mTakingPicture = false;
|
||||
/* The sequence of callbacks during picture taking is:
|
||||
* - CAMERA_MSG_SHUTTER
|
||||
* - CAMERA_MSG_RAW_IMAGE_NOTIFY
|
||||
* - CAMERA_MSG_COMPRESSED_IMAGE
|
||||
*/
|
||||
if (isMessageEnabled(CAMERA_MSG_SHUTTER)) {
|
||||
mNotifyCB(CAMERA_MSG_SHUTTER, 0, 0, mCBOpaque);
|
||||
}
|
||||
if (isMessageEnabled(CAMERA_MSG_RAW_IMAGE_NOTIFY)) {
|
||||
mNotifyCB(CAMERA_MSG_RAW_IMAGE_NOTIFY, 0, 0, mCBOpaque);
|
||||
}
|
||||
@@ -240,11 +250,6 @@ void CallbackNotifier::onNextFrameAvailable(const void* frame,
|
||||
LOGE("%s: Compression failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
if (isMessageEnabled(CAMERA_MSG_SHUTTER)) {
|
||||
mNotifyCB(CAMERA_MSG_SHUTTER, 0, 0, mCBOpaque);
|
||||
}
|
||||
/* This happens just once. */
|
||||
mTakingPicture = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -503,15 +503,16 @@ status_t EmulatedCamera::doStartPreview()
|
||||
{
|
||||
LOGV("%s", __FUNCTION__);
|
||||
|
||||
EmulatedCameraDevice* camera_dev = getCameraDevice();
|
||||
if (camera_dev->isStarted()) {
|
||||
camera_dev->stopDeliveringFrames();
|
||||
camera_dev->stopDevice();
|
||||
}
|
||||
|
||||
status_t res = mPreviewWindow.startPreview();
|
||||
if (res != NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
if (getCameraDevice()->isStarted()) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
EmulatedCameraDevice* camera_dev = getCameraDevice();
|
||||
|
||||
/* Make sure camera device is connected. */
|
||||
if (!camera_dev->isConnected()) {
|
||||
@@ -573,15 +574,17 @@ status_t EmulatedCamera::doStopPreview()
|
||||
LOGV("%s", __FUNCTION__);
|
||||
|
||||
status_t res = NO_ERROR;
|
||||
/* Stop the camera. */
|
||||
if (getCameraDevice()->isStarted()) {
|
||||
getCameraDevice()->stopDeliveringFrames();
|
||||
res = getCameraDevice()->stopDevice();
|
||||
}
|
||||
if (mPreviewWindow.isPreviewEnabled()) {
|
||||
/* Stop the camera. */
|
||||
if (getCameraDevice()->isStarted()) {
|
||||
getCameraDevice()->stopDeliveringFrames();
|
||||
res = getCameraDevice()->stopDevice();
|
||||
}
|
||||
|
||||
if (res == NO_ERROR) {
|
||||
/* Disable preview as well. */
|
||||
mPreviewWindow.stopPreview();
|
||||
if (res == NO_ERROR) {
|
||||
/* Disable preview as well. */
|
||||
mPreviewWindow.stopPreview();
|
||||
}
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
|
||||
@@ -50,7 +50,7 @@ status_t NV21JpegCompressor::compressRawImage(const void* image,
|
||||
offsets[0] = 0;
|
||||
offsets[1] = width * height;
|
||||
mStrides[0] = width;
|
||||
mStrides[1] = mStrides[2] = width / 4;
|
||||
mStrides[1] = width;
|
||||
if (encode(&mStream, pY, width, height, offsets, quality)) {
|
||||
LOGV("%s: Compressed JPEG: %d[%dx%d] -> %d bytes",
|
||||
__FUNCTION__, (width * height * 12) / 8, width, height, mStream.getOffset());
|
||||
@@ -59,7 +59,6 @@ status_t NV21JpegCompressor::compressRawImage(const void* image,
|
||||
LOGE("%s: JPEG compression failed", __FUNCTION__);
|
||||
return errno ? errno : EINVAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}; /* namespace android */
|
||||
|
||||
Reference in New Issue
Block a user