Merge change 24872 into eclair
* changes:
Fix issue 2115450: a2dp thread is started, even though we are only connected to headset and not playing music.
diff --git a/include/private/ui/SharedBufferStack.h b/include/private/ui/SharedBufferStack.h
index 6181f55..8b0f154 100644
--- a/include/private/ui/SharedBufferStack.h
+++ b/include/private/ui/SharedBufferStack.h
@@ -228,6 +228,8 @@
friend struct Condition;
friend struct DequeueCondition;
friend struct LockCondition;
+
+ int32_t computeTail() const;
struct QueueUpdate : public UpdateBase {
inline QueueUpdate(SharedBufferBase* sbb);
diff --git a/include/utils/threads.h b/include/utils/threads.h
index f5304f7..0fc533f 100644
--- a/include/utils/threads.h
+++ b/include/utils/threads.h
@@ -90,11 +90,6 @@
ANDROID_TGROUP_MAX = ANDROID_TGROUP_FG_BOOST,
};
-typedef enum {
- SP_BACKGROUND = 0,
- SP_FOREGROUND = 1,
-} SchedPolicy;
-
// Create and run a new thread.
extern int androidCreateThread(android_thread_func_t, void *);
diff --git a/libs/surfaceflinger/Buffer.cpp b/libs/surfaceflinger/Buffer.cpp
index 4a7c55e..65650aa 100644
--- a/libs/surfaceflinger/Buffer.cpp
+++ b/libs/surfaceflinger/Buffer.cpp
@@ -106,6 +106,9 @@
// the requested flags should be honored.
usage = reqUsage | BufferAllocator::USAGE_HW_TEXTURE;
}
+
+ if (format == PIXEL_FORMAT_RGBX_8888)
+ format = PIXEL_FORMAT_RGBA_8888;
err = allocator.alloc(w, h, format, usage, &handle, &stride);
if (err == NO_ERROR) {
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index 6275910..1e7f1e6 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -176,6 +176,9 @@
// this failed, for instance, because we don't support
// NPOT.
// FIXME: do something!
+ LOGD("layer=%p, glEGLImageTargetTexture2DOES(%d) "
+ "failed err=0x%04x",
+ this, mTextures[index].image, error);
mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
} else {
// Everything went okay!
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index 1f22488..e08861d 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -590,7 +590,8 @@
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, texture_w, texture_h, 0,
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888) {
+ } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 ||
+ t.format == GGL_PIXEL_FORMAT_RGBX_8888) {
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, texture_w, texture_h, 0,
GL_RGBA, GL_UNSIGNED_BYTE, data);
@@ -620,7 +621,8 @@
0, bounds.top, t.width, bounds.height(),
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4,
t.data + bounds.top*t.stride*2);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888) {
+ } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 ||
+ t.format == GGL_PIXEL_FORMAT_RGBX_8888) {
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
GL_RGBA, GL_UNSIGNED_BYTE,
diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp
index 8685f99..a352431 100644
--- a/libs/surfaceflinger/SurfaceFlinger.cpp
+++ b/libs/surfaceflinger/SurfaceFlinger.cpp
@@ -1524,13 +1524,24 @@
result.append( l->lcblk->dump(" ") );
sp<const Buffer> buf0(l->getBuffer(0));
sp<const Buffer> buf1(l->getBuffer(1));
+ uint32_t w0=0, h0=0, s0=0;
+ uint32_t w1=0, h1=0, s1=0;
+ if (buf0 != 0) {
+ w0 = buf0->getWidth();
+ h0 = buf0->getHeight();
+ s0 = buf0->getStride();
+ }
+ if (buf1 != 0) {
+ w1 = buf1->getWidth();
+ h1 = buf1->getHeight();
+ s1 = buf1->getStride();
+ }
snprintf(buffer, SIZE,
" "
"format=%2d, [%3ux%3u:%3u] [%3ux%3u:%3u],"
" freezeLock=%p\n",
l->pixelFormat(),
- buf0->getWidth(), buf0->getHeight(), buf0->getStride(),
- buf1->getWidth(), buf1->getHeight(), buf1->getStride(),
+ w0, h0, s0, w1, h1, s1,
l->getFreezeLock().get());
result.append(buffer);
buffer[0] = 0;
diff --git a/libs/ui/SharedBufferStack.cpp b/libs/ui/SharedBufferStack.cpp
index 436d793..7789a3f 100644
--- a/libs/ui/SharedBufferStack.cpp
+++ b/libs/ui/SharedBufferStack.cpp
@@ -246,19 +246,26 @@
int surface, int num)
: SharedBufferBase(sharedClient, surface, num), tail(0)
{
+ tail = computeTail();
+}
+
+int32_t SharedBufferClient::computeTail() const
+{
SharedBufferStack& stack( *mSharedStack );
- int32_t avail;
- int32_t head;
// we need to make sure we read available and head coherently,
// w.r.t RetireUpdate.
+ int32_t newTail;
+ int32_t avail;
+ int32_t head;
do {
avail = stack.available;
head = stack.head;
} while (stack.available != avail);
- tail = head - avail + 1;
- if (tail < 0) {
- tail += num;
+ newTail = head - avail + 1;
+ if (newTail < 0) {
+ newTail += mNumBuffers;
}
+ return newTail;
}
ssize_t SharedBufferClient::dequeue()
@@ -296,6 +303,9 @@
{
UndoDequeueUpdate update(this);
status_t err = updateCondition( update );
+ if (err == NO_ERROR) {
+ tail = computeTail();
+ }
return err;
}