diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 14:04:24 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 14:04:24 -0800 |
commit | 43aa2b1cbf7a03e248e10f4d0fec0463257cd52d (patch) | |
tree | 419be3db269033df1a79ef96e10fe15be35ce27d | |
parent | 0bb03408de8886e8d17013219967d42fb9c8cf8c (diff) | |
download | frameworks_native-43aa2b1cbf7a03e248e10f4d0fec0463257cd52d.zip frameworks_native-43aa2b1cbf7a03e248e10f4d0fec0463257cd52d.tar.gz frameworks_native-43aa2b1cbf7a03e248e10f4d0fec0463257cd52d.tar.bz2 |
auto import from //depot/cupcake/@132589
-rw-r--r-- | camera/libcameraservice/CameraHardwareStub.cpp | 37 | ||||
-rw-r--r-- | camera/libcameraservice/CameraHardwareStub.h | 4 | ||||
-rw-r--r-- | camera/libcameraservice/CameraService.cpp | 48 | ||||
-rw-r--r-- | camera/libcameraservice/CameraService.h | 3 | ||||
-rw-r--r-- | include/ui/CameraHardwareInterface.h | 3 | ||||
-rw-r--r-- | include/utils/ResourceTypes.h | 16 | ||||
-rw-r--r-- | libs/audioflinger/A2dpAudioInterface.cpp | 15 | ||||
-rw-r--r-- | libs/audioflinger/A2dpAudioInterface.h | 1 | ||||
-rw-r--r-- | libs/audioflinger/AudioFlinger.cpp | 17 | ||||
-rw-r--r-- | libs/audioflinger/AudioFlinger.h | 5 | ||||
-rw-r--r-- | libs/audioflinger/AudioHardwareGeneric.h | 2 | ||||
-rw-r--r-- | libs/ui/Camera.cpp | 2 | ||||
-rw-r--r-- | libs/utils/Threads.cpp | 4 | ||||
-rw-r--r-- | opengl/libagl/egl.cpp | 6 | ||||
-rw-r--r-- | opengl/libs/EGL/egl.cpp | 8 |
15 files changed, 69 insertions, 102 deletions
diff --git a/camera/libcameraservice/CameraHardwareStub.cpp b/camera/libcameraservice/CameraHardwareStub.cpp index 0f1ae8e..9a47705 100644 --- a/camera/libcameraservice/CameraHardwareStub.cpp +++ b/camera/libcameraservice/CameraHardwareStub.cpp @@ -29,8 +29,7 @@ namespace android { CameraHardwareStub::CameraHardwareStub() : mParameters(), - mPreviewHeap(0), - mRawHeap(0), + mHeap(0), mFakeCamera(0), mPreviewFrameSize(0), mRawPictureCallback(0), @@ -63,17 +62,13 @@ void CameraHardwareStub::initDefaultParameters() void CameraHardwareStub::initHeapLocked() { - // Create raw heap. - int picture_width, picture_height; - mParameters.getPictureSize(&picture_width, &picture_height); - mRawHeap = new MemoryHeapBase(picture_width * 2 * picture_height); + int width, height; + mParameters.getPreviewSize(&width, &height); - int preview_width, preview_height; - mParameters.getPreviewSize(&preview_width, &preview_height); - LOGD("initHeapLocked: preview size=%dx%d", preview_width, preview_height); + LOGD("initHeapLocked: preview size=%dx%d", width, height); // Note that we enforce yuv422 in setParameters(). - int how_big = preview_width * preview_height * 2; + int how_big = width * height * 2; // If we are being reinitialized to the same size as before, no // work needs to be done. @@ -84,15 +79,15 @@ void CameraHardwareStub::initHeapLocked() // Make a new mmap'ed heap that can be shared across processes. // use code below to test with pmem - mPreviewHeap = new MemoryHeapBase(mPreviewFrameSize * kBufferCount); + mHeap = 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(mPreviewHeap, i * mPreviewFrameSize, mPreviewFrameSize); + mBuffers[i] = new MemoryBase(mHeap, i * mPreviewFrameSize, mPreviewFrameSize); } - + // Recreate the fake camera to reflect the current size. delete mFakeCamera; - mFakeCamera = new FakeCamera(preview_width, preview_height); + mFakeCamera = new FakeCamera(width, height); } CameraHardwareStub::~CameraHardwareStub() @@ -104,12 +99,7 @@ CameraHardwareStub::~CameraHardwareStub() sp<IMemoryHeap> CameraHardwareStub::getPreviewHeap() const { - return mPreviewHeap; -} - -sp<IMemoryHeap> CameraHardwareStub::getRawHeap() const -{ - return mRawHeap; + return mHeap; } // --------------------------------------------------------------------------- @@ -124,7 +114,7 @@ int CameraHardwareStub::previewThread() // Find the offset within the heap of the current buffer. ssize_t offset = mCurrentPreviewFrame * mPreviewFrameSize; - sp<MemoryHeapBase> heap = mPreviewHeap; + sp<MemoryHeapBase> heap = mHeap; // this assumes the internal state of fake camera doesn't change // (or is thread safe) @@ -265,9 +255,10 @@ int CameraHardwareStub::pictureThread() // In the meantime just make another fake camera picture. int w, h; mParameters.getPictureSize(&w, &h); - sp<MemoryBase> mem = new MemoryBase(mRawHeap, 0, w * 2 * h); + sp<MemoryHeapBase> heap = new MemoryHeapBase(w * 2 * h); + sp<MemoryBase> mem = new MemoryBase(heap, 0, w * 2 * h); FakeCamera cam(w, h); - cam.getNextFrameAsYuv422((uint8_t *)mRawHeap->base()); + cam.getNextFrameAsYuv422((uint8_t *)heap->base()); if (mRawPictureCallback) mRawPictureCallback(mem, mPictureCallbackCookie); } diff --git a/camera/libcameraservice/CameraHardwareStub.h b/camera/libcameraservice/CameraHardwareStub.h index 0d26d47..cdd6011 100644 --- a/camera/libcameraservice/CameraHardwareStub.h +++ b/camera/libcameraservice/CameraHardwareStub.h @@ -30,7 +30,6 @@ namespace android { 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(); @@ -94,8 +93,7 @@ private: CameraParameters mParameters; - sp<MemoryHeapBase> mPreviewHeap; - sp<MemoryHeapBase> mRawHeap; + sp<MemoryHeapBase> mHeap; sp<MemoryBase> mBuffers[kBufferCount]; FakeCamera *mFakeCamera; diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp index 953e637..e5d4220 100644 --- a/camera/libcameraservice/CameraService.cpp +++ b/camera/libcameraservice/CameraService.cpp @@ -152,7 +152,7 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient) } 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 @@ status_t CameraService::Client::startPreviewMode() 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,33 +684,13 @@ status_t CameraService::Client::takePicture() return INVALID_OPERATION; } + if (mSurface != NULL && !mUseOverlay) + mSurface->unregisterBuffers(); - Mutex::Autolock buffer_lock(mBufferLock); - result = mHardware->takePicture(shutterCallback, + return 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 @@ -752,9 +732,23 @@ void CameraService::Client::yuvPictureCallback(const sp<IMemory>& mem, #endif // Put the YUV version of the snapshot in the preview display. - // Use lock to make sure buffer has been registered. - Mutex::Autolock clientLock(client->mBufferLock); + int w, h; + CameraParameters params(client->mHardware->getParameters()); + params.getPictureSize(&w, &h); + +// Mutex::Autolock clientLock(client->mLock); 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 812b928..d9b7927 100644 --- a/camera/libcameraservice/CameraService.h +++ b/camera/libcameraservice/CameraService.h @@ -172,9 +172,6 @@ private: // 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 73036f0..b068c52 100644 --- a/include/ui/CameraHardwareInterface.h +++ b/include/ui/CameraHardwareInterface.h @@ -87,9 +87,6 @@ public: /** 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 7d3fcf2..d83a33c 100644 --- a/include/utils/ResourceTypes.h +++ b/include/utils/ResourceTypes.h @@ -1101,22 +1101,16 @@ struct ResTable_config 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) || - (settings.mcc == 0 && mcc != 0)) { + if (settings.mcc != 0 && mcc != 0 + && mcc != settings.mcc) { return false; } - if ((settings.mnc != 0 && mnc != 0 - && mnc != settings.mnc) || - (settings.mnc == 0 && mnc != 0)) { + if (settings.mnc != 0 && mnc != 0 + && mnc != settings.mnc) { return false; } } diff --git a/libs/audioflinger/A2dpAudioInterface.cpp b/libs/audioflinger/A2dpAudioInterface.cpp index eb00f8c..d1b7af3 100644 --- a/libs/audioflinger/A2dpAudioInterface.cpp +++ b/libs/audioflinger/A2dpAudioInterface.cpp @@ -131,7 +131,8 @@ status_t A2dpAudioInterface::dump(int fd, const Vector<String16>& args) // ---------------------------------------------------------------------------- A2dpAudioInterface::A2dpAudioStreamOut::A2dpAudioStreamOut() : - mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL) + mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL), + mInitialized(false) { // use any address by default strncpy(mA2dpAddress, "00:00:00:00:00:00", sizeof(mA2dpAddress)); @@ -166,14 +167,13 @@ ssize_t A2dpAudioInterface::A2dpAudioStreamOut::write(const void* buffer, size_t status_t status = NO_INIT; size_t remaining = bytes; - if (!mData) { - status = a2dp_init(44100, 2, &mData); + if (!mInitialized) { + status = a2dp_init(mA2dpAddress, 44100, 2, &mData); if (status < 0) { LOGE("a2dp_init failed err: %d\n", status); - mData = NULL; goto Error; } - a2dp_set_sink(mData, mA2dpAddress); + mInitialized = true; } while (remaining > 0) { @@ -191,6 +191,7 @@ ssize_t A2dpAudioInterface::A2dpAudioStreamOut::write(const void* buffer, size_t return bytes; Error: + close(); // Simulate audio output timing in case of error usleep(bytes * 1000000 / frameSize() / sampleRate()); @@ -217,8 +218,7 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::setAddress(const char* address) if (strcmp(address, mA2dpAddress)) { strcpy(mA2dpAddress, address); - if (mData) - a2dp_set_sink(mData, mA2dpAddress); + close(); } return NO_ERROR; @@ -229,6 +229,7 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::close() 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 a56e8a0..5bef5da 100644 --- a/libs/audioflinger/A2dpAudioInterface.h +++ b/libs/audioflinger/A2dpAudioInterface.h @@ -96,6 +96,7 @@ private: int mRetryCount; char mA2dpAddress[20]; void* mData; + bool mInitialized; }; Mutex mLock; diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp index 92c40e9..557d93b 100644 --- a/libs/audioflinger/AudioFlinger.cpp +++ b/libs/audioflinger/AudioFlinger.cpp @@ -171,6 +171,13 @@ AudioFlinger::AudioFlinger() } 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() @@ -988,16 +995,6 @@ bool AudioFlinger::MixerThread::threadLoop() 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 77f064b..dfbb1e9 100644 --- a/libs/audioflinger/AudioFlinger.h +++ b/libs/audioflinger/AudioFlinger.h @@ -223,7 +223,10 @@ private: enum track_flags { STEPSERVER_FAILED = 0x01, // StepServer could not acquire cblk->lock mutex SYSTEM_FLAGS_MASK = 0x0000ffffUL, - // The upper 16 bits are used for track-specific flags. + + 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 }; TrackBase(const sp<MixerThread>& mixerThread, diff --git a/libs/audioflinger/AudioHardwareGeneric.h b/libs/audioflinger/AudioHardwareGeneric.h index c949aa1..1d58389 100644 --- a/libs/audioflinger/AudioHardwareGeneric.h +++ b/libs/audioflinger/AudioHardwareGeneric.h @@ -47,7 +47,7 @@ public: 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 20; } + virtual uint32_t latency() const { return 0; } 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 b3cbda1..6c60b85 100644 --- a/libs/ui/Camera.cpp +++ b/libs/ui/Camera.cpp @@ -110,8 +110,6 @@ sp<Camera> Camera::connect() 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 5f407a9..74271ba 100644 --- a/libs/utils/Threads.cpp +++ b/libs/utils/Threads.cpp @@ -896,7 +896,6 @@ void ReadWriteLock::unlockForRead() { mLock.lock(); if (mNumReaders == 0) { - mLock.unlock(); LOG(LOG_WARN, "thread", "WARNING: unlockForRead requested, but not locked\n"); return; @@ -962,7 +961,6 @@ void ReadWriteLock::unlockForWrite() { mLock.lock(); if (mNumWriters == 0) { - mLock.unlock(); LOG(LOG_WARN, "thread", "WARNING: unlockForWrite requested, but not locked\n"); return; @@ -974,7 +972,7 @@ void ReadWriteLock::unlockForWrite() //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 5b90bf0..1446fb2 100644 --- a/opengl/libagl/egl.cpp +++ b/opengl/libagl/egl.cpp @@ -463,8 +463,6 @@ struct config_management_t { // ---------------------------------------------------------------------------- -#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"; @@ -1004,8 +1002,8 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) } if (res == EGL_TRUE) { - if (major != NULL) *major = VERSION_MAJOR; - if (minor != NULL) *minor = VERSION_MINOR; + if (major != NULL) *major = 1; + if (minor != NULL) *minor = 2; } return res; } diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp index 687c8bc..e35773e 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.cpp @@ -50,8 +50,8 @@ namespace android { // ---------------------------------------------------------------------------- -#define VERSION_MAJOR 1 -#define VERSION_MINOR 4 +#define VERSION_MINOR 1 +#define VERSION_MAJOR 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 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) } if (res == EGL_TRUE) { - if (major != NULL) *major = VERSION_MAJOR; - if (minor != NULL) *minor = VERSION_MINOR; + if (major != NULL) *major = 1; + if (minor != NULL) *minor = 2; return EGL_TRUE; } return setError(EGL_NOT_INITIALIZED, EGL_FALSE); |