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

Change-Id: I33fd11fc269a649bb20bbdfd205dbfbb9a9902ff
  • Loading branch information
stargo authored and andi34 committed Sep 8, 2016
1 parent 6ffb973 commit 9d246c9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions media/libstagefright/ACodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,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 @@ -993,6 +999,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 @@ -134,6 +134,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
endif

LOCAL_CLANG := true

LOCAL_MODULE:= libstagefright
Expand Down
10 changes: 9 additions & 1 deletion media/libstagefright/OMXCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,12 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
// plus an extra buffer to account for incorrect minUndequeuedBufs
CODEC_LOGI("OMX-buffers: min=%u actual=%u undeq=%d+1",
def.nBufferCountMin, def.nBufferCountActual, 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 + minUndequeuedBufs) {
#endif
for (OMX_U32 extraBuffers = 2 + 1; /* condition inside loop */; extraBuffers--) {
OMX_U32 newBufferCount =
def.nBufferCountMin + minUndequeuedBufs + extraBuffers;
Expand All @@ -1834,6 +1839,9 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
return err;
}
}
#ifdef BOARD_CANT_REALLOCATE_OMX_BUFFERS
}
#endif
CODEC_LOGI("OMX-buffers: min=%u actual=%u undeq=%d+1",
def.nBufferCountMin, def.nBufferCountActual, minUndequeuedBufs);

Expand Down

0 comments on commit 9d246c9

Please sign in to comment.