auto import from //depot/cupcake/@137055
diff --git a/camera/libcameraservice/CameraHardwareStub.cpp b/camera/libcameraservice/CameraHardwareStub.cpp
index 9a47705..0f1ae8e 100644
--- a/camera/libcameraservice/CameraHardwareStub.cpp
+++ b/camera/libcameraservice/CameraHardwareStub.cpp
@@ -29,7 +29,8 @@
CameraHardwareStub::CameraHardwareStub()
: mParameters(),
- mHeap(0),
+ mPreviewHeap(0),
+ mRawHeap(0),
mFakeCamera(0),
mPreviewFrameSize(0),
mRawPictureCallback(0),
@@ -62,13 +63,17 @@
void CameraHardwareStub::initHeapLocked()
{
- int width, height;
- mParameters.getPreviewSize(&width, &height);
+ // Create raw heap.
+ int picture_width, picture_height;
+ mParameters.getPictureSize(&picture_width, &picture_height);
+ mRawHeap = new MemoryHeapBase(picture_width * 2 * picture_height);
- LOGD("initHeapLocked: preview size=%dx%d", width, height);
+ int preview_width, preview_height;
+ mParameters.getPreviewSize(&preview_width, &preview_height);
+ LOGD("initHeapLocked: preview size=%dx%d", preview_width, preview_height);
// Note that we enforce yuv422 in setParameters().
- int how_big = width * height * 2;
+ int how_big = preview_width * preview_height * 2;
// If we are being reinitialized to the same size as before, no
// work needs to be done.
@@ -79,15 +84,15 @@
// Make a new mmap'ed heap that can be shared across processes.
// use code below to test with pmem
- mHeap = new MemoryHeapBase(mPreviewFrameSize * kBufferCount);
+ mPreviewHeap = new MemoryHeapBase(mPreviewFrameSize * kBufferCount);
// Make an IMemory for each frame so that we can reuse them in callbacks.
for (int i = 0; i < kBufferCount; i++) {
- mBuffers[i] = new MemoryBase(mHeap, i * mPreviewFrameSize, mPreviewFrameSize);
+ mBuffers[i] = new MemoryBase(mPreviewHeap, i * mPreviewFrameSize, mPreviewFrameSize);
}
-
+
// Recreate the fake camera to reflect the current size.
delete mFakeCamera;
- mFakeCamera = new FakeCamera(width, height);
+ mFakeCamera = new FakeCamera(preview_width, preview_height);
}
CameraHardwareStub::~CameraHardwareStub()
@@ -99,7 +104,12 @@
sp<IMemoryHeap> CameraHardwareStub::getPreviewHeap() const
{
- return mHeap;
+ return mPreviewHeap;
+}
+
+sp<IMemoryHeap> CameraHardwareStub::getRawHeap() const
+{
+ return mRawHeap;
}
// ---------------------------------------------------------------------------
@@ -114,7 +124,7 @@
// Find the offset within the heap of the current buffer.
ssize_t offset = mCurrentPreviewFrame * mPreviewFrameSize;
- sp<MemoryHeapBase> heap = mHeap;
+ sp<MemoryHeapBase> heap = mPreviewHeap;
// this assumes the internal state of fake camera doesn't change
// (or is thread safe)
@@ -255,10 +265,9 @@
// In the meantime just make another fake camera picture.
int w, h;
mParameters.getPictureSize(&w, &h);
- sp<MemoryHeapBase> heap = new MemoryHeapBase(w * 2 * h);
- sp<MemoryBase> mem = new MemoryBase(heap, 0, w * 2 * h);
+ sp<MemoryBase> mem = new MemoryBase(mRawHeap, 0, w * 2 * h);
FakeCamera cam(w, h);
- cam.getNextFrameAsYuv422((uint8_t *)heap->base());
+ cam.getNextFrameAsYuv422((uint8_t *)mRawHeap->base());
if (mRawPictureCallback)
mRawPictureCallback(mem, mPictureCallbackCookie);
}
diff --git a/camera/libcameraservice/CameraHardwareStub.h b/camera/libcameraservice/CameraHardwareStub.h
index cdd6011..0d26d47 100644
--- a/camera/libcameraservice/CameraHardwareStub.h
+++ b/camera/libcameraservice/CameraHardwareStub.h
@@ -30,6 +30,7 @@
class CameraHardwareStub : public CameraHardwareInterface {
public:
virtual sp<IMemoryHeap> getPreviewHeap() const;
+ virtual sp<IMemoryHeap> getRawHeap() const;
virtual status_t startPreview(preview_callback cb, void* user);
virtual void stopPreview();
@@ -93,7 +94,8 @@
CameraParameters mParameters;
- sp<MemoryHeapBase> mHeap;
+ sp<MemoryHeapBase> mPreviewHeap;
+ sp<MemoryHeapBase> mRawHeap;
sp<MemoryBase> mBuffers[kBufferCount];
FakeCamera *mFakeCamera;
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index e5d4220..953e637 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -152,7 +152,7 @@
}
CameraService::Client::Client(const sp<CameraService>& cameraService,
- const sp<ICameraClient>& cameraClient, pid_t clientPid)
+ const sp<ICameraClient>& cameraClient, pid_t clientPid)
{
LOGD("Client E constructor");
mCameraService = cameraService;
@@ -429,7 +429,7 @@
ret = mHardware->startPreview(NULL, mCameraService.get());
if (ret != NO_ERROR)
LOGE("mHardware->startPreview() failed with status %d\n", ret);
-
+
} else {
ret = mHardware->startPreview(previewCallback,
mCameraService.get());
@@ -684,13 +684,33 @@
return INVALID_OPERATION;
}
- if (mSurface != NULL && !mUseOverlay)
- mSurface->unregisterBuffers();
- return mHardware->takePicture(shutterCallback,
+ Mutex::Autolock buffer_lock(mBufferLock);
+ result = mHardware->takePicture(shutterCallback,
yuvPictureCallback,
jpegPictureCallback,
mCameraService.get());
+
+ // It takes quite some time before yuvPicture callback to be called.
+ // Register the buffer for raw image here to reduce latency.
+ // But yuvPictureCallback is called from libcamera. So do not call into a
+ // libcamera function here that gets another lock, which may cause deadlock.
+ if (mSurface != 0 && !mUseOverlay) {
+ int w, h;
+ CameraParameters params(mHardware->getParameters());
+ params.getPictureSize(&w, &h);
+ mSurface->unregisterBuffers();
+ uint32_t transform = 0;
+ if (params.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
+ LOGV("portrait mode");
+ transform = ISurface::BufferHeap::ROT_90;
+ }
+ ISurface::BufferHeap buffers(w, h, w, h,
+ PIXEL_FORMAT_YCbCr_420_SP, transform, 0, mHardware->getRawHeap());
+ mSurface->registerBuffers(buffers);
+ }
+
+ return result;
}
// picture callback - snapshot taken
@@ -732,23 +752,9 @@
#endif
// Put the YUV version of the snapshot in the preview display.
- int w, h;
- CameraParameters params(client->mHardware->getParameters());
- params.getPictureSize(&w, &h);
-
-// Mutex::Autolock clientLock(client->mLock);
+ // Use lock to make sure buffer has been registered.
+ Mutex::Autolock clientLock(client->mBufferLock);
if (client->mSurface != 0 && !client->mUseOverlay) {
- client->mSurface->unregisterBuffers();
-
- uint32_t transform = 0;
- if (params.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
- LOGV("portrait mode");
- transform = ISurface::BufferHeap::ROT_90;
- }
- ISurface::BufferHeap buffers(w, h, w, h,
- PIXEL_FORMAT_YCbCr_420_SP, transform, 0, heap);
-
- client->mSurface->registerBuffers(buffers);
client->mSurface->postBuffer(offset);
}
diff --git a/camera/libcameraservice/CameraService.h b/camera/libcameraservice/CameraService.h
index d9b7927..812b928 100644
--- a/camera/libcameraservice/CameraService.h
+++ b/camera/libcameraservice/CameraService.h
@@ -172,6 +172,9 @@
// for a callback from CameraHardwareInterface. If this
// happens, it will cause a deadlock.
mutable Mutex mSurfaceLock;
+ // mBufferLock synchronizes buffer registration between takePicture()
+ // and yuvPictureCallback().
+ mutable Mutex mBufferLock;
mutable Condition mReady;
sp<CameraService> mCameraService;
sp<ISurface> mSurface;
diff --git a/include/ui/CameraHardwareInterface.h b/include/ui/CameraHardwareInterface.h
index b068c52..73036f0 100644
--- a/include/ui/CameraHardwareInterface.h
+++ b/include/ui/CameraHardwareInterface.h
@@ -87,6 +87,9 @@
/** Return the IMemoryHeap for the preview image heap */
virtual sp<IMemoryHeap> getPreviewHeap() const = 0;
+ /** Return the IMemoryHeap for the raw image heap */
+ virtual sp<IMemoryHeap> getRawHeap() const = 0;
+
/**
* Start preview mode. When a preview image is available
* preview_callback is called with the user parameter. The
diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h
index d83a33c..7d3fcf2 100644
--- a/include/utils/ResourceTypes.h
+++ b/include/utils/ResourceTypes.h
@@ -1101,16 +1101,22 @@
return false;
}
- // Return true if 'this' can be considered a match for the parameters in
+ // Return true if 'this' can be considered a match for the parameters in
// 'settings'.
+ // Note this is asymetric. A default piece of data will match every request
+ // but a request for the default should not match odd specifics
+ // (ie, request with no mcc should not match a particular mcc's data)
+ // settings is the requested settings
inline bool match(const ResTable_config& settings) const {
if (imsi != 0) {
- if (settings.mcc != 0 && mcc != 0
- && mcc != settings.mcc) {
+ if ((settings.mcc != 0 && mcc != 0
+ && mcc != settings.mcc) ||
+ (settings.mcc == 0 && mcc != 0)) {
return false;
}
- if (settings.mnc != 0 && mnc != 0
- && mnc != settings.mnc) {
+ if ((settings.mnc != 0 && mnc != 0
+ && mnc != settings.mnc) ||
+ (settings.mnc == 0 && mnc != 0)) {
return false;
}
}
diff --git a/libs/audioflinger/A2dpAudioInterface.cpp b/libs/audioflinger/A2dpAudioInterface.cpp
index d1b7af3..eb00f8c 100644
--- a/libs/audioflinger/A2dpAudioInterface.cpp
+++ b/libs/audioflinger/A2dpAudioInterface.cpp
@@ -131,8 +131,7 @@
// ----------------------------------------------------------------------------
A2dpAudioInterface::A2dpAudioStreamOut::A2dpAudioStreamOut() :
- mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL),
- mInitialized(false)
+ mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL)
{
// use any address by default
strncpy(mA2dpAddress, "00:00:00:00:00:00", sizeof(mA2dpAddress));
@@ -167,13 +166,14 @@
status_t status = NO_INIT;
size_t remaining = bytes;
- if (!mInitialized) {
- status = a2dp_init(mA2dpAddress, 44100, 2, &mData);
+ if (!mData) {
+ status = a2dp_init(44100, 2, &mData);
if (status < 0) {
LOGE("a2dp_init failed err: %d\n", status);
+ mData = NULL;
goto Error;
}
- mInitialized = true;
+ a2dp_set_sink(mData, mA2dpAddress);
}
while (remaining > 0) {
@@ -191,7 +191,6 @@
return bytes;
Error:
- close();
// Simulate audio output timing in case of error
usleep(bytes * 1000000 / frameSize() / sampleRate());
@@ -218,7 +217,8 @@
if (strcmp(address, mA2dpAddress)) {
strcpy(mA2dpAddress, address);
- close();
+ if (mData)
+ a2dp_set_sink(mData, mA2dpAddress);
}
return NO_ERROR;
@@ -229,7 +229,6 @@
if (mData) {
a2dp_cleanup(mData);
mData = NULL;
- mInitialized = false;
}
return NO_ERROR;
}
diff --git a/libs/audioflinger/A2dpAudioInterface.h b/libs/audioflinger/A2dpAudioInterface.h
index 5bef5da..a56e8a0 100644
--- a/libs/audioflinger/A2dpAudioInterface.h
+++ b/libs/audioflinger/A2dpAudioInterface.h
@@ -96,7 +96,6 @@
int mRetryCount;
char mA2dpAddress[20];
void* mData;
- bool mInitialized;
};
Mutex mLock;
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 557d93b..92c40e9 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -171,13 +171,6 @@
} else {
LOGE("Couldn't even initialize the stubbed audio hardware!");
}
-
- char value[PROPERTY_VALUE_MAX];
- property_get("ro.audio.silent", value, "0");
- if (atoi(value)) {
- LOGD("Silence is golden");
- setMasterMute(true);
- }
}
AudioFlinger::~AudioFlinger()
@@ -995,6 +988,16 @@
IPCThreadState::self()->flushCommands();
mWaitWorkCV.wait(mLock);
LOGV("Audio hardware exiting standby, output %d\n", mOutputType);
+
+ if (mMasterMute == false) {
+ char value[PROPERTY_VALUE_MAX];
+ property_get("ro.audio.silent", value, "0");
+ if (atoi(value)) {
+ LOGD("Silence is golden");
+ setMasterMute(true);
+ }
+ }
+
standbyTime = systemTime() + kStandbyTimeInNsecs;
continue;
}
diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h
index dfbb1e9..77f064b 100644
--- a/libs/audioflinger/AudioFlinger.h
+++ b/libs/audioflinger/AudioFlinger.h
@@ -223,10 +223,7 @@
enum track_flags {
STEPSERVER_FAILED = 0x01, // StepServer could not acquire cblk->lock mutex
SYSTEM_FLAGS_MASK = 0x0000ffffUL,
-
- AUDIO_IN_AGC_ENABLE = AudioSystem::AGC_ENABLE << 16,
- AUDIO_IN_NS_ENABLE = AudioSystem::NS_ENABLE << 16,
- AUDIO_IN_IIR_ENABLE = AudioSystem::TX_IIR_ENABLE << 16
+ // The upper 16 bits are used for track-specific flags.
};
TrackBase(const sp<MixerThread>& mixerThread,
diff --git a/libs/audioflinger/AudioHardwareGeneric.h b/libs/audioflinger/AudioHardwareGeneric.h
index 1d58389..c949aa1 100644
--- a/libs/audioflinger/AudioHardwareGeneric.h
+++ b/libs/audioflinger/AudioHardwareGeneric.h
@@ -47,7 +47,7 @@
virtual size_t bufferSize() const { return 4096; }
virtual int channelCount() const { return 2; }
virtual int format() const { return AudioSystem::PCM_16_BIT; }
- virtual uint32_t latency() const { return 0; }
+ virtual uint32_t latency() const { return 20; }
virtual status_t setVolume(float volume) { return INVALID_OPERATION; }
virtual ssize_t write(const void* buffer, size_t bytes);
virtual status_t standby();
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index 6c60b85..b3cbda1 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -110,6 +110,8 @@
if (c->mCamera != 0) {
c->mCamera->asBinder()->linkToDeath(c);
c->mStatus = NO_ERROR;
+ } else {
+ c.clear();
}
return c;
}
diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp
index 74271ba..5f407a9 100644
--- a/libs/utils/Threads.cpp
+++ b/libs/utils/Threads.cpp
@@ -896,6 +896,7 @@
{
mLock.lock();
if (mNumReaders == 0) {
+ mLock.unlock();
LOG(LOG_WARN, "thread",
"WARNING: unlockForRead requested, but not locked\n");
return;
@@ -961,6 +962,7 @@
{
mLock.lock();
if (mNumWriters == 0) {
+ mLock.unlock();
LOG(LOG_WARN, "thread",
"WARNING: unlockForWrite requested, but not locked\n");
return;
@@ -972,7 +974,7 @@
//printf(" wrlk held %.3f msec\n",
// (double) mDebugTimer.durationUsecs() / 1000.0);
#endif
- // mWriteWaiter.signal(); // should other writers get first dibs?
+ mWriteWaiter.signal(); // should other writers get first dibs?
//printf("+++ signaling readers (if any)\n");
mReadWaiter.broadcast(); // wake all readers (if any)
mLock.unlock();
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 1446fb2..5b90bf0 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -463,6 +463,8 @@
// ----------------------------------------------------------------------------
+#define VERSION_MAJOR 1
+#define VERSION_MINOR 2
static char const * const gVendorString = "Google Inc.";
static char const * const gVersionString = "1.2 Android Driver";
static char const * const gClientApiString = "OpenGL ES";
@@ -1002,8 +1004,8 @@
}
if (res == EGL_TRUE) {
- if (major != NULL) *major = 1;
- if (minor != NULL) *minor = 2;
+ if (major != NULL) *major = VERSION_MAJOR;
+ if (minor != NULL) *minor = VERSION_MINOR;
}
return res;
}
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index e35773e..687c8bc 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -50,8 +50,8 @@
namespace android {
// ----------------------------------------------------------------------------
-#define VERSION_MINOR 1
-#define VERSION_MAJOR 4
+#define VERSION_MAJOR 1
+#define VERSION_MINOR 4
static char const * const gVendorString = "Android";
static char const * const gVersionString = "1.31 Android META-EGL";
static char const * const gClientApiString = "OpenGL ES";
@@ -648,8 +648,8 @@
}
if (res == EGL_TRUE) {
- if (major != NULL) *major = 1;
- if (minor != NULL) *minor = 2;
+ if (major != NULL) *major = VERSION_MAJOR;
+ if (minor != NULL) *minor = VERSION_MINOR;
return EGL_TRUE;
}
return setError(EGL_NOT_INITIALIZED, EGL_FALSE);