From d95b46a1d130a90835f217540926f400a9075aa5 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 19 Jan 2011 10:34:52 -0800 Subject: Make parameter blocks read/writable even for SET_PARAMETER/SET_CONFIG requests. Refactor the logic a little. Change-Id: Idd7a26678d846c96b0b11f096305e7467381bda3 --- media/libmedia/IOMX.cpp | 78 +++++++++++++------------------------------------ 1 file changed, 20 insertions(+), 58 deletions(-) (limited to 'media') diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp index 9ce6738..af67175 100644 --- a/media/libmedia/IOMX.cpp +++ b/media/libmedia/IOMX.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -449,48 +450,9 @@ status_t BnOMX::onTransact( } case GET_PARAMETER: - { - CHECK_INTERFACE(IOMX, data, reply); - - node_id node = (void*)data.readIntPtr(); - OMX_INDEXTYPE index = static_cast(data.readInt32()); - - size_t size = data.readInt32(); - - // XXX I am not happy with this but Parcel::readInplace didn't work. - void *params = malloc(size); - data.read(params, size); - - status_t err = getParameter(node, index, params, size); - - reply->writeInt32(err); - - if (err == OK) { - reply->write(params, size); - } - - free(params); - params = NULL; - - return NO_ERROR; - } - case SET_PARAMETER: - { - CHECK_INTERFACE(IOMX, data, reply); - - node_id node = (void*)data.readIntPtr(); - OMX_INDEXTYPE index = static_cast(data.readInt32()); - - size_t size = data.readInt32(); - void *params = const_cast(data.readInplace(size)); - - reply->writeInt32(setParameter(node, index, params, size)); - - return NO_ERROR; - } - case GET_CONFIG: + case SET_CONFIG: { CHECK_INTERFACE(IOMX, data, reply); @@ -499,15 +461,30 @@ status_t BnOMX::onTransact( size_t size = data.readInt32(); - // XXX I am not happy with this but Parcel::readInplace didn't work. void *params = malloc(size); data.read(params, size); - status_t err = getConfig(node, index, params, size); + status_t err; + switch (code) { + case GET_PARAMETER: + err = getParameter(node, index, params, size); + break; + case SET_PARAMETER: + err = setParameter(node, index, params, size); + break; + case GET_CONFIG: + err = getConfig(node, index, params, size); + break; + case SET_CONFIG: + err = setConfig(node, index, params, size); + break; + default: + TRESPASS(); + } reply->writeInt32(err); - if (err == OK) { + if ((code == GET_PARAMETER || code == GET_CONFIG) && err == OK) { reply->write(params, size); } @@ -517,21 +494,6 @@ status_t BnOMX::onTransact( return NO_ERROR; } - case SET_CONFIG: - { - CHECK_INTERFACE(IOMX, data, reply); - - node_id node = (void*)data.readIntPtr(); - OMX_INDEXTYPE index = static_cast(data.readInt32()); - - size_t size = data.readInt32(); - void *params = const_cast(data.readInplace(size)); - - reply->writeInt32(setConfig(node, index, params, size)); - - return NO_ERROR; - } - case ENABLE_GRAPHIC_BUFFERS: { CHECK_INTERFACE(IOMX, data, reply); -- cgit v1.1