diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2012-05-17 17:54:56 -0700 |
---|---|---|
committer | Eino-Ville Talvala <etalvala@google.com> | 2012-05-17 17:54:56 -0700 |
commit | 08a6e5e374c57361275173e18eea120587627adf (patch) | |
tree | 62cab5525673917b314fc2ba20720c00c97ccb49 /tests | |
parent | 407a8eeeec8ac7edc947b003060e9f7a19bd7cd0 (diff) | |
download | hardware_libhardware-08a6e5e374c57361275173e18eea120587627adf.zip hardware_libhardware-08a6e5e374c57361275173e18eea120587627adf.tar.gz hardware_libhardware-08a6e5e374c57361275173e18eea120587627adf.tar.bz2 |
I am a HAL of constant structure.
Bug: 6243944
Change-Id: I126313f75f5f7165d3ca96f52054866c4fb6bee0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/camera2/camera2_utils.cpp | 58 | ||||
-rw-r--r-- | tests/camera2/camera2_utils.h | 31 |
2 files changed, 52 insertions, 37 deletions
diff --git a/tests/camera2/camera2_utils.cpp b/tests/camera2/camera2_utils.cpp index bd56644..e3ea99f 100644 --- a/tests/camera2/camera2_utils.cpp +++ b/tests/camera2/camera2_utils.cpp @@ -50,7 +50,7 @@ MetadataQueue::~MetadataQueue() { } // Interface to camera2 HAL as consumer (input requests/reprocessing) -camera2_request_queue_src_ops_t* MetadataQueue::getToConsumerInterface() { +const camera2_request_queue_src_ops_t* MetadataQueue::getToConsumerInterface() { return static_cast<camera2_request_queue_src_ops_t*>(this); } @@ -58,7 +58,7 @@ void MetadataQueue::setFromConsumerInterface(camera2_device_t *d) { mDevice = d; } -camera2_frame_queue_dst_ops_t* MetadataQueue::getToProducerInterface() { +const camera2_frame_queue_dst_ops_t* MetadataQueue::getToProducerInterface() { return static_cast<camera2_frame_queue_dst_ops_t*>(this); } @@ -181,26 +181,38 @@ status_t MetadataQueue::freeBuffers(List<camera_metadata_t*>::iterator start, return OK; } +MetadataQueue* MetadataQueue::getInstance( + const camera2_request_queue_src_ops_t *q) { + const MetadataQueue* cmq = static_cast<const MetadataQueue*>(q); + return const_cast<MetadataQueue*>(cmq); +} + +MetadataQueue* MetadataQueue::getInstance( + const camera2_frame_queue_dst_ops_t *q) { + const MetadataQueue* cmq = static_cast<const MetadataQueue*>(q); + return const_cast<MetadataQueue*>(cmq); +} + int MetadataQueue::consumer_buffer_count( - camera2_request_queue_src_ops_t *q) { - MetadataQueue *queue = static_cast<MetadataQueue *>(q); + const camera2_request_queue_src_ops_t *q) { + MetadataQueue *queue = getInstance(q); return queue->getBufferCount(); } -int MetadataQueue::consumer_dequeue(camera2_request_queue_src_ops_t *q, +int MetadataQueue::consumer_dequeue(const camera2_request_queue_src_ops_t *q, camera_metadata_t **buffer) { - MetadataQueue *queue = static_cast<MetadataQueue *>(q); + MetadataQueue *queue = getInstance(q); return queue->dequeue(buffer, true); } -int MetadataQueue::consumer_free(camera2_request_queue_src_ops_t *q, +int MetadataQueue::consumer_free(const camera2_request_queue_src_ops_t *q, camera_metadata_t *old_buffer) { - MetadataQueue *queue = static_cast<MetadataQueue *>(q); + MetadataQueue *queue = getInstance(q); free_camera_metadata(old_buffer); return OK; } -int MetadataQueue::producer_dequeue(camera2_frame_queue_dst_ops_t *q, +int MetadataQueue::producer_dequeue(const camera2_frame_queue_dst_ops_t *q, size_t entries, size_t bytes, camera_metadata_t **buffer) { camera_metadata_t *new_buffer = @@ -210,15 +222,15 @@ int MetadataQueue::producer_dequeue(camera2_frame_queue_dst_ops_t *q, return OK; } -int MetadataQueue::producer_cancel(camera2_frame_queue_dst_ops_t *q, +int MetadataQueue::producer_cancel(const camera2_frame_queue_dst_ops_t *q, camera_metadata_t *old_buffer) { free_camera_metadata(old_buffer); return OK; } -int MetadataQueue::producer_enqueue(camera2_frame_queue_dst_ops_t *q, +int MetadataQueue::producer_enqueue(const camera2_frame_queue_dst_ops_t *q, camera_metadata_t *filled_buffer) { - MetadataQueue *queue = static_cast<MetadataQueue *>(q); + MetadataQueue *queue = getInstance(q); return queue->enqueue(filled_buffer); } @@ -486,18 +498,18 @@ int StreamAdapter::getId() { return mId; } -camera2_stream_ops *StreamAdapter::getStreamOps() { +const camera2_stream_ops *StreamAdapter::getStreamOps() { return static_cast<camera2_stream_ops *>(this); } -ANativeWindow* StreamAdapter::toANW(camera2_stream_ops_t *w) { - return static_cast<StreamAdapter*>(w)->mConsumerInterface.get(); +ANativeWindow* StreamAdapter::toANW(const camera2_stream_ops_t *w) { + return static_cast<const StreamAdapter*>(w)->mConsumerInterface.get(); } -int StreamAdapter::dequeue_buffer(camera2_stream_ops_t *w, +int StreamAdapter::dequeue_buffer(const camera2_stream_ops_t *w, buffer_handle_t** buffer) { int res; - int state = static_cast<StreamAdapter*>(w)->mState; + int state = static_cast<const StreamAdapter*>(w)->mState; if (state != ACTIVE) { ALOGE("%s: Called when in bad state: %d", __FUNCTION__, state); return INVALID_OPERATION; @@ -515,10 +527,10 @@ int StreamAdapter::dequeue_buffer(camera2_stream_ops_t *w, return res; } -int StreamAdapter::enqueue_buffer(camera2_stream_ops_t* w, +int StreamAdapter::enqueue_buffer(const camera2_stream_ops_t* w, int64_t timestamp, buffer_handle_t* buffer) { - int state = static_cast<StreamAdapter*>(w)->mState; + int state = static_cast<const StreamAdapter*>(w)->mState; if (state != ACTIVE) { ALOGE("%s: Called when in bad state: %d", __FUNCTION__, state); return INVALID_OPERATION; @@ -531,9 +543,9 @@ int StreamAdapter::enqueue_buffer(camera2_stream_ops_t* w, container_of(buffer, ANativeWindowBuffer, handle)); } -int StreamAdapter::cancel_buffer(camera2_stream_ops_t* w, +int StreamAdapter::cancel_buffer(const camera2_stream_ops_t* w, buffer_handle_t* buffer) { - int state = static_cast<StreamAdapter*>(w)->mState; + int state = static_cast<const StreamAdapter*>(w)->mState; if (state != ACTIVE) { ALOGE("%s: Called when in bad state: %d", __FUNCTION__, state); return INVALID_OPERATION; @@ -543,9 +555,9 @@ int StreamAdapter::cancel_buffer(camera2_stream_ops_t* w, container_of(buffer, ANativeWindowBuffer, handle)); } -int StreamAdapter::set_crop(camera2_stream_ops_t* w, +int StreamAdapter::set_crop(const camera2_stream_ops_t* w, int left, int top, int right, int bottom) { - int state = static_cast<StreamAdapter*>(w)->mState; + int state = static_cast<const StreamAdapter*>(w)->mState; if (state != ACTIVE) { ALOGE("%s: Called when in bad state: %d", __FUNCTION__, state); return INVALID_OPERATION; diff --git a/tests/camera2/camera2_utils.h b/tests/camera2/camera2_utils.h index 4e0b521..2c9f801 100644 --- a/tests/camera2/camera2_utils.h +++ b/tests/camera2/camera2_utils.h @@ -40,10 +40,10 @@ class MetadataQueue: public camera2_request_queue_src_ops_t, // Interface to camera2 HAL device, either for requests (device is consumer) // or for frames (device is producer) - camera2_request_queue_src_ops_t* getToConsumerInterface(); + const camera2_request_queue_src_ops_t* getToConsumerInterface(); void setFromConsumerInterface(camera2_device_t *d); - camera2_frame_queue_dst_ops_t* getToProducerInterface(); + const camera2_frame_queue_dst_ops_t* getToProducerInterface(); // Real interfaces. On enqueue, queue takes ownership of buffer pointer // On dequeue, user takes ownership of buffer pointer. @@ -76,22 +76,25 @@ class MetadataQueue: public camera2_request_queue_src_ops_t, bool mSignalConsumer; - static int consumer_buffer_count(camera2_request_queue_src_ops_t *q); + static MetadataQueue* getInstance(const camera2_frame_queue_dst_ops_t *q); + static MetadataQueue* getInstance(const camera2_request_queue_src_ops_t *q); - static int consumer_dequeue(camera2_request_queue_src_ops_t *q, + static int consumer_buffer_count(const camera2_request_queue_src_ops_t *q); + + static int consumer_dequeue(const camera2_request_queue_src_ops_t *q, camera_metadata_t **buffer); - static int consumer_free(camera2_request_queue_src_ops_t *q, + static int consumer_free(const camera2_request_queue_src_ops_t *q, camera_metadata_t *old_buffer); - static int producer_dequeue(camera2_frame_queue_dst_ops_t *q, + static int producer_dequeue(const camera2_frame_queue_dst_ops_t *q, size_t entries, size_t bytes, camera_metadata_t **buffer); - static int producer_cancel(camera2_frame_queue_dst_ops_t *q, + static int producer_cancel(const camera2_frame_queue_dst_ops_t *q, camera_metadata_t *old_buffer); - static int producer_enqueue(camera2_frame_queue_dst_ops_t *q, + static int producer_enqueue(const camera2_frame_queue_dst_ops_t *q, camera_metadata_t *filled_buffer); }; @@ -193,21 +196,21 @@ class StreamAdapter: public camera2_stream_ops { int mFormatRequested; - camera2_stream_ops *getStreamOps(); + const camera2_stream_ops *getStreamOps(); - static ANativeWindow* toANW(camera2_stream_ops_t *w); + static ANativeWindow* toANW(const camera2_stream_ops_t *w); - static int dequeue_buffer(camera2_stream_ops_t *w, + static int dequeue_buffer(const camera2_stream_ops_t *w, buffer_handle_t** buffer); - static int enqueue_buffer(camera2_stream_ops_t* w, + static int enqueue_buffer(const camera2_stream_ops_t* w, int64_t timestamp, buffer_handle_t* buffer); - static int cancel_buffer(camera2_stream_ops_t* w, + static int cancel_buffer(const camera2_stream_ops_t* w, buffer_handle_t* buffer); - static int set_crop(camera2_stream_ops_t* w, + static int set_crop(const camera2_stream_ops_t* w, int left, int top, int right, int bottom); }; |