Skip to content

Commit 819d2aa

Browse files
Eino-Ville TalvalaAndroid (Google) Code Review
authored andcommitted
Merge "EmulatedFakeCamera2: Add autofocus management" into jb-mr1-dev
2 parents 81a034f + f856a82 commit 819d2aa

File tree

4 files changed

+479
-21
lines changed

4 files changed

+479
-21
lines changed

tools/emulator/system/camera/EmulatedCamera2.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ int EmulatedCamera2::trigger_action(const camera2_device_t *d,
305305
int EmulatedCamera2::set_notify_callback(const camera2_device_t *d,
306306
camera2_notify_callback notify_cb, void* user) {
307307
EmulatedCamera2* ec = getInstance(d);
308+
Mutex::Autolock l(ec->mMutex);
308309
ec->mNotifyCb = notify_cb;
309310
ec->mNotifyUserPtr = user;
310311
return NO_ERROR;
@@ -355,6 +356,18 @@ int EmulatedCamera2::close(struct hw_device_t* device) {
355356
return ec->closeCamera();
356357
}
357358

359+
void EmulatedCamera2::sendNotification(int32_t msgType,
360+
int32_t ext1, int32_t ext2, int32_t ext3) {
361+
camera2_notify_callback notifyCb;
362+
{
363+
Mutex::Autolock l(mMutex);
364+
notifyCb = mNotifyCb;
365+
}
366+
if (notifyCb != NULL) {
367+
notifyCb(msgType, ext1, ext2, ext3, mNotifyUserPtr);
368+
}
369+
}
370+
358371
camera2_device_ops_t EmulatedCamera2::sDeviceOps = {
359372
EmulatedCamera2::set_request_queue_src_ops,
360373
EmulatedCamera2::notify_request_queue_not_empty,

tools/emulator/system/camera/EmulatedCamera2.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "hardware/camera2.h"
2929
#include "system/camera_metadata.h"
3030
#include "EmulatedBaseCamera.h"
31+
#include <utils/Thread.h>
32+
#include <utils/Mutex.h>
3133

3234
namespace android {
3335

@@ -128,7 +130,7 @@ class EmulatedCamera2 : public camera2_device, public EmulatedBaseCamera {
128130

129131
/** 3A action triggering */
130132
virtual int triggerAction(uint32_t trigger_id,
131-
int ext1, int ext2);
133+
int32_t ext1, int32_t ext2);
132134

133135
/** Custom tag definitions */
134136
virtual const char* getVendorSectionName(uint32_t tag);
@@ -232,21 +234,27 @@ class EmulatedCamera2 : public camera2_device, public EmulatedBaseCamera {
232234
* Data members shared with implementations
233235
***************************************************************************/
234236
protected:
237+
/** Mutex for calls through camera2 device interface */
238+
Mutex mMutex;
239+
235240
const camera2_request_queue_src_ops *mRequestQueueSrc;
236241
const camera2_frame_queue_dst_ops *mFrameQueueDst;
237-
camera2_notify_callback mNotifyCb;
238-
void* mNotifyUserPtr;
239242

240243
struct TagOps : public vendor_tag_query_ops {
241244
EmulatedCamera2 *parent;
242245
};
243246
TagOps mVendorTagOps;
244247

248+
void sendNotification(int32_t msgType,
249+
int32_t ext1, int32_t ext2, int32_t ext3);
250+
245251
/****************************************************************************
246252
* Data members
247253
***************************************************************************/
248254
private:
249255
static camera2_device_ops_t sDeviceOps;
256+
camera2_notify_callback mNotifyCb;
257+
void* mNotifyUserPtr;
250258
};
251259

252260
}; /* namespace android */

0 commit comments

Comments
 (0)