Loading camera/camera2/ICameraDeviceUser.cpp +25 −2 Original line number Diff line number Diff line Loading @@ -49,7 +49,8 @@ enum { WAIT_UNTIL_IDLE, FLUSH, PREPARE, TEAR_DOWN TEAR_DOWN, PREPARE2 }; namespace { Loading Loading @@ -366,6 +367,21 @@ public: return reply.readInt32(); } virtual status_t prepare2(int maxCount, int streamId) { ALOGV("prepare2"); Parcel data, reply; data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); data.writeInt32(maxCount); data.writeInt32(streamId); remote()->transact(PREPARE2, data, &reply); reply.readExceptionCode(); return reply.readInt32(); } virtual status_t tearDown(int streamId) { ALOGV("tearDown"); Loading Loading @@ -592,7 +608,14 @@ status_t BnCameraDeviceUser::onTransact( reply->writeInt32(tearDown(streamId)); return NO_ERROR; } break; case PREPARE2: { CHECK_INTERFACE(ICameraDeviceUser, data, reply); int maxCount = data.readInt32(); int streamId = data.readInt32(); reply->writeNoException(); reply->writeInt32(prepare2(maxCount, streamId)); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } Loading include/camera/camera2/ICameraDeviceUser.h +5 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,11 @@ public: */ virtual status_t prepare(int streamId) = 0; /** * Preallocate up to maxCount buffers for a given output stream asynchronously. */ virtual status_t prepare2(int maxCount, int streamId) = 0; /** * Free all unused buffers for a given output stream. */ Loading services/camera/libcameraservice/api2/CameraDeviceClient.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -719,6 +719,43 @@ status_t CameraDeviceClient::prepare(int streamId) { return res; } status_t CameraDeviceClient::prepare2(int maxCount, int streamId) { ATRACE_CALL(); ALOGV("%s", __FUNCTION__); status_t res = OK; if ( (res = checkPid(__FUNCTION__) ) != OK) return res; Mutex::Autolock icl(mBinderSerializationLock); // Guard against trying to prepare non-created streams ssize_t index = NAME_NOT_FOUND; for (size_t i = 0; i < mStreamMap.size(); ++i) { if (streamId == mStreamMap.valueAt(i)) { index = i; break; } } if (index == NAME_NOT_FOUND) { ALOGW("%s: Camera %d: Invalid stream ID (%d) specified, no stream created yet", __FUNCTION__, mCameraId, streamId); return BAD_VALUE; } if (maxCount <= 0) { ALOGE("%s: Camera %d: Invalid maxCount (%d) specified, must be greater than 0.", __FUNCTION__, mCameraId, maxCount); return BAD_VALUE; } // Also returns BAD_VALUE if stream ID was not valid, or stream already // has been used res = mDevice->prepare(maxCount, streamId); return res; } status_t CameraDeviceClient::tearDown(int streamId) { ATRACE_CALL(); ALOGV("%s", __FUNCTION__); Loading services/camera/libcameraservice/api2/CameraDeviceClient.h +3 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,9 @@ public: // Tear down stream resources by freeing its unused buffers virtual status_t tearDown(int streamId); // Prepare stream by preallocating up to maxCount of its buffers virtual status_t prepare2(int maxCount, int streamId); /** * Interface used by CameraService */ Loading services/camera/libcameraservice/common/CameraDeviceBase.h +6 −0 Original line number Diff line number Diff line Loading @@ -293,6 +293,12 @@ class CameraDeviceBase : public virtual RefBase { */ virtual status_t tearDown(int streamId) = 0; /** * Prepare stream by preallocating up to maxCount buffers for it asynchronously. * Calls notifyPrepared() once allocation is complete. */ virtual status_t prepare(int maxCount, int streamId) = 0; /** * Get the HAL device version. */ Loading Loading
camera/camera2/ICameraDeviceUser.cpp +25 −2 Original line number Diff line number Diff line Loading @@ -49,7 +49,8 @@ enum { WAIT_UNTIL_IDLE, FLUSH, PREPARE, TEAR_DOWN TEAR_DOWN, PREPARE2 }; namespace { Loading Loading @@ -366,6 +367,21 @@ public: return reply.readInt32(); } virtual status_t prepare2(int maxCount, int streamId) { ALOGV("prepare2"); Parcel data, reply; data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); data.writeInt32(maxCount); data.writeInt32(streamId); remote()->transact(PREPARE2, data, &reply); reply.readExceptionCode(); return reply.readInt32(); } virtual status_t tearDown(int streamId) { ALOGV("tearDown"); Loading Loading @@ -592,7 +608,14 @@ status_t BnCameraDeviceUser::onTransact( reply->writeInt32(tearDown(streamId)); return NO_ERROR; } break; case PREPARE2: { CHECK_INTERFACE(ICameraDeviceUser, data, reply); int maxCount = data.readInt32(); int streamId = data.readInt32(); reply->writeNoException(); reply->writeInt32(prepare2(maxCount, streamId)); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } Loading
include/camera/camera2/ICameraDeviceUser.h +5 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,11 @@ public: */ virtual status_t prepare(int streamId) = 0; /** * Preallocate up to maxCount buffers for a given output stream asynchronously. */ virtual status_t prepare2(int maxCount, int streamId) = 0; /** * Free all unused buffers for a given output stream. */ Loading
services/camera/libcameraservice/api2/CameraDeviceClient.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -719,6 +719,43 @@ status_t CameraDeviceClient::prepare(int streamId) { return res; } status_t CameraDeviceClient::prepare2(int maxCount, int streamId) { ATRACE_CALL(); ALOGV("%s", __FUNCTION__); status_t res = OK; if ( (res = checkPid(__FUNCTION__) ) != OK) return res; Mutex::Autolock icl(mBinderSerializationLock); // Guard against trying to prepare non-created streams ssize_t index = NAME_NOT_FOUND; for (size_t i = 0; i < mStreamMap.size(); ++i) { if (streamId == mStreamMap.valueAt(i)) { index = i; break; } } if (index == NAME_NOT_FOUND) { ALOGW("%s: Camera %d: Invalid stream ID (%d) specified, no stream created yet", __FUNCTION__, mCameraId, streamId); return BAD_VALUE; } if (maxCount <= 0) { ALOGE("%s: Camera %d: Invalid maxCount (%d) specified, must be greater than 0.", __FUNCTION__, mCameraId, maxCount); return BAD_VALUE; } // Also returns BAD_VALUE if stream ID was not valid, or stream already // has been used res = mDevice->prepare(maxCount, streamId); return res; } status_t CameraDeviceClient::tearDown(int streamId) { ATRACE_CALL(); ALOGV("%s", __FUNCTION__); Loading
services/camera/libcameraservice/api2/CameraDeviceClient.h +3 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,9 @@ public: // Tear down stream resources by freeing its unused buffers virtual status_t tearDown(int streamId); // Prepare stream by preallocating up to maxCount of its buffers virtual status_t prepare2(int maxCount, int streamId); /** * Interface used by CameraService */ Loading
services/camera/libcameraservice/common/CameraDeviceBase.h +6 −0 Original line number Diff line number Diff line Loading @@ -293,6 +293,12 @@ class CameraDeviceBase : public virtual RefBase { */ virtual status_t tearDown(int streamId) = 0; /** * Prepare stream by preallocating up to maxCount buffers for it asynchronously. * Calls notifyPrepared() once allocation is complete. */ virtual status_t prepare(int maxCount, int streamId) = 0; /** * Get the HAL device version. */ Loading