Files
android_hardware_libhardware/modules/sensors/dynamic_sensor/RingBuffer.h
Peng Xu 57d8af7f5e Dynamic sensor manager module - framework
Library to handle dynamic sensor connection. There are two way to use
this: as hal extension or standalone hal module.

In hal extension mode: add libdynamic_sensor_ext in dependency of hal,
instantiate DynamicSensorManager with appropriate parameters. Then
for all sensor requests, if the handle is owned by dynamic sensor
manager, forward the request.

In standalone mode, add sensor.dynamic_sensor_hal into device make
file. Usually, this also means multihal is necessary. Add
sensor.dynamic_sensor_hal into multihal configuration file.

This CL implements the dynamic sensor manager framework. Sensor daemon
will be added in follow up CL.

Test: test compile (functionality test done in a follow up CL)

Change-Id: I3b96ee135d8dbe3e199af01bed4b61637358803e
2017-03-07 20:50:56 -08:00

50 lines
1.2 KiB
C++

/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RING_BUFFER_H_
#define RING_BUFFER_H_
#include <media/stagefright/foundation/ABase.h>
#include <hardware/sensors.h>
#include <utils/threads.h>
namespace android {
class RingBuffer {
public:
explicit RingBuffer(size_t size);
~RingBuffer();
ssize_t write(const sensors_event_t *ev, size_t size);
ssize_t read(sensors_event_t *ev, size_t size);
private:
Mutex mLock;
Condition mNotEmptyCondition;
size_t mSize;
sensors_event_t *mData;
size_t mReadPos, mWritePos;
DISALLOW_EVIL_CONSTRUCTORS(RingBuffer);
};
} // namespace android
#endif // RING_BUFFER_H_