summaryrefslogtreecommitdiffstats
path: root/camera/SensorListener.cpp
diff options
context:
space:
mode:
authorDaniel Levin <dendy@ti.com>2012-05-29 15:33:53 +0300
committerDaniel Levin <dendy@ti.com>2012-07-25 08:56:45 -0500
commit21d4114f53d8d6c85db477437e51151591599f45 (patch)
tree8f69f8954f2d5215d727dfe56a63013f6c67e870 /camera/SensorListener.cpp
parent0db69e2a940fea8c70c8259d74358c6dfd6ff1bf (diff)
downloadhardware_ti_omap4-21d4114f53d8d6c85db477437e51151591599f45.zip
hardware_ti_omap4-21d4114f53d8d6c85db477437e51151591599f45.tar.gz
hardware_ti_omap4-21d4114f53d8d6c85db477437e51151591599f45.tar.bz2
CameraHAL: Moved Camera HAL sources out of namespace android
C++ namespace android:: is reserved for base Google Android types to avoid current and further conflicts with 3rd party code. Having TI Camera HAL under namespace android:: violates this rule, adding potential conflicts. This patch moves libtiutils and Camera HAL code out of namespace android:: to custom local namespaces. Putting camera code under namespace android and 'using namespace android' is not allowed anymore. All C++ Android types should have android:: namespace prefix explicitly. Next namespaces added: - Ti:: - placeholder for all custom code - Ti::Utils:: - common utility helper library - Ti::Camera:: - Camera HAL code Also added Ti::status_t as typedef for android::status_t. Change-Id: Ie8cc00d6d6bd4e8a8ddf089421010c370ee40ebe Signed-off-by: Daniel Levin <dendy@ti.com>
Diffstat (limited to 'camera/SensorListener.cpp')
-rw-r--r--camera/SensorListener.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/camera/SensorListener.cpp b/camera/SensorListener.cpp
index a5ddbd5..45a278b 100644
--- a/camera/SensorListener.cpp
+++ b/camera/SensorListener.cpp
@@ -27,7 +27,8 @@
#include <math.h>
#include <sys/types.h>
-namespace android {
+namespace Ti {
+namespace Camera {
/*** static declarations ***/
static const float RADIANS_2_DEG = (float) (180 / M_PI);
@@ -43,7 +44,7 @@ static int sensor_events_listener(int fd, int events, void* data)
ASensorEvent sen_events[8];
while ((num_sensors = listener->mSensorEventQueue->read(sen_events, 8)) > 0) {
for (int i = 0; i < num_sensors; i++) {
- if (sen_events[i].type == Sensor::TYPE_ACCELEROMETER) {
+ if (sen_events[i].type == android::Sensor::TYPE_ACCELEROMETER) {
float x = sen_events[i].vector.azimuth;
float y = sen_events[i].vector.pitch;
float z = sen_events[i].vector.roll;
@@ -76,7 +77,7 @@ static int sensor_events_listener(int fd, int events, void* data)
}
listener->handleOrientation(orient, tilt);
CAMHAL_LOGVB(" tilt = %d orientation = %d", tilt, orient);
- } else if (sen_events[i].type == Sensor::TYPE_GYROSCOPE) {
+ } else if (sen_events[i].type == android::Sensor::TYPE_GYROSCOPE) {
CAMHAL_LOGVA("GYROSCOPE EVENT");
}
}
@@ -129,11 +130,11 @@ SensorListener::~SensorListener() {
status_t SensorListener::initialize() {
status_t ret = NO_ERROR;
- SensorManager& mgr(SensorManager::getInstance());
+ android::SensorManager& mgr(android::SensorManager::getInstance());
LOG_FUNCTION_NAME;
- sp<Looper> mLooper;
+ android::sp<android::Looper> mLooper;
mSensorEventQueue = mgr.createEventQueue();
if (mSensorEventQueue == NULL) {
@@ -142,7 +143,7 @@ status_t SensorListener::initialize() {
goto out;
}
- mLooper = new Looper(false);
+ mLooper = new android::Looper(false);
mLooper->addFd(mSensorEventQueue->getFd(), 0, ALOOPER_EVENT_INPUT, sensor_events_listener, this);
if (mSensorLooperThread.get() == NULL)
@@ -154,7 +155,7 @@ status_t SensorListener::initialize() {
goto out;
}
- ret = mSensorLooperThread->run("sensor looper thread", PRIORITY_URGENT_DISPLAY);
+ ret = mSensorLooperThread->run("sensor looper thread", android::PRIORITY_URGENT_DISPLAY);
if (ret == INVALID_OPERATION){
CAMHAL_LOGDA("thread already running ?!?");
} else if (ret != NO_ERROR) {
@@ -181,7 +182,7 @@ void SensorListener::setCallbacks(orientation_callback_t orientation_cb, void *c
void SensorListener::handleOrientation(uint32_t orientation, uint32_t tilt) {
LOG_FUNCTION_NAME;
- Mutex::Autolock lock(&mLock);
+ android::AutoMutex lock(&mLock);
if (mOrientationCb && (sensorsEnabled & SENSOR_ORIENTATION)) {
mOrientationCb(orientation, tilt, mCbCookie);
@@ -191,15 +192,15 @@ void SensorListener::handleOrientation(uint32_t orientation, uint32_t tilt) {
}
void SensorListener::enableSensor(sensor_type_t type) {
- Sensor const* sensor;
- SensorManager& mgr(SensorManager::getInstance());
+ android::Sensor const* sensor;
+ android::SensorManager& mgr(android::SensorManager::getInstance());
LOG_FUNCTION_NAME;
- Mutex::Autolock lock(&mLock);
+ android::AutoMutex lock(&mLock);
if ((type & SENSOR_ORIENTATION) && !(sensorsEnabled & SENSOR_ORIENTATION)) {
- sensor = mgr.getDefaultSensor(Sensor::TYPE_ACCELEROMETER);
+ sensor = mgr.getDefaultSensor(android::Sensor::TYPE_ACCELEROMETER);
CAMHAL_LOGDB("orientation = %p (%s)", sensor, sensor->getName().string());
mSensorEventQueue->enableSensor(sensor);
mSensorEventQueue->setEventRate(sensor, ms2ns(100));
@@ -210,15 +211,15 @@ void SensorListener::enableSensor(sensor_type_t type) {
}
void SensorListener::disableSensor(sensor_type_t type) {
- Sensor const* sensor;
- SensorManager& mgr(SensorManager::getInstance());
+ android::Sensor const* sensor;
+ android::SensorManager& mgr(android::SensorManager::getInstance());
LOG_FUNCTION_NAME;
- Mutex::Autolock lock(&mLock);
+ android::AutoMutex lock(&mLock);
if ((type & SENSOR_ORIENTATION) && (sensorsEnabled & SENSOR_ORIENTATION)) {
- sensor = mgr.getDefaultSensor(Sensor::TYPE_ACCELEROMETER);
+ sensor = mgr.getDefaultSensor(android::Sensor::TYPE_ACCELEROMETER);
CAMHAL_LOGDB("orientation = %p (%s)", sensor, sensor->getName().string());
mSensorEventQueue->disableSensor(sensor);
sensorsEnabled &= ~SENSOR_ORIENTATION;
@@ -227,4 +228,5 @@ void SensorListener::disableSensor(sensor_type_t type) {
LOG_FUNCTION_NAME_EXIT;
}
-} // namespace android
+} // namespace Camera
+} // namespace Ti