diff --git a/tools/emulator/system/camera/CallbackNotifier.cpp b/tools/emulator/system/camera/CallbackNotifier.cpp index cec471fd8..7d83bb171 100755 --- a/tools/emulator/system/camera/CallbackNotifier.cpp +++ b/tools/emulator/system/camera/CallbackNotifier.cpp @@ -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; } } diff --git a/tools/emulator/system/camera/EmulatedCamera.cpp b/tools/emulator/system/camera/EmulatedCamera.cpp index 909760bb0..8f50eb8f1 100755 --- a/tools/emulator/system/camera/EmulatedCamera.cpp +++ b/tools/emulator/system/camera/EmulatedCamera.cpp @@ -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; diff --git a/tools/emulator/system/camera/JpegCompressor.cpp b/tools/emulator/system/camera/JpegCompressor.cpp index d8976c205..0e538a165 100644 --- a/tools/emulator/system/camera/JpegCompressor.cpp +++ b/tools/emulator/system/camera/JpegCompressor.cpp @@ -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 */