Skip to content

Commit

Permalink
Track graphic buffer mode in OMXNodeInstance
Browse files Browse the repository at this point in the history
Test: CtsMediaTestCases & YT & Play Movies & Cast
Bug: 62948670
Merged-In: Icbd9b767f1aef005819e680f77f4a05041988f34
Change-Id: Icbd9b767f1aef005819e680f77f4a05041988f34
(cherry picked from commit f630233)
  • Loading branch information
Dongwon Kang authored and andi34 committed Nov 18, 2017
1 parent 107165c commit ad0d1aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion media/libstagefright/include/OMXNodeInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,15 @@ struct OMXNodeInstance {
KeyedVector<OMX::buffer_id, OMX_BUFFERHEADERTYPE *> mBufferIDToBufferHeader;
KeyedVector<OMX_BUFFERHEADERTYPE *, OMX::buffer_id> mBufferHeaderToBufferID;

// metadata and secure buffer type tracking
// metadata and secure buffer types and graphic buffer mode tracking
MetadataBufferType mMetadataType[2];
enum SecureBufferType {
kSecureBufferTypeUnknown,
kSecureBufferTypeOpaque,
kSecureBufferTypeNativeHandle,
};
SecureBufferType mSecureBufferType[2];
bool mGraphicBufferEnabled[2];

// For debug support
char *mName;
Expand Down
23 changes: 23 additions & 0 deletions media/libstagefright/omx/OMXNodeInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ OMXNodeInstance::OMXNodeInstance(
mMetadataType[1] = kMetadataBufferTypeInvalid;
mSecureBufferType[0] = kSecureBufferTypeUnknown;
mSecureBufferType[1] = kSecureBufferTypeUnknown;
mGraphicBufferEnabled[0] = false;
mGraphicBufferEnabled[1] = false;
mIsSecure = AString(name).endsWith(".secure");
atomic_store(&mDying, false);
}
Expand Down Expand Up @@ -566,6 +568,12 @@ status_t OMXNodeInstance::enableNativeBuffers(
} else if (mSecureBufferType[portIndex] == kSecureBufferTypeUnknown) {
mSecureBufferType[portIndex] = kSecureBufferTypeOpaque;
}
} else {
if (err == OMX_ErrorNone) {
mGraphicBufferEnabled[portIndex] = enable;
} else if (enable) {
mGraphicBufferEnabled[portIndex] = false;
}
}
} else {
CLOG_ERROR_IF(enable, getExtensionIndex, err, "%s", name);
Expand Down Expand Up @@ -802,6 +810,13 @@ status_t OMXNodeInstance::useBuffer(
return BAD_VALUE;
}

if (mMetadataType[portIndex] == kMetadataBufferTypeInvalid
&& mGraphicBufferEnabled[portIndex]) {
ALOGE("b/62948670");
android_errorWriteLog(0x534e4554, "62948670");
return INVALID_OPERATION;
}

// metadata buffers are not connected cross process
// use a backup buffer instead of the actual buffer
BufferMeta *buffer_meta;
Expand Down Expand Up @@ -925,6 +940,14 @@ status_t OMXNodeInstance::useGraphicBuffer(
}
Mutex::Autolock autoLock(mLock);

if (!mGraphicBufferEnabled[portIndex]
|| mMetadataType[portIndex] != kMetadataBufferTypeInvalid) {
// Report error if this is not in graphic buffer mode.
ALOGE("b/62948670");
android_errorWriteLog(0x534e4554, "62948670");
return INVALID_OPERATION;
}

// See if the newer version of the extension is present.
OMX_INDEXTYPE index;
if (OMX_GetExtensionIndex(
Expand Down

0 comments on commit ad0d1aa

Please sign in to comment.