Merge change I0fae86b8 into eclair
* changes:
Make QuickContact styles public.
diff --git a/include/private/opengles/gl_context.h b/include/private/opengles/gl_context.h
index 67c2dd8..26cde38 100644
--- a/include/private/opengles/gl_context.h
+++ b/include/private/opengles/gl_context.h
@@ -32,6 +32,8 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
+struct android_native_buffer_t;
+
namespace android {
const unsigned int OGLES_NUM_COMPRESSED_TEXTURE_FORMATS = 10;
@@ -602,7 +604,7 @@
copybit_device_t* blitEngine;
int32_t minScale;
int32_t maxScale;
- buffer_handle_t drawSurfaceBuffer;
+ android_native_buffer_t* drawSurfaceBuffer;
};
struct ogles_context_t {
diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h
index 2172536..b9c491b 100644
--- a/include/ui/GraphicBuffer.h
+++ b/include/ui/GraphicBuffer.h
@@ -93,6 +93,8 @@
void setIndex(int index);
int getIndex() const;
+ void setVerticalStride(uint32_t vstride);
+ uint32_t getVerticalStride() const;
protected:
GraphicBuffer(const Parcel& reply);
diff --git a/libs/audioflinger/AudioPolicyManagerGeneric.cpp b/libs/audioflinger/AudioPolicyManagerGeneric.cpp
index 6323859..8cfc204 100644
--- a/libs/audioflinger/AudioPolicyManagerGeneric.cpp
+++ b/libs/audioflinger/AudioPolicyManagerGeneric.cpp
@@ -459,6 +459,61 @@
return NO_ERROR;
}
+status_t AudioPolicyManagerGeneric::dump(int fd)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+
+ snprintf(buffer, SIZE, "\nAudioPolicyManager Dump: %p\n", this);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Hardware Output: %d\n", mHardwareOutput);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Output devices: %08x\n", mAvailableOutputDevices);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Input devices: %08x\n", mAvailableInputDevices);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Phone state: %d\n", mPhoneState);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Ringer mode: %d\n", mRingerMode);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Force use for communications %d\n", mForceUse[AudioSystem::FOR_COMMUNICATION]);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Force use for media %d\n", mForceUse[AudioSystem::FOR_MEDIA]);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Force use for record %d\n", mForceUse[AudioSystem::FOR_RECORD]);
+ result.append(buffer);
+ write(fd, result.string(), result.size());
+
+ snprintf(buffer, SIZE, "\nOutputs dump:\n");
+ write(fd, buffer, strlen(buffer));
+ for (size_t i = 0; i < mOutputs.size(); i++) {
+ snprintf(buffer, SIZE, "- Output %d dump:\n", mOutputs.keyAt(i));
+ write(fd, buffer, strlen(buffer));
+ mOutputs.valueAt(i)->dump(fd);
+ }
+
+ snprintf(buffer, SIZE, "\nInputs dump:\n");
+ write(fd, buffer, strlen(buffer));
+ for (size_t i = 0; i < mInputs.size(); i++) {
+ snprintf(buffer, SIZE, "- Input %d dump:\n", mInputs.keyAt(i));
+ write(fd, buffer, strlen(buffer));
+ mInputs.valueAt(i)->dump(fd);
+ }
+
+ snprintf(buffer, SIZE, "\nStreams dump:\n");
+ write(fd, buffer, strlen(buffer));
+ snprintf(buffer, SIZE, " Stream Index Min Index Max Index Cur Mute Count Can be muted\n");
+ write(fd, buffer, strlen(buffer));
+ for (size_t i = 0; i < AudioSystem::NUM_STREAM_TYPES; i++) {
+ snprintf(buffer, SIZE, " %02d", i);
+ mStreams[i].dump(buffer + 3, SIZE);
+ write(fd, buffer, strlen(buffer));
+ }
+
+ return NO_ERROR;
+}
+
// ----------------------------------------------------------------------------
// AudioPolicyManagerGeneric
// ----------------------------------------------------------------------------
@@ -815,6 +870,35 @@
return refcount;
}
+status_t AudioPolicyManagerGeneric::AudioOutputDescriptor::dump(int fd)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+
+ snprintf(buffer, SIZE, " Sampling rate: %d\n", mSamplingRate);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Format: %d\n", mFormat);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Channels: %08x\n", mChannels);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Latency: %d\n", mLatency);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Flags %08x\n", mFlags);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Devices %08x\n", mDevice);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Stream refCount\n");
+ result.append(buffer);
+ for (int i = 0; i < AudioSystem::NUM_STREAM_TYPES; i++) {
+ snprintf(buffer, SIZE, " %02d %d\n", i, mRefCount[i]);
+ result.append(buffer);
+ }
+ write(fd, result.string(), result.size());
+
+ return NO_ERROR;
+}
+
// --- AudioInputDescriptor class implementation
AudioPolicyManagerGeneric::AudioInputDescriptor::AudioInputDescriptor()
@@ -823,4 +907,39 @@
{
}
+status_t AudioPolicyManagerGeneric::AudioInputDescriptor::dump(int fd)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+
+ snprintf(buffer, SIZE, " Sampling rate: %d\n", mSamplingRate);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Format: %d\n", mFormat);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Channels: %08x\n", mChannels);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Acoustics %08x\n", mAcoustics);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Devices %08x\n", mDevice);
+ result.append(buffer);
+ snprintf(buffer, SIZE, " Ref Count %d\n", mRefCount);
+ result.append(buffer);
+ write(fd, result.string(), result.size());
+
+ return NO_ERROR;
+}
+
+// --- StreamDescriptor class implementation
+
+void AudioPolicyManagerGeneric::StreamDescriptor::dump(char* buffer, size_t size)
+{
+ snprintf(buffer, size, " %02d %02d %02d %02d %d\n",
+ mIndexMin,
+ mIndexMax,
+ mIndexCur,
+ mMuteCount,
+ mCanBeMuted);
+}
+
}; // namespace android
diff --git a/libs/audioflinger/AudioPolicyManagerGeneric.h b/libs/audioflinger/AudioPolicyManagerGeneric.h
index d904520..4997cdf 100644
--- a/libs/audioflinger/AudioPolicyManagerGeneric.h
+++ b/libs/audioflinger/AudioPolicyManagerGeneric.h
@@ -76,6 +76,8 @@
virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index);
virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index);
+ virtual status_t dump(int fd);
+
private:
enum routing_strategy {
@@ -93,6 +95,7 @@
public:
AudioOutputDescriptor();
+ status_t dump(int fd);
uint32_t device();
void changeRefCount(AudioSystem::stream_type, int delta);
@@ -115,6 +118,8 @@
public:
AudioInputDescriptor();
+ status_t dump(int fd);
+
uint32_t mSamplingRate; //
uint32_t mFormat; // input configuration
uint32_t mChannels; //
@@ -130,6 +135,8 @@
StreamDescriptor()
: mIndexMin(0), mIndexMax(1), mIndexCur(1), mMuteCount(0), mCanBeMuted(true) {}
+ void dump(char* buffer, size_t size);
+
int mIndexMin; // min volume index
int mIndexMax; // max volume index
int mIndexCur; // current volume index
diff --git a/libs/audioflinger/AudioPolicyService.cpp b/libs/audioflinger/AudioPolicyService.cpp
index f71c99c..9723697 100644
--- a/libs/audioflinger/AudioPolicyService.cpp
+++ b/libs/audioflinger/AudioPolicyService.cpp
@@ -43,6 +43,12 @@
namespace android {
+static const char* kDeadlockedString = "AudioPolicyService may be deadlocked\n";
+static const char* kCmdDeadlockedString = "AudioPolicyService command thread may be deadlocked\n";
+
+static const int kDumpLockRetries = 50;
+static const int kDumpLockSleep = 20000;
+
static bool checkPermission() {
#ifndef HAVE_ANDROID_OS
return true;
@@ -335,17 +341,65 @@
LOGW("binderDied() %p, tid %d, calling tid %d", who.unsafe_get(), gettid(), IPCThreadState::self()->getCallingPid());
}
+static bool tryLock(Mutex& mutex)
+{
+ bool locked = false;
+ for (int i = 0; i < kDumpLockRetries; ++i) {
+ if (mutex.tryLock() == NO_ERROR) {
+ locked = true;
+ break;
+ }
+ usleep(kDumpLockSleep);
+ }
+ return locked;
+}
+
+status_t AudioPolicyService::dumpInternals(int fd)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+
+ snprintf(buffer, SIZE, "PolicyManager Interface: %p\n", mpPolicyManager);
+ result.append(buffer);
+ snprintf(buffer, SIZE, "Command Thread: %p\n", mAudioCommandThread.get());
+ result.append(buffer);
+ snprintf(buffer, SIZE, "Tones Thread: %p\n", mTonePlaybackThread.get());
+ result.append(buffer);
+
+ write(fd, result.string(), result.size());
+ return NO_ERROR;
+}
+
status_t AudioPolicyService::dump(int fd, const Vector<String16>& args)
{
if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
- dumpPermissionDenial(fd, args);
+ dumpPermissionDenial(fd);
} else {
+ bool locked = tryLock(mLock);
+ if (!locked) {
+ String8 result(kDeadlockedString);
+ write(fd, result.string(), result.size());
+ }
+ dumpInternals(fd);
+ if (mAudioCommandThread != NULL) {
+ mAudioCommandThread->dump(fd);
+ }
+ if (mTonePlaybackThread != NULL) {
+ mTonePlaybackThread->dump(fd);
+ }
+
+ if (mpPolicyManager) {
+ mpPolicyManager->dump(fd);
+ }
+
+ if (locked) mLock.unlock();
}
return NO_ERROR;
}
-status_t AudioPolicyService::dumpPermissionDenial(int fd, const Vector<String16>& args)
+status_t AudioPolicyService::dumpPermissionDenial(int fd)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -609,6 +663,36 @@
return false;
}
+status_t AudioPolicyService::AudioCommandThread::dump(int fd)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+
+ snprintf(buffer, SIZE, "AudioCommandThread %p Dump\n", this);
+ result.append(buffer);
+ write(fd, result.string(), result.size());
+
+ bool locked = tryLock(mLock);
+ if (!locked) {
+ String8 result2(kCmdDeadlockedString);
+ write(fd, result2.string(), result2.size());
+ }
+
+ snprintf(buffer, SIZE, "- Commands:\n");
+ result = String8(buffer);
+ result.append(" Command Time Status Wait pParam\n");
+ for (int i = 0; i < (int)mAudioCommands.size(); i++) {
+ mAudioCommands[i]->dump(buffer, SIZE);
+ result.append(buffer);
+ }
+ write(fd, result.string(), result.size());
+
+ if (locked) mLock.unlock();
+
+ return NO_ERROR;
+}
+
void AudioPolicyService::AudioCommandThread::startToneCommand(int type, int stream)
{
AudioCommand *command = new AudioCommand();
@@ -808,4 +892,15 @@
requestExitAndWait();
}
+void AudioPolicyService::AudioCommandThread::AudioCommand::dump(char* buffer, size_t size)
+{
+ snprintf(buffer, size, " %02d %06d.%03d %03d %01u %p\n",
+ mCommand,
+ (int)ns2s(mTime),
+ (int)ns2ms(mTime)%1000,
+ mStatus,
+ mWaitStatus,
+ mParam);
+}
+
}; // namespace android
diff --git a/libs/audioflinger/AudioPolicyService.h b/libs/audioflinger/AudioPolicyService.h
index 11a1214..7c1bb85 100644
--- a/libs/audioflinger/AudioPolicyService.h
+++ b/libs/audioflinger/AudioPolicyService.h
@@ -111,6 +111,8 @@
AudioPolicyService();
virtual ~AudioPolicyService();
+ status_t dumpInternals(int fd);
+
// Thread used for tone playback and to send audio config commands to audio flinger
// For tone playback, using a separate thread is necessary to avoid deadlock with mLock because startTone()
// and stopTone() are normally called with mLock locked and requesting a tone start or stop will cause
@@ -133,6 +135,8 @@
AudioCommandThread ();
virtual ~AudioCommandThread();
+ status_t dump(int fd);
+
// Thread virtuals
virtual void onFirstRef();
virtual bool threadLoop();
@@ -149,6 +153,8 @@
// descriptor for requested tone playback event
class AudioCommand {
public:
+ void dump(char* buffer, size_t size);
+
int mCommand; // START_TONE, STOP_TONE ...
nsecs_t mTime; // time stamp
Condition mCond; // condition for status return
@@ -188,7 +194,7 @@
};
// Internal dump utilities.
- status_t dumpPermissionDenial(int fd, const Vector<String16>& args);
+ status_t dumpPermissionDenial(int fd);
Mutex mLock; // prevents concurrent access to AudioPolicy manager functions changing device
diff --git a/libs/binder/MemoryHeapPmem.cpp b/libs/binder/MemoryHeapPmem.cpp
index 3806a42..c660947 100644
--- a/libs/binder/MemoryHeapPmem.cpp
+++ b/libs/binder/MemoryHeapPmem.cpp
@@ -132,7 +132,7 @@
char const * const device = pmemHeap->getDevice();
#if HAVE_ANDROID_OS
if (device) {
- int fd = open(device, O_RDWR);
+ int fd = open(device, O_RDWR | (flags & NO_CACHING ? O_SYNC : 0));
LOGE_IF(fd<0, "couldn't open %s (%s)", device, strerror(errno));
if (fd >= 0) {
int err = ioctl(fd, PMEM_CONNECT, pmemHeap->heapID());
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index 82a8e51..a36304c 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -444,6 +444,8 @@
GraphicBuffer::USAGE_HW_TEXTURE,
src.img.w, src.img.handle, false);
+ graphicBuffer->setVerticalStride(src.img.h);
+
err = mLayer.initializeEglImage(graphicBuffer, &mTexture);
}
#endif
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index efe2d78..6a5c8a9 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -226,6 +226,14 @@
return mIndex;
}
+void GraphicBuffer::setVerticalStride(uint32_t vstride) {
+ mVStride = vstride;
+}
+
+uint32_t GraphicBuffer::getVerticalStride() const {
+ return mVStride;
+}
+
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/opengl/libagl/copybit.cpp b/opengl/libagl/copybit.cpp
index 3de5b2b..1bef859 100644
--- a/opengl/libagl/copybit.cpp
+++ b/opengl/libagl/copybit.cpp
@@ -46,13 +46,24 @@
static void textureToCopyBitImage(
const GGLSurface* surface, int32_t opFormat,
- buffer_handle_t buffer, copybit_image_t* img)
+ android_native_buffer_t* buffer, copybit_image_t* img)
{
+ uint32_t vstride = 0;
+ if (opFormat == COPYBIT_FORMAT_YCbCr_422_SP ||
+ opFormat == COPYBIT_FORMAT_YCbCr_420_SP) {
+ // NOTE: this static_cast is really not safe b/c we can't know for
+ // sure the buffer passed is of the right type.
+ // However, since we do this only for YUV formats, we should be safe
+ // since only SurfaceFlinger makes use of them.
+ GraphicBuffer* graphicBuffer = static_cast<GraphicBuffer*>(buffer);
+ vstride = graphicBuffer->getVerticalStride();
+ }
+
img->w = surface->stride;
- img->h = surface->height;
+ img->h = vstride ? vstride : surface->height;
img->format = opFormat;
img->base = surface->data;
- img->handle = (native_handle_t *)buffer;
+ img->handle = (native_handle_t *)buffer->handle;
}
struct clipRectRegion : public copybit_region_t {
@@ -279,8 +290,8 @@
copybit_device_t* copybit = c->copybits.blitEngine;
copybit_image_t src;
- buffer_handle_t source_hnd = textureObject->buffer->handle;
- textureToCopyBitImage(&textureObject->surface, opFormat, source_hnd, &src);
+ textureToCopyBitImage(&textureObject->surface, opFormat,
+ textureObject->buffer, &src);
copybit_rect_t srect = { Ucr, Vcr + Hcr, Ucr + Wcr, Vcr };
/*
@@ -360,8 +371,8 @@
}
copybit_image_t dst;
- buffer_handle_t target_hnd = c->copybits.drawSurfaceBuffer;
- textureToCopyBitImage(&cbSurface, cbSurface.format, target_hnd, &dst);
+ textureToCopyBitImage(&cbSurface, cbSurface.format,
+ c->copybits.drawSurfaceBuffer, &dst);
copybit_rect_t drect = {x, y, x+w, y+h};
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index d04900e..80ddc02 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -651,7 +651,7 @@
if (supportedCopybitsDestinationFormat(buffer.format)) {
buffer_handle_t handle = this->buffer->handle;
if (handle != NULL) {
- gl->copybits.drawSurfaceBuffer = handle;
+ gl->copybits.drawSurfaceBuffer = this->buffer;
}
}
}