#ifndef ANDROID_OVERLAY_INTERFACE_H
#define ANDROID_OVERLAY_INTERFACE_H
+#include <cutils/native_handle.h>
+
#include <hardware/hardware.h>
#include <stdint.h>
/*****************************************************************************/
/* opaque reference to an Overlay kernel object */
-typedef struct {
- int numFds;
- int fds[4];
- int numInts;
- int data[0];
-} overlay_handle_t;
+typedef const native_handle* overlay_handle_t;
typedef struct overlay_t {
uint32_t w;
uint32_t reserved[3];
/* returns a reference to this overlay's handle (the caller doesn't
* take ownership) */
- overlay_handle_t const* (*getHandleRef)(struct overlay_t* overlay);
+ overlay_handle_t (*getHandleRef)(struct overlay_t* overlay);
uint32_t reserved_procs[7];
} overlay_t;
/* initialize the overlay from the given handle. this associates this
* overlay data module to its control module */
int (*initialize)(struct overlay_data_device_t *dev,
- overlay_handle_t const* handle);
+ overlay_handle_t handle);
/* blocks until an overlay buffer is available and return that buffer. */
int (*dequeueBuffer)(struct overlay_data_device_t *dev,
/*
* This is the overlay_t object, it is returned to the user and represents
- * an overlay. here we use a subclass, where we can store our own state.
- * Notice the use of "overlay_handle_t", which is an "opaque" marshallable
- * handle, it can contains any number of ints and up to 4 filedescriptors.
- * In this example we store no fd and 2 ints.
+ * an overlay.
* This handles will be passed across processes and possibly given to other
* HAL modules (for instance video decode modules).
*/
class overlay_object : public overlay_t {
- struct handle_t : public overlay_handle_t {
+ struct handle_t : public native_handle {
/* add the data fields we need here, for instance: */
int width;
int height;
handle_t mHandle;
- static overlay_handle_t const* getHandleRef(struct overlay_t* overlay) {
+ static overlay_handle_t getHandleRef(struct overlay_t* overlay) {
/* returns a reference to the handle, caller doesn't take ownership */
return &(static_cast<overlay_object *>(overlay)->mHandle);
}
public:
overlay_object() {
this->overlay_t::getHandleRef = getHandleRef;
+ mHandle.version = sizeof(native_handle);
mHandle.numFds = 0;
mHandle.numInts = 2; // extra ints we have in our handle
}
// ****************************************************************************
int overlay_initialize(struct overlay_data_device_t *dev,
- overlay_handle_t const* handle)
+ overlay_handle_t handle)
{
/*
* overlay_handle_t should contain all the information to "inflate" this
}
int overlay_dequeueBuffer(struct overlay_data_device_t *dev,
- overlay_buffer_t buf)
+ overlay_buffer_t* buf)
{
/* blocks until a buffer is available and return an opaque structure
* representing this buffer.