Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e763137d authored by The Android Open Source Project's avatar The Android Open Source Project
Browse files

Merge branch 'cupcake'

parents 214a02e7 5f78a48b
Loading
Loading
Loading
Loading
+42 −14
Original line number Diff line number Diff line
@@ -166,22 +166,26 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,

status_t CameraService::Client::checkPid()
{
    // zero means the interface is not locked down
    if (mClientPid == 0) return NO_ERROR;
    return (int) mClientPid == IPCThreadState::self()->getCallingPid() ? NO_ERROR : -EBUSY;
    if (mClientPid == IPCThreadState::self()->getCallingPid()) return NO_ERROR;
    LOGW("Attempt to use locked camera from different process");
    return -EBUSY;
}

status_t CameraService::Client::lock()
{
    // lock camera to this client
    status_t result = checkPid();
    if (result == NO_ERROR) mClientPid = IPCThreadState::self()->getCallingPid();
    return result;
    // lock camera to this client if the the camera is unlocked
    if (mClientPid == 0) {
        mClientPid = IPCThreadState::self()->getCallingPid();
        return NO_ERROR;
    }
    // returns NO_ERROR if the client already owns the camera, -EBUSY otherwise
    return checkPid();
}

status_t CameraService::Client::unlock()
{
    // allow anyone to use camera
    LOGV("unlock");
    status_t result = checkPid();
    if (result == NO_ERROR) mClientPid = 0;
    return result;
@@ -189,12 +193,29 @@ status_t CameraService::Client::unlock()

status_t CameraService::Client::connect(const sp<ICameraClient>& client)
{
    // remove old client
    LOGV("connect new client to existing camera");
    // connect a new process to the camera
    LOGV("connect");

    // hold a reference to the old client or we will deadlock if the client is
    // in the same process and we hold the lock when we remove the reference
    sp<ICameraClient> oldClient;
    {
        Mutex::Autolock _l(mLock);
        if (mClientPid != 0) {
            LOGW("Tried to connect to locked camera");
            return -EBUSY;
        }
        oldClient = mCameraClient;

        // did the client actually change?
        if (client->asBinder() == mCameraClient->asBinder()) return NO_ERROR;

        LOGV("connect new process to existing camera client");
        mCameraClient = client;
        mClientPid = IPCThreadState::self()->getCallingPid();
        mFrameCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
    }

    return NO_ERROR;
}

@@ -210,7 +231,7 @@ static void *unregister_surface(void *arg)

CameraService::Client::~Client()
{
    // spin down hardware
    // tear down client
    LOGD("Client E destructor");
    if (mSurface != 0) {
#if HAVE_ANDROID_OS
@@ -227,6 +248,8 @@ CameraService::Client::~Client()
#endif
    }

    // make sure we tear down the hardware
    mClientPid = IPCThreadState::self()->getCallingPid();
    disconnect();
    LOGD("Client X destructor");
}
@@ -235,7 +258,12 @@ void CameraService::Client::disconnect()
{
    LOGD("Client E disconnect");
    Mutex::Autolock lock(mLock);
    if (mClientPid == 0) {
        LOGV("camera is unlocked, don't tear down hardware");
        return;
    }
    if (checkPid() != NO_ERROR) return;

    mCameraService->removeClient(mCameraClient);
    if (mHardware != 0) {
        // Before destroying mHardware, we must make sure it's in the
+3 −3
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ class IMemoryHeap;
class OverlayRef : public LightRefBase<OverlayRef>
{
public:
    OverlayRef(overlay_handle_t const*, const sp<IOverlay>&,
    OverlayRef(overlay_handle_t, const sp<IOverlay>&,
            uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs);

    static sp<OverlayRef> readFromParcel(const Parcel& data);
@@ -53,7 +53,7 @@ private:
    OverlayRef();
    virtual ~OverlayRef();

    overlay_handle_t const *mOverlayHandle;
    overlay_handle_t mOverlayHandle;
    sp<IOverlay> mOverlayChannel;
    uint32_t mWidth;
    uint32_t mHeight;
@@ -74,7 +74,7 @@ public:
    void destroy();
    
    /* get the HAL handle for this overlay */
    overlay_handle_t const* getHandleRef() const;
    overlay_handle_t getHandleRef() const;

    /* blocks until an overlay buffer is available and return that buffer. */
    status_t dequeueBuffer(overlay_buffer_t* buffer);
+13 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef ANDROID_PARCEL_H
#define ANDROID_PARCEL_H

#include <cutils/native_handle.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
#include <utils/String16.h>
@@ -79,6 +80,9 @@ public:
    status_t            writeStrongBinder(const sp<IBinder>& val);
    status_t            writeWeakBinder(const wp<IBinder>& val);

    // doesn't take ownership of the native_handle
    status_t            writeNativeHandle(const native_handle& handle);
    
    // Place a file descriptor into the parcel.  The given fd must remain
    // valid for the lifetime of the parcel.
    status_t            writeFileDescriptor(int fd);
@@ -109,6 +113,15 @@ public:
    sp<IBinder>         readStrongBinder() const;
    wp<IBinder>         readWeakBinder() const;

    
    // if alloc is NULL, native_handle is allocated with malloc(), otherwise
    // alloc is used. If the function fails, the effects of alloc() must be
    // reverted by the caller.
    native_handle*     readNativeHandle(
            native_handle* (*alloc)(void* cookie, int numFds, int ints),
            void* cookie) const;

    
    // Retrieve a file descriptor from the parcel.  This returns the raw fd
    // in the parcel, which you do not own -- use dup() to get your own copy.
    int                 readFileDescriptor() const;
+1 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ status_t A2dpAudioInterface::dump(int fd, const Vector<String16>& args)
// ----------------------------------------------------------------------------

A2dpAudioInterface::A2dpAudioStreamOut::A2dpAudioStreamOut() :
    mFd(-1), mStandby(false), mStartCount(0), mRetryCount(0), mData(NULL),
    mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL),
    mInitialized(false)
{
    // use any address by default
+1 −1
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ private:
        bool mVisibilityChanged;

        overlay_t* mOverlay;        
        overlay_handle_t const *mOverlayHandle;
        overlay_handle_t mOverlayHandle;
        overlay_control_device_t* mOverlayDevice;
        uint32_t mWidth;
        uint32_t mHeight;
Loading