Merge "hwcomposer2: add api to control vsync period"
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index 6821448..30417b9 100644
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -821,13 +821,22 @@
return 0;
}
- // If the write to the sink would block when no input stream is present, flush enough frames
+ // If the write to the sink would block, flush enough frames
// from the pipe to make space to write the most recent data.
+ // We DO NOT block if:
+ // - no peer input stream is present
+ // - the peer input is in standby AFTER having been active.
+ // We DO block if:
+ // - the input was never activated to avoid discarding first frames
+ // in the pipe in case capture start was delayed
{
const size_t availableToWrite = sink->availableToWrite();
// NOTE: rsxSink has been checked above and sink and source life cycles are synchronized
sp<MonoPipeReader> source = rsxadev->routes[out->route_handle].rsxSource;
- if (rsxadev->routes[out->route_handle].input == NULL && availableToWrite < frames) {
+ const struct submix_stream_in *in = rsxadev->routes[out->route_handle].input;
+ const bool dont_block = (in == NULL)
+ || (in->input_standby && (in->read_counter_frames != 0));
+ if (dont_block && availableToWrite < frames) {
static uint8_t flush_buffer[64];
const size_t flushBufferSizeFrames = sizeof(flush_buffer) / frame_size;
size_t frames_to_flush_from_source = frames - availableToWrite;
diff --git a/modules/gralloc/framebuffer.cpp b/modules/gralloc/framebuffer.cpp
index c171711..b2ec3e4 100644
--- a/modules/gralloc/framebuffer.cpp
+++ b/modules/gralloc/framebuffer.cpp
@@ -117,7 +117,7 @@
/*****************************************************************************/
-int mapFrameBufferLocked(struct private_module_t* module)
+int mapFrameBufferLocked(struct private_module_t* module, int format)
{
// already initialized...
if (module->framebuffer) {
@@ -161,6 +161,20 @@
*/
info.yres_virtual = info.yres * NUM_BUFFERS;
+ switch (format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ info.bits_per_pixel = 32;
+ info.red.offset = 0;
+ info.red.length = 8;
+ info.green.offset = 8;
+ info.green.length = 8;
+ info.blue.offset = 16;
+ info.blue.length = 8;
+ break;
+ default:
+ ALOGW("unknown format: %d", format);
+ break;
+ }
uint32_t flags = PAGE_FLIP;
#if USE_PAN_DISPLAY
@@ -280,7 +294,8 @@
static int mapFrameBuffer(struct private_module_t* module)
{
pthread_mutex_lock(&module->lock);
- int err = mapFrameBufferLocked(module);
+ // Request RGBA8888 because the platform assumes support for RGBA8888.
+ int err = mapFrameBufferLocked(module, HAL_PIXEL_FORMAT_RGBA_8888);
pthread_mutex_unlock(&module->lock);
return err;
}
diff --git a/modules/gralloc/gr.h b/modules/gralloc/gr.h
index ac7e967..14fe6a0 100644
--- a/modules/gralloc/gr.h
+++ b/modules/gralloc/gr.h
@@ -36,7 +36,7 @@
return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
}
-int mapFrameBufferLocked(struct private_module_t* module);
+int mapFrameBufferLocked(struct private_module_t* module, int format);
int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd);
int mapBuffer(gralloc_module_t const* module, private_handle_t* hnd);
diff --git a/modules/gralloc/gralloc.cpp b/modules/gralloc/gralloc.cpp
index 07bbfba..87bda97 100644
--- a/modules/gralloc/gralloc.cpp
+++ b/modules/gralloc/gralloc.cpp
@@ -101,7 +101,7 @@
/*****************************************************************************/
static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev,
- size_t size, int usage, buffer_handle_t* pHandle)
+ size_t size, int format, int usage, buffer_handle_t* pHandle)
{
private_module_t* m = reinterpret_cast<private_module_t*>(
dev->common.module);
@@ -110,7 +110,7 @@
if (m->framebuffer == NULL) {
// initialize the framebuffer, the framebuffer is mapped once
// and forever.
- int err = mapFrameBufferLocked(m);
+ int err = mapFrameBufferLocked(m, format);
if (err < 0) {
return err;
}
@@ -154,12 +154,12 @@
}
static int gralloc_alloc_framebuffer(alloc_device_t* dev,
- size_t size, int usage, buffer_handle_t* pHandle)
+ size_t size, int format, int usage, buffer_handle_t* pHandle)
{
private_module_t* m = reinterpret_cast<private_module_t*>(
dev->common.module);
pthread_mutex_lock(&m->lock);
- int err = gralloc_alloc_framebuffer_locked(dev, size, usage, pHandle);
+ int err = gralloc_alloc_framebuffer_locked(dev, size, format, usage, pHandle);
pthread_mutex_unlock(&m->lock);
return err;
}
@@ -236,7 +236,7 @@
int err;
if (usage & GRALLOC_USAGE_HW_FB) {
- err = gralloc_alloc_framebuffer(dev, size, usage, pHandle);
+ err = gralloc_alloc_framebuffer(dev, size, format, usage, pHandle);
} else {
err = gralloc_alloc_buffer(dev, size, usage, pHandle);
}