Skip to content

Commit

Permalink
libstagefright: Make it possible to skip OMX buffer reallocation
Browse files Browse the repository at this point in the history
Some devices don't like the call to setParameter() at this point, so
skip this call if enough buffers are already allocated. This check
was present in KitKat but got removed when code to allocate extra-
buffers was introduced.

This is activated only for omap4 for now.

Conflicts:
	media/libstagefright/Android.mk
	media/libstagefright/OMXCodec.cpp
  • Loading branch information
stargo authored and andi34 committed Sep 17, 2016
1 parent 65d2fb7 commit 83776ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions media/libstagefright/ACodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,12 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
// 2. try to allocate two (2) additional buffers to reduce starvation from
// the consumer
// plus an extra buffer to account for incorrect minUndequeuedBufs
#ifdef BOARD_CANT_REALLOCATE_OMX_BUFFERS
// Some devices don't like to set OMX_IndexParamPortDefinition at this
// point (even with an unmodified def), so skip it if possible.
// This check was present in KitKat.
if (def.nBufferCountActual < def.nBufferCountMin + *minUndequeuedBuffers) {
#endif
for (OMX_U32 extraBuffers = 2 + 1; /* condition inside loop */; extraBuffers--) {
OMX_U32 newBufferCount =
def.nBufferCountMin + *minUndequeuedBuffers + extraBuffers;
Expand All @@ -1071,6 +1077,9 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
return err;
}
}
#ifdef BOARD_CANT_REALLOCATE_OMX_BUFFERS
}
#endif

err = native_window_set_buffer_count(
mNativeWindow.get(), def.nBufferCountActual);
Expand Down
4 changes: 4 additions & 0 deletions media/libstagefright/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DENABLE_STAGEFRIGHT_EXPERIMENTS
endif

ifeq ($(TARGET_BOARD_PLATFORM),omap4)
LOCAL_CFLAGS := -DBOARD_CANT_REALLOCATE_OMX_BUFFERS

This comment has been minimized.

Copy link
@MWisBest

MWisBest Sep 27, 2016

Member

Errrrr, this should be +=, not :=

endif

LOCAL_CLANG := true
LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow

Expand Down

0 comments on commit 83776ea

Please sign in to comment.