summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-05-18 17:04:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-18 17:04:02 +0000
commit6a266d0f9b2dec275299fbad119650a4019935f2 (patch)
treea539e8def7e37c507772425ed6eb41e498ad70db
parent706965400cc8f6bb663528535723df124f7c7608 (diff)
parentab2a73c98c342ce9459e446bb93d23253da2754a (diff)
downloadcamera-6a266d0f9b2dec275299fbad119650a4019935f2.tar.gz
Merge "EmulatedCamera: Avoid event queue setup in scene constructor" into rvc-dev
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedScene.cpp15
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedScene.h3
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedSensor.cpp1
3 files changed, 14 insertions, 5 deletions
diff --git a/devices/EmulatedCamera/hwl/EmulatedScene.cpp b/devices/EmulatedCamera/hwl/EmulatedScene.cpp
index df0c9f2..595adce 100644
--- a/devices/EmulatedCamera/hwl/EmulatedScene.cpp
+++ b/devices/EmulatedCamera/hwl/EmulatedScene.cpp
@@ -89,9 +89,13 @@ const uint8_t EmulatedScene::kScene[EmulatedScene::kSceneWidth *
EmulatedScene::EmulatedScene(int sensor_width_px, int sensor_height_px,
float sensor_sensitivity, int sensor_orientation,
bool is_front_facing)
- : sensor_handle_(-1), screen_rotation_(0), current_scene_(scene_rot0_),
- sensor_orientation_(sensor_orientation), is_front_facing_(is_front_facing),
- hour_(12), exposure_duration_(0.033f) {
+ : sensor_handle_(-1),
+ screen_rotation_(0),
+ current_scene_(scene_rot0_),
+ sensor_orientation_(sensor_orientation),
+ is_front_facing_(is_front_facing),
+ hour_(12),
+ exposure_duration_(0.033f) {
// Assume that sensor filters are sRGB primaries to start
filter_r_[0] = 3.2406f;
filter_r_[1] = -1.5372f;
@@ -107,7 +111,6 @@ EmulatedScene::EmulatedScene(int sensor_width_px, int sensor_height_px,
filter_b_[2] = 1.0570f;
InitiliazeSceneRotation(!is_front_facing_);
- InitializeSensorQueue();
Initialize(sensor_width_px, sensor_height_px, sensor_sensitivity);
}
@@ -433,6 +436,10 @@ void EmulatedScene::InitiliazeSceneRotation(bool clock_wise) {
}
void EmulatedScene::InitializeSensorQueue() {
+ if (sensor_event_queue_.get() != nullptr) {
+ return;
+ }
+
sp<ISensorManager> manager = ISensorManager::getService();
if (manager == nullptr) {
ALOGE("%s: Cannot get ISensorManager", __func__);
diff --git a/devices/EmulatedCamera/hwl/EmulatedScene.h b/devices/EmulatedCamera/hwl/EmulatedScene.h
index e3a5238..b0def35 100644
--- a/devices/EmulatedCamera/hwl/EmulatedScene.h
+++ b/devices/EmulatedCamera/hwl/EmulatedScene.h
@@ -45,6 +45,8 @@ class EmulatedScene : public RefBase {
bool is_front_facing);
~EmulatedScene();
+ void InitializeSensorQueue();
+
void Initialize(int sensor_width_px, int sensor_height_px,
float sensor_sensitivity);
@@ -105,7 +107,6 @@ class EmulatedScene : public RefBase {
};
void InitiliazeSceneRotation(bool clock_wise);
- void InitializeSensorQueue();
int32_t sensor_handle_;
sp<IEventQueue> sensor_event_queue_;
diff --git a/devices/EmulatedCamera/hwl/EmulatedSensor.cpp b/devices/EmulatedCamera/hwl/EmulatedSensor.cpp
index 823ae73..e94941b 100644
--- a/devices/EmulatedCamera/hwl/EmulatedSensor.cpp
+++ b/devices/EmulatedCamera/hwl/EmulatedSensor.cpp
@@ -368,6 +368,7 @@ status_t EmulatedSensor::StartUp(
device_chars->second.width, device_chars->second.height,
kElectronsPerLuxSecond, device_chars->second.orientation,
device_chars->second.is_front_facing);
+ scene_->InitializeSensorQueue();
jpeg_compressor_ = std::make_unique<JpegCompressor>();
auto res = run(LOG_TAG, ANDROID_PRIORITY_URGENT_DISPLAY);