Fix capture stopping
When stopping the camera, the working thread should be stopped before sending "stop" query to the emulator: we don't want "frame" queries to be floating around while we're in the process of stopping the camera. Change-Id: I16dc56ca1c2e304a07a074302001d2e27100f2ac
This commit is contained in:
@@ -78,6 +78,7 @@ status_t EmulatedCameraDevice::startCapturing(int width,
|
|||||||
{
|
{
|
||||||
LOGV("%s", __FUNCTION__);
|
LOGV("%s", __FUNCTION__);
|
||||||
|
|
||||||
|
Mutex::Autolock locker(&mObjectLock);
|
||||||
/* Validate pixel format, and calculate framebuffer size at the same time. */
|
/* Validate pixel format, and calculate framebuffer size at the same time. */
|
||||||
switch (pix_fmt) {
|
switch (pix_fmt) {
|
||||||
case V4L2_PIX_FMT_YVU420:
|
case V4L2_PIX_FMT_YVU420:
|
||||||
@@ -126,6 +127,7 @@ status_t EmulatedCameraDevice::stopCapturing()
|
|||||||
{
|
{
|
||||||
LOGV("%s", __FUNCTION__);
|
LOGV("%s", __FUNCTION__);
|
||||||
|
|
||||||
|
Mutex::Autolock locker(&mObjectLock);
|
||||||
/* Stop the camera. */
|
/* Stop the camera. */
|
||||||
const status_t res = stopDevice();
|
const status_t res = stopDevice();
|
||||||
if (res == NO_ERROR) {
|
if (res == NO_ERROR) {
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ status_t EmulatedFakeCameraDevice::startDevice()
|
|||||||
{
|
{
|
||||||
LOGV("%s", __FUNCTION__);
|
LOGV("%s", __FUNCTION__);
|
||||||
|
|
||||||
Mutex::Autolock locker(&mObjectLock);
|
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
LOGE("%s: Fake camera device is not connected.", __FUNCTION__);
|
LOGE("%s: Fake camera device is not connected.", __FUNCTION__);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ status_t EmulatedQemuCameraDevice::startDevice()
|
|||||||
{
|
{
|
||||||
LOGV("%s", __FUNCTION__);
|
LOGV("%s", __FUNCTION__);
|
||||||
|
|
||||||
Mutex::Autolock locker(&mObjectLock);
|
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
LOGE("%s: Qemu camera device is not connected.", __FUNCTION__);
|
LOGE("%s: Qemu camera device is not connected.", __FUNCTION__);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
@@ -169,17 +168,16 @@ status_t EmulatedQemuCameraDevice::stopDevice()
|
|||||||
{
|
{
|
||||||
LOGV("%s", __FUNCTION__);
|
LOGV("%s", __FUNCTION__);
|
||||||
|
|
||||||
Mutex::Autolock locker(&mObjectLock);
|
|
||||||
if (!isCapturing()) {
|
if (!isCapturing()) {
|
||||||
LOGW("%s: Qemu camera device is not capturing.", __FUNCTION__);
|
LOGW("%s: Qemu camera device is not capturing.", __FUNCTION__);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop the actual camera device. */
|
/* Stop the worker thread first. */
|
||||||
status_t res = mQemuClient.queryStop();
|
status_t res = stopWorkerThread();
|
||||||
if (res == NO_ERROR) {
|
if (res == NO_ERROR) {
|
||||||
/* Stop the worker thread. */
|
/* Stop the actual camera device. */
|
||||||
res = stopWorkerThread();
|
res = mQemuClient.queryStop();
|
||||||
if (res == NO_ERROR) {
|
if (res == NO_ERROR) {
|
||||||
if (mPreviewFrame == NULL) {
|
if (mPreviewFrame == NULL) {
|
||||||
delete[] mPreviewFrame;
|
delete[] mPreviewFrame;
|
||||||
@@ -187,9 +185,11 @@ status_t EmulatedQemuCameraDevice::stopDevice()
|
|||||||
}
|
}
|
||||||
mState = ECDS_CONNECTED;
|
mState = ECDS_CONNECTED;
|
||||||
LOGV("%s: Stopped", __FUNCTION__);
|
LOGV("%s: Stopped", __FUNCTION__);
|
||||||
|
} else {
|
||||||
|
LOGE("%s: Stop failed", __FUNCTION__);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOGE("%s: Stop failed", __FUNCTION__);
|
LOGE("%s: Unable to stop worker thread", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -111,8 +111,6 @@ void PreviewWindow::onNextFrameAvailable(const void* frame,
|
|||||||
nsecs_t timestamp,
|
nsecs_t timestamp,
|
||||||
EmulatedCameraDevice* camera_dev)
|
EmulatedCameraDevice* camera_dev)
|
||||||
{
|
{
|
||||||
LOGV("%s", __FUNCTION__);
|
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
Mutex::Autolock locker(&mObjectLock);
|
Mutex::Autolock locker(&mObjectLock);
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,13 @@
|
|||||||
#include "EmulatedCamera.h"
|
#include "EmulatedCamera.h"
|
||||||
#include "QemuClient.h"
|
#include "QemuClient.h"
|
||||||
|
|
||||||
|
#define LOG_QUERIES 0
|
||||||
|
#if LOG_QUERIES
|
||||||
|
#define LOGQ(...) LOGD(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define LOGQ(...) (void(0))
|
||||||
|
|
||||||
|
#endif // LOG_QUERIES
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -329,13 +336,18 @@ status_t QemuClient::doQuery(QemuQuery* query)
|
|||||||
return query->mQueryStatus;
|
return query->mQueryStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGQ("Send query '%s'", query->mQuery);
|
||||||
|
|
||||||
/* Send the query. */
|
/* Send the query. */
|
||||||
status_t res = sendMessage(query->mQuery, strlen(query->mQuery) + 1);
|
status_t res = sendMessage(query->mQuery, strlen(query->mQuery) + 1);
|
||||||
if (res == NO_ERROR) {
|
if (res == NO_ERROR) {
|
||||||
/* Read the response. */
|
/* Read the response. */
|
||||||
res = receiveMessage(reinterpret_cast<void**>(&query->mReplyBuffer),
|
res = receiveMessage(reinterpret_cast<void**>(&query->mReplyBuffer),
|
||||||
&query->mReplySize);
|
&query->mReplySize);
|
||||||
if (res != NO_ERROR) {
|
if (res == NO_ERROR) {
|
||||||
|
LOGQ("Response to query '%s': Status = '%.2s', %d bytes in response",
|
||||||
|
query->mQuery, query->mReplyBuffer, query->mReplySize);
|
||||||
|
} else {
|
||||||
LOGE("%s Response to query '%s' has failed: %s",
|
LOGE("%s Response to query '%s' has failed: %s",
|
||||||
__FUNCTION__, query->mQuery, strerror(res));
|
__FUNCTION__, query->mQuery, strerror(res));
|
||||||
}
|
}
|
||||||
@@ -488,8 +500,6 @@ status_t CameraQemuClient::queryFrame(void* vframe,
|
|||||||
size_t vframe_size,
|
size_t vframe_size,
|
||||||
size_t pframe_size)
|
size_t pframe_size)
|
||||||
{
|
{
|
||||||
LOGV("%s", __FUNCTION__);
|
|
||||||
|
|
||||||
char query_str[256];
|
char query_str[256];
|
||||||
snprintf(query_str, sizeof(query_str), "%s video=%d preview=%d",
|
snprintf(query_str, sizeof(query_str), "%s video=%d preview=%d",
|
||||||
mQueryFrame, (vframe && vframe_size) ? vframe_size : 0,
|
mQueryFrame, (vframe && vframe_size) ? vframe_size : 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user