Merge change I66693ea2 into eclair
* changes:
fix sync exponential backoff for expedited syncs
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index 8279914..b63e97f 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -563,7 +563,19 @@
status_t ret = NO_ERROR;
if (mSurface != 0) {
if (mOverlayRef.get() == NULL) {
- mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT);
+
+ // FIXME:
+ // Surfaceflinger may hold onto the previous overlay reference for some
+ // time after we try to destroy it. retry a few times. In the future, we
+ // should make the destroy call block, or possibly specify that we can
+ // wait in the createOverlay call if the previous overlay is in the
+ // process of being destroyed.
+ for (int retry = 0; retry < 50; ++retry) {
+ mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT);
+ if (mOverlayRef != NULL) break;
+ LOGD("Overlay create failed - retrying");
+ usleep(20000);
+ }
if ( mOverlayRef.get() == NULL )
{
LOGE("Overlay Creation Failed!");
diff --git a/include/private/ui/SharedBufferStack.h b/include/private/ui/SharedBufferStack.h
index f6824d9..bbc1822 100644
--- a/include/private/ui/SharedBufferStack.h
+++ b/include/private/ui/SharedBufferStack.h
@@ -289,6 +289,7 @@
void setStatus(status_t status);
status_t reallocate();
status_t assertReallocate(int buffer);
+ int32_t getQueuedCount() const;
Region getDirtyRegion(int buffer) const;
diff --git a/include/private/ui/SurfaceFlingerSynchro.h b/include/private/ui/SurfaceFlingerSynchro.h
deleted file mode 100644
index 7386d33..0000000
--- a/include/private/ui/SurfaceFlingerSynchro.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef ANDROID_SURFACE_FLINGER_SYNCHRO_H
-#define ANDROID_SURFACE_FLINGER_SYNCHRO_H
-
-#include <stdint.h>
-#include <sys/types.h>
-#include <utils/Errors.h>
-#include <ui/ISurfaceComposer.h>
-
-namespace android {
-
-class SurfaceFlinger;
-
-class SurfaceFlingerSynchro
-{
-public:
- // client constructor
- SurfaceFlingerSynchro(const sp<ISurfaceComposer>& flinger);
- ~SurfaceFlingerSynchro();
-
- // signal surfaceflinger for some work
- status_t signal();
-
-private:
- friend class SurfaceFlinger;
- sp<ISurfaceComposer> mSurfaceComposer;
-};
-
-}; // namespace android
-
-#endif // ANDROID_SURFACE_FLINGER_SYNCHRO_H
-
diff --git a/include/ui/SurfaceComposerClient.h b/include/ui/SurfaceComposerClient.h
index 8701928..777b878 100644
--- a/include/ui/SurfaceComposerClient.h
+++ b/include/ui/SurfaceComposerClient.h
@@ -153,7 +153,7 @@
SharedClient* mControl;
sp<IMemoryHeap> mControlMemory;
sp<ISurfaceFlingerClient> mClient;
- SurfaceFlingerSynchro* mSignalServer;
+ sp<ISurfaceComposer> mSignalServer;
};
}; // namespace android
diff --git a/libs/audioflinger/A2dpAudioInterface.cpp b/libs/audioflinger/A2dpAudioInterface.cpp
index 57a29f2..351815b 100644
--- a/libs/audioflinger/A2dpAudioInterface.cpp
+++ b/libs/audioflinger/A2dpAudioInterface.cpp
@@ -16,7 +16,7 @@
#include <math.h>
-#define LOG_NDEBUG 0
+//#define LOG_NDEBUG 0
#define LOG_TAG "A2dpAudioInterface"
#include <utils/Log.h>
#include <utils/String8.h>
@@ -40,7 +40,7 @@
//}
A2dpAudioInterface::A2dpAudioInterface(AudioHardwareInterface* hw) :
- mOutput(0), mHardwareInterface(hw), mBluetoothEnabled(true)
+ mOutput(0), mHardwareInterface(hw), mBluetoothEnabled(true), mSuspended(false)
{
}
@@ -78,6 +78,7 @@
if ((err = out->set(devices, format, channels, sampleRate)) == NO_ERROR) {
mOutput = out;
mOutput->setBluetoothEnabled(mBluetoothEnabled);
+ mOutput->setSuspended(mSuspended);
} else {
delete out;
}
@@ -142,6 +143,14 @@
}
param.remove(key);
}
+ key = String8("A2dpSuspended");
+ if (param.get(key, value) == NO_ERROR) {
+ mSuspended = (value == "true");
+ if (mOutput) {
+ mOutput->setSuspended(mSuspended);
+ }
+ param.remove(key);
+ }
if (param.size()) {
status_t hwStatus = mHardwareInterface->setParameters(param.toString());
@@ -166,6 +175,12 @@
a2dpParam.add(key, value);
param.remove(key);
}
+ key = "A2dpSuspended";
+ if (param.get(key, value) == NO_ERROR) {
+ value = mSuspended ? "true" : "false";
+ a2dpParam.add(key, value);
+ param.remove(key);
+ }
String8 keyValuePairs = a2dpParam.toString();
@@ -204,7 +219,7 @@
mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL),
// assume BT enabled to start, this is safe because its only the
// enabled->disabled transition we are worried about
- mBluetoothEnabled(true), mDevice(0), mClosing(false)
+ mBluetoothEnabled(true), mDevice(0), mClosing(false), mSuspended(false)
{
// use any address by default
strcpy(mA2dpAddress, "00:00:00:00:00:00");
@@ -258,8 +273,10 @@
size_t remaining = bytes;
status_t status = -1;
- if (!mBluetoothEnabled || mClosing) {
- LOGW("A2dpAudioStreamOut::write(), but bluetooth disabled");
+ if (!mBluetoothEnabled || mClosing || mSuspended) {
+ LOGV("A2dpAudioStreamOut::write(), but bluetooth disabled \
+ mBluetoothEnabled %d, mClosing %d, mSuspended %d",
+ mBluetoothEnabled, mClosing, mSuspended);
goto Error;
}
@@ -408,6 +425,14 @@
return NO_ERROR;
}
+status_t A2dpAudioInterface::A2dpAudioStreamOut::setSuspended(bool onOff)
+{
+ LOGV("setSuspended %d", onOff);
+ mSuspended = onOff;
+ standby();
+ return NO_ERROR;
+}
+
status_t A2dpAudioInterface::A2dpAudioStreamOut::close()
{
Mutex::Autolock lock(mLock);
diff --git a/libs/audioflinger/A2dpAudioInterface.h b/libs/audioflinger/A2dpAudioInterface.h
index 35a6e11..530e432 100644
--- a/libs/audioflinger/A2dpAudioInterface.h
+++ b/libs/audioflinger/A2dpAudioInterface.h
@@ -101,6 +101,7 @@
status_t close_l();
status_t setAddress(const char* address);
status_t setBluetoothEnabled(bool enabled);
+ status_t setSuspended(bool onOff);
private:
int mFd;
@@ -113,6 +114,7 @@
bool mBluetoothEnabled;
uint32_t mDevice;
bool mClosing;
+ bool mSuspended;
};
friend class A2dpAudioStreamOut;
@@ -121,6 +123,7 @@
AudioHardwareInterface *mHardwareInterface;
char mA2dpAddress[20];
bool mBluetoothEnabled;
+ bool mSuspended;
};
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index 0258cee..7fd5434 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -454,14 +454,16 @@
// recompute visible region
recomputeVisibleRegions = true;
-
- // we now have the correct size, unfreeze the screen
- mFreezeLock.clear();
}
+
+ // we now have the correct size, unfreeze the screen
+ mFreezeLock.clear();
}
- // FIXME: signal an event if we have more buffers waiting
- // mFlinger->signalEvent();
+ if (lcblk->getQueuedCount()) {
+ // signal an event if we have more buffers waiting
+ mFlinger->signalEvent();
+ }
if (!mPostedDirtyRegion.isEmpty()) {
reloadTexture( mPostedDirtyRegion );
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
index 73d86ea..84aec61 100644
--- a/libs/ui/Android.mk
+++ b/libs/ui/Android.mk
@@ -27,8 +27,7 @@
Region.cpp \
SharedBufferStack.cpp \
Surface.cpp \
- SurfaceComposerClient.cpp \
- SurfaceFlingerSynchro.cpp
+ SurfaceComposerClient.cpp
LOCAL_SHARED_LIBRARIES := \
libcutils \
diff --git a/libs/ui/SharedBufferStack.cpp b/libs/ui/SharedBufferStack.cpp
index b460757..46b6766 100644
--- a/libs/ui/SharedBufferStack.cpp
+++ b/libs/ui/SharedBufferStack.cpp
@@ -394,6 +394,12 @@
return NO_ERROR;
}
+int32_t SharedBufferServer::getQueuedCount() const
+{
+ SharedBufferStack& stack( *mSharedStack );
+ return stack.queued;
+}
+
status_t SharedBufferServer::assertReallocate(int buffer)
{
ReallocateCondition condition(this, buffer);
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp
index 2d83a8c..f51ca7a 100644
--- a/libs/ui/Surface.cpp
+++ b/libs/ui/Surface.cpp
@@ -746,6 +746,8 @@
currentBuffer->setIndex(index);
mNeedFullUpdate = true;
}
+ } else {
+ err = err<0 ? err : NO_MEMORY;
}
}
return err;
diff --git a/libs/ui/SurfaceComposerClient.cpp b/libs/ui/SurfaceComposerClient.cpp
index 3baa281..eda84ef 100644
--- a/libs/ui/SurfaceComposerClient.cpp
+++ b/libs/ui/SurfaceComposerClient.cpp
@@ -42,7 +42,6 @@
#include <private/ui/LayerState.h>
#include <private/ui/SharedBufferStack.h>
-#include <private/ui/SurfaceFlingerSynchro.h>
#define VERBOSE(...) ((void)0)
//#define VERBOSE LOGD
@@ -155,7 +154,6 @@
{
VERBOSE("Creating client %p, conn %p", this, conn.get());
- mSignalServer = 0;
mPrebuiltLayerState = 0;
mTransactionOpen = 0;
mStatus = NO_ERROR;
@@ -168,7 +166,7 @@
}
mControlMemory = mClient->getControlBlock();
- mSignalServer = new SurfaceFlingerSynchro(sm);
+ mSignalServer = sm;
mControl = static_cast<SharedClient *>(mControlMemory->getBase());
}
@@ -225,7 +223,6 @@
Mutex::Autolock _lg(gLock);
Mutex::Autolock _lm(mLock);
- delete mSignalServer;
mSignalServer = 0;
if (mClient != 0) {
diff --git a/libs/ui/SurfaceFlingerSynchro.cpp b/libs/ui/SurfaceFlingerSynchro.cpp
deleted file mode 100644
index c81db71..0000000
--- a/libs/ui/SurfaceFlingerSynchro.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdint.h>
-
-#include <private/ui/SurfaceFlingerSynchro.h>
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-SurfaceFlingerSynchro::SurfaceFlingerSynchro(const sp<ISurfaceComposer>& flinger)
- : mSurfaceComposer(flinger)
-{
-}
-SurfaceFlingerSynchro::~SurfaceFlingerSynchro()
-{
-}
-
-status_t SurfaceFlingerSynchro::signal()
-{
- mSurfaceComposer->signal();
- return NO_ERROR;
-}
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp
index 3204d9a..1e4c136 100644
--- a/opengl/libs/GLES_CM/gl.cpp
+++ b/opengl/libs/GLES_CM/gl.cpp
@@ -31,6 +31,9 @@
using namespace android;
+// set this to 1 for crude GL debugging
+#define CHECK_FOR_GL_ERRORS 0
+
// ----------------------------------------------------------------------------
// extensions for the framework
// ----------------------------------------------------------------------------
@@ -71,7 +74,7 @@
#undef CALL_GL_API
#undef CALL_GL_API_RETURN
-#if USE_FAST_TLS_KEY
+#if USE_FAST_TLS_KEY && !CHECK_FOR_GL_ERRORS
#define API_ENTRY(_api) __attribute__((naked)) _api
@@ -95,12 +98,27 @@
#else
+ #if CHECK_FOR_GL_ERRORS
+
+ #define CHECK_GL_ERRORS(_api) \
+ do { GLint err = glGetError(); \
+ LOGE_IF(err != GL_NO_ERROR, "%s failed (0x%04X)", #_api, err); \
+ } while(false);
+
+ #else
+
+ #define CHECK_GL_ERRORS(_api) do { } while(false);
+
+ #endif
+
+
#define API_ENTRY(_api) _api
#define CALL_GL_API(_api, ...) \
gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
- _c->_api(__VA_ARGS__)
-
+ _c->_api(__VA_ARGS__); \
+ CHECK_GL_ERRORS(_api)
+
#define CALL_GL_API_RETURN(_api, ...) \
gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
return _c->_api(__VA_ARGS__)