diff options
Diffstat (limited to 'services/camera/libcameraservice')
19 files changed, 62 insertions, 51 deletions
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 76428da..1232c32 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -755,7 +755,7 @@ status_t CameraService::connect( Mutex::Autolock lock(mServiceLock); sp<BasicClient> clientTmp; if (!canConnectUnsafe(cameraId, clientPackageName, - cameraClient->asBinder(), + IInterface::asBinder(cameraClient), /*out*/clientTmp)) { return -EBUSY; } else if (client.get() != NULL) { @@ -818,7 +818,7 @@ status_t CameraService::connectLegacy( Mutex::Autolock lock(mServiceLock); sp<BasicClient> clientTmp; if (!canConnectUnsafe(cameraId, clientPackageName, - cameraClient->asBinder(), + IInterface::asBinder(cameraClient), /*out*/clientTmp)) { return -EBUSY; } else if (client.get() != NULL) { @@ -889,7 +889,7 @@ status_t CameraService::connectPro( { sp<BasicClient> client; if (!canConnectUnsafe(cameraId, clientPackageName, - cameraCb->asBinder(), + IInterface::asBinder(cameraCb), /*out*/client)) { return -EBUSY; } @@ -962,7 +962,7 @@ status_t CameraService::connectDevice( { sp<BasicClient> client; if (!canConnectUnsafe(cameraId, clientPackageName, - cameraCb->asBinder(), + IInterface::asBinder(cameraCb), /*out*/client)) { return -EBUSY; } @@ -1024,7 +1024,7 @@ status_t CameraService::addListener( Vector<sp<ICameraServiceListener> >::iterator it, end; for (it = mListenerList.begin(); it != mListenerList.end(); ++it) { - if ((*it)->asBinder() == listener->asBinder()) { + if (IInterface::asBinder(*it) == IInterface::asBinder(listener)) { ALOGW("%s: Tried to add listener %p which was already subscribed", __FUNCTION__, listener.get()); return ALREADY_EXISTS; @@ -1057,7 +1057,7 @@ status_t CameraService::removeListener( Vector<sp<ICameraServiceListener> >::iterator it; for (it = mListenerList.begin(); it != mListenerList.end(); ++it) { - if ((*it)->asBinder() == listener->asBinder()) { + if (IInterface::asBinder(*it) == IInterface::asBinder(listener)) { mListenerList.erase(it); return OK; } @@ -1170,7 +1170,7 @@ void CameraService::removeClientByRemote(const wp<IBinder>& remoteBinder) { // Found our camera, clear and leave. LOG1("removeClient: clear pro %p", clientPro.get()); - clientPro->getRemoteCallback()->asBinder()->unlinkToDeath(this); + IInterface::asBinder(clientPro->getRemoteCallback())->unlinkToDeath(this); } } @@ -1364,7 +1364,8 @@ CameraService::Client::Client(const sp<CameraService>& cameraService, int cameraId, int cameraFacing, int clientPid, uid_t clientUid, int servicePid) : - CameraService::BasicClient(cameraService, cameraClient->asBinder(), + CameraService::BasicClient(cameraService, + IInterface::asBinder(cameraClient), clientPackageName, cameraId, cameraFacing, clientPid, clientUid, @@ -1477,7 +1478,9 @@ status_t CameraService::BasicClient::finishCameraOps() { } // Always stop watching, even if no camera op is active - mAppOpsManager.stopWatchingMode(mOpsCallback); + if (mOpsCallback != NULL) { + mAppOpsManager.stopWatchingMode(mOpsCallback); + } mOpsCallback.clear(); return OK; @@ -1573,7 +1576,7 @@ CameraService::ProClient::ProClient(const sp<CameraService>& cameraService, int clientPid, uid_t clientUid, int servicePid) - : CameraService::BasicClient(cameraService, remoteCallback->asBinder(), + : CameraService::BasicClient(cameraService, IInterface::asBinder(remoteCallback), clientPackageName, cameraId, cameraFacing, clientPid, clientUid, servicePid) { diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index a7328cf..126d8d9 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -273,7 +273,7 @@ public: } virtual sp<IBinder> asBinderWrapper() { - return asBinder(); + return asBinder(this); } protected: diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp index dcab4ad..0ed5586 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -165,7 +165,8 @@ status_t Camera2Client::dump(int fd, const Vector<String16>& args) { String8 result; result.appendFormat("Client2[%d] (%p) Client: %s PID: %d, dump:\n", mCameraId, - getRemoteCallback()->asBinder().get(), + (getRemoteCallback() != NULL ? + (IInterface::asBinder(getRemoteCallback()).get()) : NULL), String8(mClientPackageName).string(), mClientPid); result.append(" State: "); @@ -531,7 +532,7 @@ status_t Camera2Client::setPreviewTarget( sp<IBinder> binder; sp<ANativeWindow> window; if (bufferProducer != 0) { - binder = bufferProducer->asBinder(); + binder = IInterface::asBinder(bufferProducer); // Using controlledByApp flag to ensure that the buffer queue remains in // async mode for the old camera API, where many applications depend // on that behavior. diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp index 1a4d9a6..bbb2fe0 100644 --- a/services/camera/libcameraservice/api1/CameraClient.cpp +++ b/services/camera/libcameraservice/api1/CameraClient.cpp @@ -118,7 +118,8 @@ status_t CameraClient::dump(int fd, const Vector<String16>& args) { size_t len = snprintf(buffer, SIZE, "Client[%d] (%p) PID: %d\n", mCameraId, - getRemoteCallback()->asBinder().get(), + (getRemoteCallback() != NULL ? + IInterface::asBinder(getRemoteCallback()).get() : NULL), mClientPid); len = (len > SIZE - 1) ? SIZE - 1 : len; write(fd, buffer, len); @@ -205,7 +206,7 @@ status_t CameraClient::connect(const sp<ICameraClient>& client) { } if (mRemoteCallback != 0 && - (client->asBinder() == mRemoteCallback->asBinder())) { + (IInterface::asBinder(client) == IInterface::asBinder(mRemoteCallback))) { LOG1("Connect to the same client"); return NO_ERROR; } @@ -328,7 +329,7 @@ status_t CameraClient::setPreviewTarget( sp<IBinder> binder; sp<ANativeWindow> window; if (bufferProducer != 0) { - binder = bufferProducer->asBinder(); + binder = IInterface::asBinder(bufferProducer); // Using controlledByApp flag to ensure that the buffer queue remains in // async mode for the old camera API, where many applications depend // on that behavior. diff --git a/services/camera/libcameraservice/api1/client2/Parameters.h b/services/camera/libcameraservice/api1/client2/Parameters.h index 7e5be84..e628a7e 100644 --- a/services/camera/libcameraservice/api1/client2/Parameters.h +++ b/services/camera/libcameraservice/api1/client2/Parameters.h @@ -19,11 +19,13 @@ #include <system/graphics.h> +#include <utils/Compat.h> #include <utils/Errors.h> +#include <utils/KeyedVector.h> #include <utils/Mutex.h> #include <utils/String8.h> #include <utils/Vector.h> -#include <utils/KeyedVector.h> + #include <camera/CameraParameters.h> #include <camera/CameraParameters2.h> #include <camera/CameraMetadata.h> @@ -187,7 +189,7 @@ struct Parameters { static const int MAX_INITIAL_PREVIEW_WIDTH = 1920; static const int MAX_INITIAL_PREVIEW_HEIGHT = 1080; // Aspect ratio tolerance - static const float ASPECT_RATIO_TOLERANCE = 0.001; + static const CONSTEXPR float ASPECT_RATIO_TOLERANCE = 0.001; // Full static camera info, object owned by someone else, such as // Camera2Device. diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp index 470624b..146d572 100644 --- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp @@ -27,6 +27,7 @@ #include <utils/Log.h> #include <utils/Trace.h> +#include <gui/BufferItem.h> #include <gui/Surface.h> #include <media/hardware/MetadataBufferType.h> @@ -675,7 +676,7 @@ status_t StreamingProcessor::processRecordingFrame() { sp<Camera2Client> client = mClient.promote(); if (client == 0) { // Discard frames during shutdown - BufferItemConsumer::BufferItem imgBuffer; + BufferItem imgBuffer; res = mRecordingConsumer->acquireBuffer(&imgBuffer, 0); if (res != OK) { if (res != BufferItemConsumer::NO_BUFFER_AVAILABLE) { @@ -693,7 +694,7 @@ status_t StreamingProcessor::processRecordingFrame() { with Camera2Client code calling into StreamingProcessor */ SharedParameters::Lock l(client->getParameters()); Mutex::Autolock m(mMutex); - BufferItemConsumer::BufferItem imgBuffer; + BufferItem imgBuffer; res = mRecordingConsumer->acquireBuffer(&imgBuffer, 0); if (res != OK) { if (res != BufferItemConsumer::NO_BUFFER_AVAILABLE) { @@ -819,8 +820,7 @@ void StreamingProcessor::releaseRecordingFrame(const sp<IMemory>& mem) { size_t itemIndex; for (itemIndex = 0; itemIndex < mRecordingBuffers.size(); itemIndex++) { - const BufferItemConsumer::BufferItem item = - mRecordingBuffers[itemIndex]; + const BufferItem item = mRecordingBuffers[itemIndex]; if (item.mBuf != BufferItemConsumer::INVALID_BUFFER_SLOT && item.mGraphicBuffer->handle == imgHandle) { break; @@ -864,8 +864,7 @@ void StreamingProcessor::releaseAllRecordingFramesLocked() { size_t releasedCount = 0; for (size_t itemIndex = 0; itemIndex < mRecordingBuffers.size(); itemIndex++) { - const BufferItemConsumer::BufferItem item = - mRecordingBuffers[itemIndex]; + const BufferItem item = mRecordingBuffers[itemIndex]; if (item.mBuf != BufferItemConsumer::INVALID_BUFFER_SLOT) { res = mRecordingConsumer->releaseBuffer(mRecordingBuffers[itemIndex]); if (res != OK) { diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h index 1d679a4..2474062 100644 --- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h +++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h @@ -124,7 +124,7 @@ class StreamingProcessor: static const size_t kDefaultRecordingHeapCount = 8; size_t mRecordingHeapCount; - Vector<BufferItemConsumer::BufferItem> mRecordingBuffers; + Vector<BufferItem> mRecordingBuffers; size_t mRecordingHeapHead, mRecordingHeapFree; virtual bool threadLoop(); diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp index 8b7e4b4..186ce6c 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp @@ -440,7 +440,7 @@ status_t ZslProcessor::processNewZslBuffer() { zslConsumer = mZslConsumer; } ALOGVV("Trying to get next buffer"); - BufferItemConsumer::BufferItem item; + BufferItem item; res = zslConsumer->acquireBuffer(&item, 0); if (res != OK) { if (res != BufferItemConsumer::NO_BUFFER_AVAILABLE) { diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.h b/services/camera/libcameraservice/api1/client2/ZslProcessor.h index 2099c38..5f50d7b 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor.h +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.h @@ -22,6 +22,7 @@ #include <utils/Vector.h> #include <utils/Mutex.h> #include <utils/Condition.h> +#include <gui/BufferItem.h> #include <gui/BufferItemConsumer.h> #include <camera/CameraMetadata.h> #include <camera/CaptureResult.h> @@ -103,7 +104,7 @@ class ZslProcessor: sp<ANativeWindow> mZslWindow; struct ZslPair { - BufferItemConsumer::BufferItem buffer; + BufferItem buffer; CameraMetadata frame; }; diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h index fc9f70c..2960478 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h @@ -22,6 +22,7 @@ #include <utils/Vector.h> #include <utils/Mutex.h> #include <utils/Condition.h> +#include <gui/BufferItem.h> #include <gui/BufferItemConsumer.h> #include <camera/CameraMetadata.h> @@ -104,7 +105,7 @@ class ZslProcessor3 : sp<camera3::Camera3ZslStream> mZslStream; struct ZslPair { - BufferItemConsumer::BufferItem buffer; + BufferItem buffer; CameraMetadata frame; }; diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp index e6865bb..6a1ee44 100644 --- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp +++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp @@ -42,8 +42,14 @@ CameraDeviceClientBase::CameraDeviceClientBase( int clientPid, uid_t clientUid, int servicePid) : - BasicClient(cameraService, remoteCallback->asBinder(), clientPackageName, - cameraId, cameraFacing, clientPid, clientUid, servicePid), + BasicClient(cameraService, + IInterface::asBinder(remoteCallback), + clientPackageName, + cameraId, + cameraFacing, + clientPid, + clientUid, + servicePid), mRemoteCallback(remoteCallback) { } @@ -157,7 +163,7 @@ status_t CameraDeviceClient::submitRequestList(List<sp<CaptureRequest> > request if (surface == 0) continue; sp<IGraphicBufferProducer> gbp = surface->getIGraphicBufferProducer(); - int idx = mStreamMap.indexOfKey(gbp->asBinder()); + int idx = mStreamMap.indexOfKey(IInterface::asBinder(gbp)); // Trying to submit request with surface that wasn't created if (idx == NAME_NOT_FOUND) { @@ -327,7 +333,7 @@ status_t CameraDeviceClient::createStream(int width, int height, int format, // Don't create multiple streams for the same target surface { - ssize_t index = mStreamMap.indexOfKey(bufferProducer->asBinder()); + ssize_t index = mStreamMap.indexOfKey(IInterface::asBinder(bufferProducer)); if (index != NAME_NOT_FOUND) { ALOGW("%s: Camera %d: Buffer producer already has a stream for it " "(ID %zd)", @@ -361,12 +367,8 @@ status_t CameraDeviceClient::createStream(int width, int height, int format, bool flexibleConsumer = (consumerUsage & disallowedFlags) == 0 && (consumerUsage & allowedFlags) != 0; - sp<IBinder> binder; - sp<ANativeWindow> anw; - if (bufferProducer != 0) { - binder = bufferProducer->asBinder(); - anw = new Surface(bufferProducer, useAsync); - } + sp<IBinder> binder = IInterface::asBinder(bufferProducer); + sp<ANativeWindow> anw = new Surface(bufferProducer, useAsync); // TODO: remove w,h,f since we are ignoring them @@ -407,7 +409,7 @@ status_t CameraDeviceClient::createStream(int width, int height, int format, res = mDevice->createStream(anw, width, height, format, &streamId); if (res == OK) { - mStreamMap.add(bufferProducer->asBinder(), streamId); + mStreamMap.add(binder, streamId); ALOGV("%s: Camera %d: Successfully created a new stream ID %d", __FUNCTION__, mCameraId, streamId); @@ -582,7 +584,8 @@ status_t CameraDeviceClient::dump(int fd, const Vector<String16>& args) { String8 result; result.appendFormat("CameraDeviceClient[%d] (%p) dump:\n", mCameraId, - getRemoteCallback()->asBinder().get()); + (getRemoteCallback() != NULL ? + IInterface::asBinder(getRemoteCallback()).get() : NULL) ); result.appendFormat(" Current client: %s (PID %d, UID %u)\n", String8(mClientPackageName).string(), mClientPid, mClientUid); diff --git a/services/camera/libcameraservice/api_pro/ProCamera2Client.cpp b/services/camera/libcameraservice/api_pro/ProCamera2Client.cpp index 2ea460f..59e5083 100644 --- a/services/camera/libcameraservice/api_pro/ProCamera2Client.cpp +++ b/services/camera/libcameraservice/api_pro/ProCamera2Client.cpp @@ -276,7 +276,7 @@ status_t ProCamera2Client::createStream(int width, int height, int format, sp<IBinder> binder; sp<ANativeWindow> window; if (bufferProducer != 0) { - binder = bufferProducer->asBinder(); + binder = IInterface::asBinder(bufferProducer); window = new Surface(bufferProducer); } @@ -334,7 +334,8 @@ status_t ProCamera2Client::dump(int fd, const Vector<String16>& args) { String8 result; result.appendFormat("ProCamera2Client[%d] (%p) PID: %d, dump:\n", mCameraId, - getRemoteCallback()->asBinder().get(), + (getRemoteCallback() != NULL ? + IInterface::asBinder(getRemoteCallback()).get() : NULL), mClientPid); result.append(" State:\n"); write(fd, result.string(), result.size()); diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.cpp b/services/camera/libcameraservice/common/Camera2ClientBase.cpp index d6db151..453c8bd 100644 --- a/services/camera/libcameraservice/common/Camera2ClientBase.cpp +++ b/services/camera/libcameraservice/common/Camera2ClientBase.cpp @@ -128,7 +128,8 @@ status_t Camera2ClientBase<TClientBase>::dump(int fd, String8 result; result.appendFormat("Camera2ClientBase[%d] (%p) PID: %d, dump:\n", TClientBase::mCameraId, - TClientBase::getRemoteCallback()->asBinder().get(), + (TClientBase::getRemoteCallback() != NULL ? + IInterface::asBinder(TClientBase::getRemoteCallback()).get() : NULL), TClientBase::mClientPid); result.append(" State: "); diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.h b/services/camera/libcameraservice/common/Camera2ClientBase.h index d198e4e..e09c1b5 100644 --- a/services/camera/libcameraservice/common/Camera2ClientBase.h +++ b/services/camera/libcameraservice/common/Camera2ClientBase.h @@ -111,7 +111,7 @@ protected: pid_t mInitialClientPid; virtual sp<IBinder> asBinderWrapper() { - return IInterface::asBinder(); + return IInterface::asBinder(this); } virtual status_t dumpDevice(int fd, const Vector<String16>& args); diff --git a/services/camera/libcameraservice/device1/CameraHardwareInterface.h b/services/camera/libcameraservice/device1/CameraHardwareInterface.h index 6386838..1935c2b 100644 --- a/services/camera/libcameraservice/device1/CameraHardwareInterface.h +++ b/services/camera/libcameraservice/device1/CameraHardwareInterface.h @@ -588,7 +588,7 @@ private: #ifndef container_of #define container_of(ptr, type, member) ({ \ - const typeof(((type *) 0)->member) *__mptr = (ptr); \ + const __typeof__(((type *) 0)->member) *__mptr = (ptr); \ (type *) ((char *) __mptr - (char *)(&((type *)0)->member)); }) #endif diff --git a/services/camera/libcameraservice/device3/Camera3InputStream.cpp b/services/camera/libcameraservice/device3/Camera3InputStream.cpp index 319be1d..9c1e28b 100644 --- a/services/camera/libcameraservice/device3/Camera3InputStream.cpp +++ b/services/camera/libcameraservice/device3/Camera3InputStream.cpp @@ -18,6 +18,7 @@ #define ATRACE_TAG ATRACE_TAG_CAMERA //#define LOG_NDEBUG 0 +#include <gui/BufferItem.h> #include <utils/Log.h> #include <utils/Trace.h> #include "Camera3InputStream.h" diff --git a/services/camera/libcameraservice/device3/Camera3InputStream.h b/services/camera/libcameraservice/device3/Camera3InputStream.h index ae49467..fd17f4f 100644 --- a/services/camera/libcameraservice/device3/Camera3InputStream.h +++ b/services/camera/libcameraservice/device3/Camera3InputStream.h @@ -48,8 +48,6 @@ class Camera3InputStream : public Camera3IOStreamBase { private: - typedef BufferItemConsumer::BufferItem BufferItem; - sp<BufferItemConsumer> mConsumer; Vector<BufferItem> mBuffersInFlight; diff --git a/services/camera/libcameraservice/gui/RingBufferConsumer.cpp b/services/camera/libcameraservice/gui/RingBufferConsumer.cpp index d0f29de..8cd6800 100644 --- a/services/camera/libcameraservice/gui/RingBufferConsumer.cpp +++ b/services/camera/libcameraservice/gui/RingBufferConsumer.cpp @@ -268,7 +268,7 @@ status_t RingBufferConsumer::releaseOldestBufferLocked(size_t* pinnedFrames) { return OK; } -void RingBufferConsumer::onFrameAvailable(const android::BufferItem& item) { +void RingBufferConsumer::onFrameAvailable(const BufferItem& item) { status_t err; { diff --git a/services/camera/libcameraservice/gui/RingBufferConsumer.h b/services/camera/libcameraservice/gui/RingBufferConsumer.h index 90fd734..83e7298 100644 --- a/services/camera/libcameraservice/gui/RingBufferConsumer.h +++ b/services/camera/libcameraservice/gui/RingBufferConsumer.h @@ -17,6 +17,7 @@ #ifndef ANDROID_GUI_RINGBUFFERCONSUMER_H #define ANDROID_GUI_RINGBUFFERCONSUMER_H +#include <gui/BufferItem.h> #include <gui/ConsumerBase.h> #include <ui/GraphicBuffer.h> @@ -54,8 +55,6 @@ class RingBufferConsumer : public ConsumerBase, public: typedef ConsumerBase::FrameAvailableListener FrameAvailableListener; - typedef BufferQueue::BufferItem BufferItem; - enum { INVALID_BUFFER_SLOT = BufferQueue::INVALID_BUFFER_SLOT }; enum { NO_BUFFER_AVAILABLE = BufferQueue::NO_BUFFER_AVAILABLE }; @@ -165,7 +164,7 @@ class RingBufferConsumer : public ConsumerBase, private: // Override ConsumerBase::onFrameAvailable - virtual void onFrameAvailable(const android::BufferItem& item); + virtual void onFrameAvailable(const BufferItem& item); void pinBufferLocked(const BufferItem& item); void unpinBuffer(const BufferItem& item); |