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__);
|
||||
|
||||
Mutex::Autolock locker(&mObjectLock);
|
||||
/* Validate pixel format, and calculate framebuffer size at the same time. */
|
||||
switch (pix_fmt) {
|
||||
case V4L2_PIX_FMT_YVU420:
|
||||
@@ -126,6 +127,7 @@ status_t EmulatedCameraDevice::stopCapturing()
|
||||
{
|
||||
LOGV("%s", __FUNCTION__);
|
||||
|
||||
Mutex::Autolock locker(&mObjectLock);
|
||||
/* Stop the camera. */
|
||||
const status_t res = stopDevice();
|
||||
if (res == NO_ERROR) {
|
||||
|
||||
@@ -90,7 +90,6 @@ status_t EmulatedFakeCameraDevice::startDevice()
|
||||
{
|
||||
LOGV("%s", __FUNCTION__);
|
||||
|
||||
Mutex::Autolock locker(&mObjectLock);
|
||||
if (!isConnected()) {
|
||||
LOGE("%s: Fake camera device is not connected.", __FUNCTION__);
|
||||
return EINVAL;
|
||||
|
||||
@@ -126,7 +126,6 @@ status_t EmulatedQemuCameraDevice::startDevice()
|
||||
{
|
||||
LOGV("%s", __FUNCTION__);
|
||||
|
||||
Mutex::Autolock locker(&mObjectLock);
|
||||
if (!isConnected()) {
|
||||
LOGE("%s: Qemu camera device is not connected.", __FUNCTION__);
|
||||
return EINVAL;
|
||||
@@ -169,17 +168,16 @@ status_t EmulatedQemuCameraDevice::stopDevice()
|
||||
{
|
||||
LOGV("%s", __FUNCTION__);
|
||||
|
||||
Mutex::Autolock locker(&mObjectLock);
|
||||
if (!isCapturing()) {
|
||||
LOGW("%s: Qemu camera device is not capturing.", __FUNCTION__);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/* Stop the actual camera device. */
|
||||
status_t res = mQemuClient.queryStop();
|
||||
/* Stop the worker thread first. */
|
||||
status_t res = stopWorkerThread();
|
||||
if (res == NO_ERROR) {
|
||||
/* Stop the worker thread. */
|
||||
res = stopWorkerThread();
|
||||
/* Stop the actual camera device. */
|
||||
res = mQemuClient.queryStop();
|
||||
if (res == NO_ERROR) {
|
||||
if (mPreviewFrame == NULL) {
|
||||
delete[] mPreviewFrame;
|
||||
@@ -187,10 +185,12 @@ status_t EmulatedQemuCameraDevice::stopDevice()
|
||||
}
|
||||
mState = ECDS_CONNECTED;
|
||||
LOGV("%s: Stopped", __FUNCTION__);
|
||||
}
|
||||
} else {
|
||||
LOGE("%s: Stop failed", __FUNCTION__);
|
||||
}
|
||||
} else {
|
||||
LOGE("%s: Unable to stop worker thread", __FUNCTION__);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -111,8 +111,6 @@ void PreviewWindow::onNextFrameAvailable(const void* frame,
|
||||
nsecs_t timestamp,
|
||||
EmulatedCameraDevice* camera_dev)
|
||||
{
|
||||
LOGV("%s", __FUNCTION__);
|
||||
|
||||
int res;
|
||||
Mutex::Autolock locker(&mObjectLock);
|
||||
|
||||
|
||||
@@ -25,6 +25,13 @@
|
||||
#include "EmulatedCamera.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 {
|
||||
|
||||
/****************************************************************************
|
||||
@@ -329,13 +336,18 @@ status_t QemuClient::doQuery(QemuQuery* query)
|
||||
return query->mQueryStatus;
|
||||
}
|
||||
|
||||
LOGQ("Send query '%s'", query->mQuery);
|
||||
|
||||
/* Send the query. */
|
||||
status_t res = sendMessage(query->mQuery, strlen(query->mQuery) + 1);
|
||||
if (res == NO_ERROR) {
|
||||
/* Read the response. */
|
||||
res = receiveMessage(reinterpret_cast<void**>(&query->mReplyBuffer),
|
||||
&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",
|
||||
__FUNCTION__, query->mQuery, strerror(res));
|
||||
}
|
||||
@@ -488,8 +500,6 @@ status_t CameraQemuClient::queryFrame(void* vframe,
|
||||
size_t vframe_size,
|
||||
size_t pframe_size)
|
||||
{
|
||||
LOGV("%s", __FUNCTION__);
|
||||
|
||||
char query_str[256];
|
||||
snprintf(query_str, sizeof(query_str), "%s video=%d preview=%d",
|
||||
mQueryFrame, (vframe && vframe_size) ? vframe_size : 0,
|
||||
|
||||
Reference in New Issue
Block a user