summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
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
commitf1fe064d735698b09e4bc7b3a10e4dc3dba9a1d9 (patch)
tree1d8e2e0a407c8a11184c8a8e7a9f05847c03b00c /media/libstagefright
parent0a2d8709e4badeeb892b325c1b6fd52ad16f9c7d (diff)
downloadframeworks_base-f1fe064d735698b09e4bc7b3a10e4dc3dba9a1d9.zip
frameworks_base-f1fe064d735698b09e4bc7b3a10e4dc3dba9a1d9.tar.gz
frameworks_base-f1fe064d735698b09e4bc7b3a10e4dc3dba9a1d9.tar.bz2
Avoid unnecessary buffer copying if at all possible, detect if running in the mediaserver process.
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/OMXCodec.cpp19
-rw-r--r--media/libstagefright/include/OMX.h2
-rw-r--r--media/libstagefright/omx/OMX.cpp4
3 files changed, 21 insertions, 4 deletions
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();