summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-01-15 15:28:19 -0800
committerAndreas Huber <andih@google.com>2010-01-19 10:57:57 -0800
commit7eaa9c9385535b651064e02d05a8ffa4b2359281 (patch)
treeda5f6ba264cd97c4fa08cdcc0666ca2b5cc7175f /media
parenta2ce85733c8e42c30927eefe3ff4e4bd36515041 (diff)
downloadframeworks_av-7eaa9c9385535b651064e02d05a8ffa4b2359281.zip
frameworks_av-7eaa9c9385535b651064e02d05a8ffa4b2359281.tar.gz
frameworks_av-7eaa9c9385535b651064e02d05a8ffa4b2359281.tar.bz2
Avoid unnecessary buffer copying if at all possible, detect if running in the mediaserver process.
Diffstat (limited to 'media')
-rw-r--r--media/libmedia/IOMX.cpp24
-rw-r--r--media/libstagefright/OMXCodec.cpp19
-rw-r--r--media/libstagefright/include/OMX.h2
-rw-r--r--media/libstagefright/omx/OMX.cpp4
4 files changed, 42 insertions, 7 deletions
diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp
index b43e48f..277bce1 100644
--- a/media/libmedia/IOMX.cpp
+++ b/media/libmedia/IOMX.cpp
@@ -12,6 +12,7 @@ namespace android {
enum {
CONNECT = IBinder::FIRST_CALL_TRANSACTION,
+ LIVES_LOCALLY,
LIST_NODES,
ALLOCATE_NODE,
FREE_NODE,
@@ -75,6 +76,15 @@ public:
: BpInterface<IOMX>(impl) {
}
+ virtual bool livesLocally(pid_t pid) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
+ data.writeInt32(pid);
+ remote()->transact(LIVES_LOCALLY, data, &reply);
+
+ return reply.readInt32() != 0;
+ }
+
virtual status_t listNodes(List<ComponentInfo> *list) {
list->clear();
@@ -369,6 +379,14 @@ IMPLEMENT_META_INTERFACE(OMX, "android.hardware.IOMX");
status_t BnOMX::onTransact(
uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
switch (code) {
+ case LIVES_LOCALLY:
+ {
+ CHECK_INTERFACE(IOMX, data, reply);
+ reply->writeInt32(livesLocally((pid_t)data.readInt32()));
+
+ return OK;
+ }
+
case LIST_NODES:
{
CHECK_INTERFACE(IOMX, data, reply);
@@ -408,7 +426,7 @@ status_t BnOMX::onTransact(
if (err == OK) {
reply->writeIntPtr((intptr_t)node);
}
-
+
return NO_ERROR;
}
@@ -419,7 +437,7 @@ status_t BnOMX::onTransact(
node_id node = (void*)data.readIntPtr();
reply->writeInt32(freeNode(node));
-
+
return NO_ERROR;
}
@@ -631,7 +649,7 @@ status_t BnOMX::onTransact(
node_id node = (void*)data.readIntPtr();
const char *parameter_name = data.readCString();
-
+
OMX_INDEXTYPE index;
status_t err = getExtensionIndex(node, parameter_name, &index);
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index c4d3b5d..c583b93 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1016,6 +1016,7 @@ OMXCodec::OMXCodec(
const char *componentName,
const sp<MediaSource> &source)
: mOMX(omx),
+ mOMXLivesLocally(omx->livesLocally(getpid())),
mNode(node),
mQuirks(quirks),
mIsEncoder(isEncoder),
@@ -1191,12 +1192,22 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
IOMX::buffer_id buffer;
if (portIndex == kPortIndexInput
&& (mQuirks & kRequiresAllocateBufferOnInputPorts)) {
- err = mOMX->allocateBufferWithBackup(
- mNode, portIndex, mem, &buffer);
+ if (mOMXLivesLocally) {
+ err = mOMX->allocateBuffer(
+ mNode, portIndex, def.nBufferSize, &buffer);
+ } else {
+ err = mOMX->allocateBufferWithBackup(
+ mNode, portIndex, mem, &buffer);
+ }
} else if (portIndex == kPortIndexOutput
&& (mQuirks & kRequiresAllocateBufferOnOutputPorts)) {
- err = mOMX->allocateBufferWithBackup(
- mNode, portIndex, mem, &buffer);
+ if (mOMXLivesLocally) {
+ err = mOMX->allocateBuffer(
+ mNode, portIndex, def.nBufferSize, &buffer);
+ } else {
+ err = mOMX->allocateBufferWithBackup(
+ mNode, portIndex, mem, &buffer);
+ }
} else {
err = mOMX->useBuffer(mNode, portIndex, mem, &buffer);
}
diff --git a/media/libstagefright/include/OMX.h b/media/libstagefright/include/OMX.h
index ce0b0d5..b559101 100644
--- a/media/libstagefright/include/OMX.h
+++ b/media/libstagefright/include/OMX.h
@@ -31,6 +31,8 @@ class OMX : public BnOMX,
public:
OMX();
+ virtual bool livesLocally(pid_t pid);
+
virtual status_t listNodes(List<ComponentInfo> *list);
virtual status_t allocateNode(
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index 0d617a5..2121321 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -164,6 +164,10 @@ void OMX::binderDied(const wp<IBinder> &the_late_who) {
instance->onObserverDied(mMaster);
}
+bool OMX::livesLocally(pid_t pid) {
+ return pid == getpid();
+}
+
status_t OMX::listNodes(List<ComponentInfo> *list) {
list->clear();