Loading include/media/IOMX.h +5 −1 Original line number Diff line number Diff line Loading @@ -82,9 +82,13 @@ public: node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer) = 0; // This API clearly only makes sense if the caller lives in the // same process as the callee, i.e. is the media_server, as the // returned "buffer_data" pointer is just that, a pointer into local // address space. virtual status_t allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer) = 0; buffer_id *buffer, void **buffer_data) = 0; virtual status_t allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, Loading include/media/stagefright/OMXCodec.h +2 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,8 @@ private: IOMX::buffer_id mBuffer; bool mOwnedByComponent; sp<IMemory> mMem; size_t mSize; void *mData; MediaBuffer *mMediaBuffer; }; Loading media/libmedia/IOMX.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -240,7 +240,7 @@ public: virtual status_t allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer) { buffer_id *buffer, void **buffer_data) { Parcel data, reply; data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); data.writeIntPtr((intptr_t)node); Loading @@ -256,6 +256,7 @@ public: } *buffer = (void *)reply.readIntPtr(); *buffer_data = (void *)reply.readIntPtr(); return err; } Loading Loading @@ -569,11 +570,14 @@ status_t BnOMX::onTransact( size_t size = data.readInt32(); buffer_id buffer; status_t err = allocateBuffer(node, port_index, size, &buffer); void *buffer_data; status_t err = allocateBuffer( node, port_index, size, &buffer, &buffer_data); reply->writeInt32(err); if (err == OK) { reply->writeIntPtr((intptr_t)buffer); reply->writeIntPtr((intptr_t)buffer_data); } return NO_ERROR; Loading media/libstagefright/OMXCodec.cpp +35 −14 Original line number Diff line number Diff line Loading @@ -1189,12 +1189,19 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { sp<IMemory> mem = mDealer[portIndex]->allocate(def.nBufferSize); CHECK(mem.get() != NULL); BufferInfo info; info.mData = NULL; info.mSize = def.nBufferSize; IOMX::buffer_id buffer; if (portIndex == kPortIndexInput && (mQuirks & kRequiresAllocateBufferOnInputPorts)) { if (mOMXLivesLocally) { mem.clear(); err = mOMX->allocateBuffer( mNode, portIndex, def.nBufferSize, &buffer); mNode, portIndex, def.nBufferSize, &buffer, &info.mData); } else { err = mOMX->allocateBufferWithBackup( mNode, portIndex, mem, &buffer); Loading @@ -1202,8 +1209,11 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { } else if (portIndex == kPortIndexOutput && (mQuirks & kRequiresAllocateBufferOnOutputPorts)) { if (mOMXLivesLocally) { mem.clear(); err = mOMX->allocateBuffer( mNode, portIndex, def.nBufferSize, &buffer); mNode, portIndex, def.nBufferSize, &buffer, &info.mData); } else { err = mOMX->allocateBufferWithBackup( mNode, portIndex, mem, &buffer); Loading @@ -1217,14 +1227,17 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { return err; } BufferInfo info; if (mem != NULL) { info.mData = mem->pointer(); } info.mBuffer = buffer; info.mOwnedByComponent = false; info.mMem = mem; info.mMediaBuffer = NULL; if (portIndex == kPortIndexOutput) { info.mMediaBuffer = new MediaBuffer(mem->pointer(), mem->size()); info.mMediaBuffer = new MediaBuffer(info.mData, info.mSize); info.mMediaBuffer->setObserver(this); } Loading Loading @@ -1599,6 +1612,8 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) { } void OMXCodec::onStateChange(OMX_STATETYPE newState) { CODEC_LOGV("onStateChange %d", newState); switch (newState) { case OMX_StateIdle: { Loading Loading @@ -1666,6 +1681,12 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) { break; } case OMX_StateInvalid: { setState(ERROR); break; } default: { CHECK(!"should not be here."); Loading Loading @@ -1845,16 +1866,16 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { static const uint8_t kNALStartCode[4] = { 0x00, 0x00, 0x00, 0x01 }; CHECK(info->mMem->size() >= specific->mSize + 4); CHECK(info->mSize >= specific->mSize + 4); size += 4; memcpy(info->mMem->pointer(), kNALStartCode, 4); memcpy((uint8_t *)info->mMem->pointer() + 4, memcpy(info->mData, kNALStartCode, 4); memcpy((uint8_t *)info->mData + 4, specific->mData, specific->mSize); } else { CHECK(info->mMem->size() >= specific->mSize); memcpy(info->mMem->pointer(), specific->mData, specific->mSize); CHECK(info->mSize >= specific->mSize); memcpy(info->mData, specific->mData, specific->mSize); } mNoMoreOutputData = false; Loading Loading @@ -1901,12 +1922,12 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { srcLength = srcBuffer->range_length(); if (info->mMem->size() < srcLength) { LOGE("info->mMem->size() = %d, srcLength = %d", info->mMem->size(), srcLength); if (info->mSize < srcLength) { LOGE("info->mSize = %d, srcLength = %d", info->mSize, srcLength); } CHECK(info->mMem->size() >= srcLength); memcpy(info->mMem->pointer(), CHECK(info->mSize >= srcLength); memcpy(info->mData, (const uint8_t *)srcBuffer->data() + srcBuffer->range_offset(), srcLength); Loading media/libstagefright/include/OMX.h +1 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ public: virtual status_t allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer); buffer_id *buffer, void **buffer_data); virtual status_t allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, Loading Loading
include/media/IOMX.h +5 −1 Original line number Diff line number Diff line Loading @@ -82,9 +82,13 @@ public: node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer) = 0; // This API clearly only makes sense if the caller lives in the // same process as the callee, i.e. is the media_server, as the // returned "buffer_data" pointer is just that, a pointer into local // address space. virtual status_t allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer) = 0; buffer_id *buffer, void **buffer_data) = 0; virtual status_t allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, Loading
include/media/stagefright/OMXCodec.h +2 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,8 @@ private: IOMX::buffer_id mBuffer; bool mOwnedByComponent; sp<IMemory> mMem; size_t mSize; void *mData; MediaBuffer *mMediaBuffer; }; Loading
media/libmedia/IOMX.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -240,7 +240,7 @@ public: virtual status_t allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer) { buffer_id *buffer, void **buffer_data) { Parcel data, reply; data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); data.writeIntPtr((intptr_t)node); Loading @@ -256,6 +256,7 @@ public: } *buffer = (void *)reply.readIntPtr(); *buffer_data = (void *)reply.readIntPtr(); return err; } Loading Loading @@ -569,11 +570,14 @@ status_t BnOMX::onTransact( size_t size = data.readInt32(); buffer_id buffer; status_t err = allocateBuffer(node, port_index, size, &buffer); void *buffer_data; status_t err = allocateBuffer( node, port_index, size, &buffer, &buffer_data); reply->writeInt32(err); if (err == OK) { reply->writeIntPtr((intptr_t)buffer); reply->writeIntPtr((intptr_t)buffer_data); } return NO_ERROR; Loading
media/libstagefright/OMXCodec.cpp +35 −14 Original line number Diff line number Diff line Loading @@ -1189,12 +1189,19 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { sp<IMemory> mem = mDealer[portIndex]->allocate(def.nBufferSize); CHECK(mem.get() != NULL); BufferInfo info; info.mData = NULL; info.mSize = def.nBufferSize; IOMX::buffer_id buffer; if (portIndex == kPortIndexInput && (mQuirks & kRequiresAllocateBufferOnInputPorts)) { if (mOMXLivesLocally) { mem.clear(); err = mOMX->allocateBuffer( mNode, portIndex, def.nBufferSize, &buffer); mNode, portIndex, def.nBufferSize, &buffer, &info.mData); } else { err = mOMX->allocateBufferWithBackup( mNode, portIndex, mem, &buffer); Loading @@ -1202,8 +1209,11 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { } else if (portIndex == kPortIndexOutput && (mQuirks & kRequiresAllocateBufferOnOutputPorts)) { if (mOMXLivesLocally) { mem.clear(); err = mOMX->allocateBuffer( mNode, portIndex, def.nBufferSize, &buffer); mNode, portIndex, def.nBufferSize, &buffer, &info.mData); } else { err = mOMX->allocateBufferWithBackup( mNode, portIndex, mem, &buffer); Loading @@ -1217,14 +1227,17 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { return err; } BufferInfo info; if (mem != NULL) { info.mData = mem->pointer(); } info.mBuffer = buffer; info.mOwnedByComponent = false; info.mMem = mem; info.mMediaBuffer = NULL; if (portIndex == kPortIndexOutput) { info.mMediaBuffer = new MediaBuffer(mem->pointer(), mem->size()); info.mMediaBuffer = new MediaBuffer(info.mData, info.mSize); info.mMediaBuffer->setObserver(this); } Loading Loading @@ -1599,6 +1612,8 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) { } void OMXCodec::onStateChange(OMX_STATETYPE newState) { CODEC_LOGV("onStateChange %d", newState); switch (newState) { case OMX_StateIdle: { Loading Loading @@ -1666,6 +1681,12 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) { break; } case OMX_StateInvalid: { setState(ERROR); break; } default: { CHECK(!"should not be here."); Loading Loading @@ -1845,16 +1866,16 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { static const uint8_t kNALStartCode[4] = { 0x00, 0x00, 0x00, 0x01 }; CHECK(info->mMem->size() >= specific->mSize + 4); CHECK(info->mSize >= specific->mSize + 4); size += 4; memcpy(info->mMem->pointer(), kNALStartCode, 4); memcpy((uint8_t *)info->mMem->pointer() + 4, memcpy(info->mData, kNALStartCode, 4); memcpy((uint8_t *)info->mData + 4, specific->mData, specific->mSize); } else { CHECK(info->mMem->size() >= specific->mSize); memcpy(info->mMem->pointer(), specific->mData, specific->mSize); CHECK(info->mSize >= specific->mSize); memcpy(info->mData, specific->mData, specific->mSize); } mNoMoreOutputData = false; Loading Loading @@ -1901,12 +1922,12 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { srcLength = srcBuffer->range_length(); if (info->mMem->size() < srcLength) { LOGE("info->mMem->size() = %d, srcLength = %d", info->mMem->size(), srcLength); if (info->mSize < srcLength) { LOGE("info->mSize = %d, srcLength = %d", info->mSize, srcLength); } CHECK(info->mMem->size() >= srcLength); memcpy(info->mMem->pointer(), CHECK(info->mSize >= srcLength); memcpy(info->mData, (const uint8_t *)srcBuffer->data() + srcBuffer->range_offset(), srcLength); Loading
media/libstagefright/include/OMX.h +1 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ public: virtual status_t allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer); buffer_id *buffer, void **buffer_data); virtual status_t allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, Loading