注:文章都是通过阅读各位前辈总结的资料 Android 10.0 && Linux(Kernel 4.19)Rockchip平台源码、加上自己的思考分析总结出来的,其中难免有理解不对的地方,欢迎大家批评指正。文章为个人学习、研究、欣赏之用,图文内容整理自互联网,如有侵权,请联系删除(◕‿◕),转载请注明出处(©Rockchip ©Android @Linux 版权所有),谢谢。
(==文章基于 Kernel-4.19 ==)&&(==文章基于 Android 10.0 ==)
【zhoujinjian.com博客原图链接】
【开发板 Khadas Edge V】
【开发板 Khadas Edge V Android 10.0 && Linux(Kernel 4.19)源码链接】
正是由于前人的分析和总结,帮助我节约了大量的时间和精力,特别感谢!!!
Android camera预览流程
==源码(部分)==:
F:\Khadas_Edge_Android_Q\frameworks\av\services\camera\libcameraservice\
F:\Khadas_Edge_Android_Q\frameworks\base\core\java\android\hardware\camera2\
==源码(部分)==:
(1)、Stack::createCaptureSessionInternal() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : configureStreamsChecked07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : java.lang.RuntimeException: here07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSessionInternal(CameraDeviceImpl.java:667 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:514 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at com.android.camera.one.v2.camera2proxy.AndroidCameraDeviceProxy.createCaptureSession(AndroidCameraDeviceProxy.java:84 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at com.android.camera.one.v2.initialization.CaptureSessionCreator.createCaptureSession(CaptureSessionCreator.java:58 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at com.android.camera.one.v2.initialization.PreviewStarter.startPreview(PreviewStarter.java:83 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at com.android.camera.one.v2.initialization.GenericOneCameraImpl.startPreview(GenericOneCameraImpl.java:151 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at com.android.camera.CaptureModule$19. onCameraOpened(CaptureModule.java:1564 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at com.android.camera.one.v2.Camera2OneCameraOpenerImpl$1. onOpened(Camera2OneCameraOpenerImpl.java:180 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at android.hardware.camera2.impl.CameraDeviceImpl$1. run(CameraDeviceImpl.java:146 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at android.os.Handler.handleCallback(Handler.java:883 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at android.os.Handler.dispatchMessage(Handler.java:100 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at android.os.Looper.loop(Looper.java:214 )07 -07 11 :03 :48.619 1727 1771 I CameraDevice-JV-0 : at android.os.HandlerThread.run(HandlerThread.java:67 )
(2)、CameraDeviceImpl.createCaptureSessionInternal() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 F:\Khadas_Edge_Android_Q\frameworks\base\core\java\android\hardware\camera2\impl\CameraDeviceImpl.java configureStreamsChecked(InputConfiguration inputConfig, List<OutputConfiguration> outputs, int operatingMode, CaptureRequest sessionParams) throws CameraAccessException { ...... checkInputConfiguration(inputConfig); boolean success = false ; synchronized (mInterfaceLock) { checkIfCameraClosedOrInError(); HashSet<OutputConfiguration> addSet = new HashSet<OutputConfiguration>(outputs); ...... try { waitUntilIdle(); mRemoteDevice.beginConfigure(); ...... Slog.i(TAG, "createStream" , new RuntimeException("here" ).fillInStackTrace()); for (OutputConfiguration outConfig : outputs) { if (addSet.contains(outConfig)) { int streamId = mRemoteDevice.createStream(outConfig); mConfiguredOutputs.put(streamId, outConfig); } } if (sessionParams != null ) { mRemoteDevice.endConfigure(operatingMode, sessionParams.getNativeCopy()); } else { mRemoteDevice.endConfigure(operatingMode, null ); } success = true ; } ...... } return success; }
07-07 11:03:48.621 334 544 V Camera3-Device: Camera 0: Creating new stream 0: 4096 x 3120, format 33, dataspace 146931712 rotation 0 consumer usage 0, isShared 0, physicalCameraId
我们主要分析 mRemoteDevice.createStream(outConfig) 的操作,在这里,将会通过Binder将相应的配置信息传输到 CameraService 端的CameraDeviceClient。
(3)、CameraDeviceClient::createStream() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 F:\Khadas_Edge_Android_Q\frameworks\av\services\camera\libcameraservice\api2\CameraDeviceClient.cpp public void openCamera (@NonNull String cameraId, @NonNull final CameraDevice.StateCallback callback, @Nullable Handler handler) throws CameraAccessException { openCameraForUid(cameraId, callback, CameraDeviceImpl.checkAndWrapHandler(handler), USE_CALLING_UID); } openCameraForUid->openCameraDeviceUserAsync binder::Status CameraDeviceClient::createStream( const hardware::camera2::params::OutputConfiguration &outputConfiguration, int32_t* newStreamId) { ATRACE_CALL(); binder::Status res; Mutex::Autolock icl (mBinderSerializationLock) ; const std::vector<sp<IGraphicBufferProducer>>& bufferProducers = outputConfiguration.getGraphicBufferProducers(); size_t numBufferProducers = bufferProducers.size(); bool deferredConsumer = outputConfiguration.isDeferred(); bool isShared = outputConfiguration.isShared(); String8 physicalCameraId = String8(outputConfiguration.getPhysicalCameraId()); bool deferredConsumerOnly = deferredConsumer && numBufferProducers == 0 ; res = checkSurfaceTypeLocked(numBufferProducers, deferredConsumer, outputConfiguration.getSurfaceType()); res = checkPhysicalCameraIdLocked(physicalCameraId); std::vector<sp<Surface>> surfaces; std::vector<sp<IBinder>> binders; status_t err; if (deferredConsumerOnly) { return createDeferredSurfaceStreamLocked(outputConfiguration, isShared, newStreamId); } OutputStreamInfo streamInfo; bool isStreamInfoValid = false ; for (auto& bufferProducer : bufferProducers) { sp<IBinder> binder = IInterface::asBinder(bufferProducer); ssize_t index = mStreamMap.indexOfKey(binder); if (index != NAME_NOT_FOUND) { String8 msg = String8::format("Camera %s: Surface already has a stream created for it " "(ID %zd)" , mCameraIdStr.string(), index); ALOGW("%s: %s" , __FUNCTION__, msg.string()); return STATUS_ERROR(CameraService::ERROR_ALREADY_EXISTS, msg.string()); } sp<Surface> surface; res = createSurfaceFromGbp(streamInfo, isStreamInfoValid, surface, bufferProducer, physicalCameraId); if (!res.isOk()) return res; if (!isStreamInfoValid) { isStreamInfoValid = true ; } binders.push_back(IInterface::asBinder(bufferProducer)); surfaces.push_back(surface); } int streamId = camera3::CAMERA3_STREAM_ID_INVALID; std::vector<int > surfaceIds; bool isDepthCompositeStream = camera3::DepthCompositeStream::isDepthCompositeStream(surfaces[0 ]); bool isHeicCompisiteStream = camera3::HeicCompositeStream::isHeicCompositeStream(surfaces[0 ]); if (isDepthCompositeStream || isHeicCompisiteStream) { ...... } else { err = mDevice->createStream(surfaces, deferredConsumer, streamInfo.width, streamInfo.height, streamInfo.format, streamInfo.dataSpace, static_cast<camera3_stream_rotation_t>(outputConfiguration.getRotation()), &streamId, physicalCameraId, &surfaceIds, outputConfiguration.getSurfaceSetID(), isShared); } if (err != OK) { ...... } else { int i = 0 ; for (auto& binder : binders) { ALOGV("%s: mStreamMap add binder %p streamId %d, surfaceId %d" , __FUNCTION__, binder.get(), streamId, i); mStreamMap.add(binder, StreamSurfaceId(streamId, surfaceIds[i])); i++; } mConfiguredOutputs.add(streamId, outputConfiguration); mStreamInfoMap[streamId] = streamInfo; ALOGV("%s: Camera %s: Successfully created a new stream ID %d for output surface" " (%d x %d) with format 0x%x." , __FUNCTION__, mCameraIdStr.string(), streamId, streamInfo.width, streamInfo.height, streamInfo.format); res = setStreamTransformLocked(streamId); *newStreamId = streamId; } return res; } Log: 07 -07 11 :03 :48.666 334 544 V Camera3-Device: Camera 0 : Created new stream07 -07 11 :03 :48.666 334 544 V CameraDeviceClient: createStream: mStreamMap add binder 0xe90162c0 streamId 0 , surfaceId 0 07 -07 11 :03 :48.666 334 544 V CameraDeviceClient: createStream: Camera 0 : Successfully created a new stream ID 0 for output surface (4096 x 3120 ) with format 0x21. Stack Trace: RELADDR FUNCTION FILE:LINE 001034a5 android::Camera3Device::createStream (std::__1::vector<android::sp<android::Surface>, std::__1::allocator<android::sp<android::Surface> > > const &, bool, unsigned int , unsigned int , int , android_dataspace_t, camera3_stream_rotation, int *, android::String8 const &, std::__1::vector<int , std::__1::allocator<int > >*, int , bool, unsigned long long ) +172 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:1758 000dcbd5 android::CameraDeviceClient::createStream (android::hardware::camera2::params::OutputConfiguration const &, int *) +1300 frameworks/av/services/camera/libcameraservice/api2/CameraDeviceClient.cpp:977 000dd4c9 non-virtual thunk to android::CameraDeviceClient::createStream (android::hardware::camera2::params::OutputConfiguration const &, int *) +4 aeabi_div0.c:? 00028509 android::hardware::camera2::BnCameraDeviceUser::onTransact (unsigned int , android::Parcel const &, android::Parcel*, unsigned int ) +720 out/soong/.intermediates/frameworks/av/camera/libcamera_client/android_arm_armv7-a-neon_cortex-a15_core_shared/gen/aidl/frameworks/av/camera/aidl/android/hardware/camera2/ICameraDeviceUser.cpp:1025 00032ed1 android::BBinder::transact (unsigned int , android::Parcel const &, android::Parcel*, unsigned int ) +72 frameworks/native /libs/binder/Binder.cpp:134 0003b117 android::IPCThreadState::executeCommand (int ) +770 frameworks/native /libs/binder/IPCThreadState.cpp:1213 0003ad53 android::IPCThreadState::getAndExecuteCommand () +98 frameworks/native /libs/binder/IPCThreadState.cpp:514 0003b2ef android::IPCThreadState::joinThreadPool (bool) +38 frameworks/native /libs/binder/IPCThreadState.cpp:594 00054665 android::PoolThread::threadLoop () +12 frameworks/native /libs/binder/ProcessState.cpp:67 0000d8bf android::Thread::_threadLoop (void *) +186 system/core/libutils/Threads.cpp:746 000a6867 __pthread_start (void *) +20 bionic/libc/bionic/pthread_create.cpp:338
上面的 mDevice->createStream() 将会调用到哪里呢?
CameraDeviceClient 类是继承模板类 Camera2ClientBase,看 mDevice 的定义,我们可以知道是 sp mDevice,mDevice 的赋值是在模板类Camera2ClientBase 的构造函数中,mDevice = new Camera3Device(cameraId),通过其构造函数可以知道 mDevice 指向 Camera3Device 实例对象。所以,mDevice->createStream() 将调用到 Camera3Device::createStream() 函数。
(4)、Camera3Device::createStream() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 F:\Khadas_Edge_Android_Q\frameworks\av\services\camera\libcameraservice\device3\Camera3Device.cpp status_t Camera3Device::createStream (const std ::vector <sp<Surface>>& consumers, bool hasDeferredConsumer, uint32_t width, uint32_t height, int format, android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id, const String8& physicalCameraId, std ::vector <int > *surfaceIds, int streamSetId, bool isShared, uint64_t consumerUsage) { ... ALOGV("Camera %s: Creating new stream %d: %d x %d, format %d, dataspace %d rotation %d" " consumer usage %" PRIu64 ", isShared %d, physicalCameraId %s" , mId.string (), mNextStreamId, width, height, format, dataSpace, rotation, consumerUsage, isShared, physicalCameraId.string ()); } else { newStream = new Camera3OutputStream(mNextStreamId, consumers[0 ], width, height, format, dataSpace, rotation, mTimestampOffset, physicalCameraId, streamSetId); } ... res = mOutputStreams.add(mNextStreamId, newStream); mNeedConfig = true ; ... Log:
我们回头看看 CameraDeviceImpl::configureStreamsChecked() 方法,在该方法中,通过 mRemoteDevice 操作影响到 CameraService,在 createStream() 之后,还将会调用 endConfigure() 操作
1 2 3 4 5 6 7 8 F:\Khadas_Edge_Android_Q\frameworks\av\services\camera\libcameraservice\api2\CameraDeviceClient.cpp binder::Status CameraDeviceClient::endConfigure (int operatingMode, const hardware::camera2::impl::CameraMetadataNative& sessionParams) { ... status_t err = mDevice->configureStreams(sessionParams, operatingMode); ... }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Stack Trace: RELADDR FUNCTION FILE:LINE 001079b f android::Camera3Device::HalInterface::configureStreams(camera_metadata const *, camera3_stream_configuration*, std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > const &)+1622 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:4341 00102b f9 android::Camera3Device::configureStreamsLocked(int , android::CameraMetadata const &, bool )+836 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:2901 00101 c01 android::Camera3Device::filterParamsAndConfigureLocked(android::CameraMetadata const &, int )+136 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:2054 00104359 android::Camera3Device::configureStreams(android::CameraMetadata const &, int )+124 aeabi_div0.c:? 000 da883 android::CameraDeviceClient::endConfigure(int , android::CameraMetadata const &)+310 frameworks/av/services/camera/libcameraservice/api2/CameraDeviceClient.cpp:491 000 dac21 non-virtual thunk to android::CameraDeviceClient::endConfigure(int , android::CameraMetadata const &)+4 aeabi_div0.c:? 0002842f android::hardware::camera2::BnCameraDeviceUser::onTransact(unsigned int , android::Parcel const &, android::Parcel*, unsigned int )+502 out/soong/.intermediates/frameworks/av/camera/libcamera_client/android_arm_armv7-a-neon_cortex-a15_core_shared/gen/aidl/frameworks/av/camera/aidl/android/hardware/camera2/ICameraDeviceUser.cpp:956 00032 ed1 android::BBinder::transact(unsigned int , android::Parcel const &, android::Parcel*, unsigned int )+72 frameworks/native/libs/binder/Binder.cpp:134 0003b 117 android::IPCThreadState::executeCommand(int )+770 frameworks/native/libs/binder/IPCThreadState.cpp:1213 0003 ad53 android::IPCThreadState::getAndExecuteCommand()+98 frameworks/native/libs/binder/IPCThreadState.cpp:514 0003b 2ef android::IPCThreadState::joinThreadPool(bool )+38 frameworks/native/libs/binder/IPCThreadState.cpp:594 00054665 android::PoolThread::threadLoop()+12 frameworks/native/libs/binder/ProcessState.cpp:67 0000 d8bf android::Thread::_threadLoop(void *)+186 system/core/libutils/Threads.cpp:746 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53
而在 Camera3Device::configureStreams() 中,最终又将是调用到 Camera3Device::configureStreamsLocked() 函数。而在 Camera3Device::configureStreamsLocked() 函数主要进行了以下操作:将 Camera3Device::createStream() 保存到 - - mOutputStreams 中的 stream 添加到 config.streams; 通过 mInterface->configureStreams(sessionBuffer, &config, bufferSizes) 操作到HAL配置流; 通知上层,配置完成;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 F:\Khadas_Edge_Android_Q\frameworks\av\services\camera\libcameraservice\device3\Camera3Device.cpp status_t Camera3Device::HalInterface::configureStreams(const camera_metadata_t *sessionParams, camera3_stream_configuration *config, const std ::vector <uint32_t >& bufferSizes) { ATRACE_NAME("CameraHal::configureStreams" ); ...... } else if (mHidlSession_3_3 != nullptr ) { CallStack stack ; stack .update(); stack .log ("Camera3Device::configureStreams_3_3" ); ALOGV("%s: v3.3 device found" , __FUNCTION__); auto err = mHidlSession_3_3->configureStreams_3_3(requestedConfiguration3_2, [&status, &finalConfiguration] (common::V1_0::Status s, const device::V3_3::HalStreamConfiguration& halConfiguration) { finalConfiguration = halConfiguration; status = s; }); if (!err.isOk()) { ALOGE("%s: Transaction error: %s" , __FUNCTION__, err.description().c_str()); return DEAD_OBJECT; } } else { ...... } ...... return res; }
上述的 mInterface 变量是在 Camera3Device::initialize() 时,保存 HalInterface 实例对象的,所以,mInterface->configureStreams() 将调用到 Camera3Device::HalInterface::configureStreams()。
Camera3Device::HalInterface::configureStreams() 将stream config转换为 HIDL 接口使用的之后,将按照 HAL 版本调用不同的接口函数,下面我们以 HAL 3.3 为例进行跟踪,将调用 mHidlSession_3_3->configureStreams_3_3()。注:mHidlSession_3_3 是在 HalInterface 构造函数中赋值的,而 mHidlSession_3_3 是 ICameraDeviceSession转换得来的,ICameraDeviceSession 则是Camera3Device::initialize() 中通过 manager->openSession() 获取的。
在上述的 mHidlSession_3_3->configureStreams_3_3() 调用,将会调用到 BpHwCameraDeviceSession::configureStreams_3_3() [android/out/soong/.intermediates/hardware/interfaces/camera/device/3.3/android.hardware.camera.device@3.3_genc++/gen/android/hardware/camera/device/3.3/CameraDeviceSessionAll.cpp],最终调用到 CameraProvider 中的 CameraDeviceSession::configureStreams_3_3()函数。通过HIDL配置流操作进入 CameraProvider。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Stack Trace: configure_streams() RELADDR FUNCTION FILE:LINE 0006 d35b android::camera2::Camera3HAL::configure_streams(camera3_stream_configuration*)+162 hardware/rockchip/camera/AAL/Camera3HAL.cpp:250 0006 daa9 android::camera2::hal_dev_configure_streams(camera3_device const *, camera3_stream_configuration*)+92 hardware/rockchip/camera/AAL/Camera3HAL.cpp:60 00004711 android::hardware::camera::device::V3_3::implementation::CameraDeviceSession::configureStreams_3_3(android::hardware::camera::device::V3_2::StreamConfiguration const &, std ::__1::function<void (android::hardware::camera::common::V1_0::Status, android::hardware::camera::device::V3_3::HalStreamConfiguration const &)>)+264 hardware/interfaces/camera/device/3.3 /default /CameraDeviceSession.cpp:88 00004 d03 android::hardware::camera::device::V3_3::implementation::CameraDeviceSession::TrampolineSessionInterface_3_3::configureStreams_3_3(android::hardware::camera::device::V3_2::StreamConfiguration const &, std ::__1::function<void (android::hardware::camera::common::V1_0::Status, android::hardware::camera::device::V3_3::HalStreamConfiguration const &)>)+66 hardware/interfaces/camera/device/3.3 /default /CameraDeviceSession.h:123 0000b 313 android::hardware::camera::device::V3_3::BnHwCameraDeviceSession::_hidl_configureStreams_3_3(android::hidl::base::V1_0::BnHwBase*, android::hardware::Parcel const &, android::hardware::Parcel*, std ::__1::function<void (android::hardware::Parcel&)>)+222 out/soong/.intermediates/hardware/interfaces/camera/device/3.3 /android.hardware.camera.device@3.3 _genc++/gen/android/hardware/camera/device/3.3 /CameraDeviceSessionAll.cpp:414 0000b 749 android::hardware::camera::device::V3_3::BnHwCameraDeviceSession::onTransact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+640 out/soong/.intermediates/hardware/interfaces/camera/device/3.3 /android.hardware.camera.device@3.3 _genc++/gen/android/hardware/camera/device/3.3 /CameraDeviceSessionAll.cpp:578 000689 a1 android::hardware::BHwBinder::transact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+52 system/libhwbinder/Binder.cpp:116 v------> android::hardware::IPCThreadState::executeCommand(int ) system/libhwbinder/IPCThreadState.cpp:1204 0006 af8d android::hardware::IPCThreadState::getAndExecuteCommand()+924 system/libhwbinder/IPCThreadState.cpp:461 0006b e61 android::hardware::IPCThreadState::joinThreadPool(bool )+56 system/libhwbinder/IPCThreadState.cpp:561 00076f 0d android::hardware::PoolThread::threadLoop()+12 system/libhwbinder/ProcessState.cpp:61 0000 d8bf android::Thread::_threadLoop(void *)+186 system/core/libutils/Threads.cpp:746 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53
(二)、construct_default_request_settings() (1)、Stack::createCaptureRequest() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 07 -07 11 :03 :48.923 1727 1727 V CAM_CameraAppUI: onPreviewStarted07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : createDefaultRequest07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : java.lang.RuntimeException: here07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureRequest(CameraDeviceImpl.java:781 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at com.android.camera.one.v2.camera2proxy.AndroidCameraDeviceProxy.createCaptureRequest(AndroidCameraDeviceProxy.java:90 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at com.android.camera.one.v2.camera2proxy.CameraDeviceRequestBuilderFactory.create(CameraDeviceRequestBuilderFactory.java:38 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at com.android.camera.one.v2.core.RequestTemplate.create(RequestTemplate.java:104 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at com.android.camera.one.v2.core.RequestTemplate.create(RequestTemplate.java:104 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at com.android.camera.one.v2.commands.PreviewCommand.run(PreviewCommand.java:56 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at com.android.camera.one.v2.commands.CameraCommandExecutor$CommandRunnable.run(CameraCommandExecutor.java:52 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at java.util.concurrent.FutureTask.run(FutureTask.java:266 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641 )07 -07 11 :03 :48.924 1727 1826 I CameraDevice-JV-0 : at java.lang.Thread.run(Thread.java:919 )
(2)、CameraDeviceImpl.createCaptureRequest() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 F:\Khadas_Edge_Android_Q\frameworks\base\core\java\android\hardware\camera2\impl\CameraDeviceImpl.java @Override public CaptureRequest.Builder createCaptureRequest (int templateType) throws CameraAccessException { synchronized(mInterfaceLock) { checkIfCameraClosedOrInError(); CameraMetadataNative templatedRequest = null; templatedRequest = mRemoteDevice.createDefaultRequest(templateType); ... return builder; } }
(3)、CameraDeviceClient::createDefaultRequest() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 F:\Khadas_Edge_Android_Q\frameworks\av\services\camera\libcameraservice\api2\CameraDeviceClient.cpp binder::Status CameraDeviceClient::createDefaultRequest (int templateId, hardware::camera2::impl::CameraMetadataNative* request) { ... CameraMetadata metadata; status_t err; if ( (err = mDevice->createDefaultRequest(templateId, &metadata) ) == OK && request != NULL ) { request->swap(metadata); } ... }
(4)、Camera3Device::createDefaultRequest() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 F:\Khadas_Edge_Android_Q\frameworks\av\services\camera\libcameraservice\common\CameraProviderManager.cpp status_t Camera3Device::createDefaultRequest (int templateId, CameraMetadata *request) { ... camera_metadata_t *rawRequest; status_t res = mInterface->constructDefaultRequestSettings( (camera3_request_template_t ) templateId, &rawRequest); { ... set_camera_metadata_vendor_id(rawRequest, mVendorTagId); mRequestTemplateCache[templateId].acquire(rawRequest); ... } }
(5)、Camera3Device::createDefaultRequest()->Stack Trace 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Stack Trace: RELADDR FUNCTION FILE:LINE 00104575 android::Camera3Device::createDefaultRequest(int , android::CameraMetadata*)+208 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:2112 000 de733 android::CameraDeviceClient::createDefaultRequest(int , android::CameraMetadata*)+206 frameworks/av/services/camera/libcameraservice/api2/CameraDeviceClient.cpp:1535 000 de8a1 non-virtual thunk to android::CameraDeviceClient::createDefaultRequest(int , android::CameraMetadata*)+4 aeabi_div0.c:? 0002863f android::hardware::camera2::BnCameraDeviceUser::onTransact(unsigned int , android::Parcel const &, android::Parcel*, unsigned int )+1030 out/soong/.intermediates/frameworks/av/camera/libcamera_client/android_arm_armv7-a-neon_cortex-a15_core_shared/gen/aidl/frameworks/av/camera/aidl/android/hardware/camera2/ICameraDeviceUser.cpp:1108 00032 ed1 android::BBinder::transact(unsigned int , android::Parcel const &, android::Parcel*, unsigned int )+72 frameworks/native/libs/binder/Binder.cpp:134 0003b 117 android::IPCThreadState::executeCommand(int )+770 frameworks/native/libs/binder/IPCThreadState.cpp:1213 0003 ad53 android::IPCThreadState::getAndExecuteCommand()+98 frameworks/native/libs/binder/IPCThreadState.cpp:514 0003b 2ef android::IPCThreadState::joinThreadPool(bool )+38 frameworks/native/libs/binder/IPCThreadState.cpp:594 00054665 android::PoolThread::threadLoop()+12 frameworks/native/libs/binder/ProcessState.cpp:67 0000 d8bf android::Thread::_threadLoop(void *)+186 system/core/libutils/Threads.cpp:746 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53
(6)、Camera3HAL::construct_default_request_settings()->Stack Trace 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Stack Trace: RELADDR FUNCTION FILE:LINE 0006 d665 android::camera2::Camera3HAL::construct_default_request_settings(int )+92 hardware/rockchip/camera/AAL/Camera3HAL.cpp:295 0006 dc15 android::camera2::hal_dev_construct_default_request_settings(camera3_device const *, int )+92 hardware/rockchip/camera/AAL/Camera3HAL.cpp:76 00019 c27 android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::constructDefaultRequestSettingsRaw(int , android::hardware::hidl_vec<unsigned char >*)+110 hardware/interfaces/camera/device/3.2 /default /CameraDeviceSession.cpp:847 00019b 67 android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::constructDefaultRequestSettings(android::hardware::camera::device::V3_2::RequestTemplate, std ::__1::function<void (android::hardware::camera::common::V1_0::Status, android::hardware::hidl_vec<unsigned char > const &)>)+50 hardware/interfaces/camera/device/3.2 /default /CameraDeviceSession.cpp:837 000049b f android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::TrampolineSessionInterface_3_2::constructDefaultRequestSettings(android::hardware::camera::device::V3_2::RequestTemplate, std ::__1::function<void (android::hardware::camera::common::V1_0::Status, android::hardware::hidl_vec<unsigned char > const &)>)+66 hardware/interfaces/camera/device/3.3 /default /CameraDeviceSession.h:88 0001f 431 android::hardware::camera::device::V3_2::BnHwCameraDeviceSession::_hidl_constructDefaultRequestSettings(android::hidl::base::V1_0::BnHwBase*, android::hardware::Parcel const &, android::hardware::Parcel*, std ::__1::function<void (android::hardware::Parcel&)>)+200 out/soong/.intermediates/hardware/interfaces/camera/device/3.2 /android.hardware.camera.device@3.2 _genc++/gen/android/hardware/camera/device/3.2 /CameraDeviceSessionAll.cpp:839 0000b 655 android::hardware::camera::device::V3_3::BnHwCameraDeviceSession::onTransact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+396 out/soong/.intermediates/hardware/interfaces/camera/device/3.3 /android.hardware.camera.device@3.3 _genc++/gen/android/hardware/camera/device/3.3 /CameraDeviceSessionAll.cpp:501 000689 a1 android::hardware::BHwBinder::transact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+52 system/libhwbinder/Binder.cpp:116 v------> android::hardware::IPCThreadState::executeCommand(int ) system/libhwbinder/IPCThreadState.cpp:1204 0006 af8d android::hardware::IPCThreadState::getAndExecuteCommand()+924 system/libhwbinder/IPCThreadState.cpp:461 0006b e61 android::hardware::IPCThreadState::joinThreadPool(bool )+56 system/libhwbinder/IPCThreadState.cpp:561 v------> int android::hardware::defaultPassthroughServiceImplementation<android::hardware::camera::provider::V2_4::ICameraProvider>(std ::__1::basic_string<char , std ::__1::char_traits<char >, std ::__1::allocator<char > > const &, unsigned int ) system/libhidl/transport/include/hidl/LegacySupport.h:85 000010b 9 main+116 hardware/interfaces/camera/provider/2.4 /default /service.cpp:49 00059127 __libc_init+66 bionic/libc/bionic/libc_init_dynamic.cpp:136 0000102f _start_main+38 bionic/libc/arch-common/bionic/crtbegin.c:45 00004456 <unknown> <anonymous:ec7ce000>
(三)、process_capture_request() (1)、ICameraDeviceUserWrapper.submitRequestList() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: submitRequestList07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: java.lang.RuntimeException: here07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at android.hardware.camera2.impl.ICameraDeviceUserWrapper.submitRequestList(ICameraDeviceUserWrapper.java:88 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at android.hardware.camera2.impl.CameraDeviceImpl.submitCaptureRequest(CameraDeviceImpl.java:1074 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at android.hardware.camera2.impl.CameraDeviceImpl.setRepeatingBurst(CameraDeviceImpl.java:1127 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at android.hardware.camera2.impl.CameraCaptureSessionImpl.setRepeatingBurst(CameraCaptureSessionImpl.java:352 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at com.android.camera.one.v2.camera2proxy.AndroidCameraCaptureSessionProxy.setRepeatingBurst(AndroidCameraCaptureSessionProxy.java:129 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at com.android.camera.one.v2.core.TagDispatchCaptureSession.submitRequest(TagDispatchCaptureSession.java:154 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at com.android.camera.one.v2.core.FrameServerImpl$Session.submitRequest(FrameServerImpl.java:58 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at com.android.camera.one.v2.commands.PreviewCommand.run(PreviewCommand.java:57 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at com.android.camera.one.v2.commands.CameraCommandExecutor$CommandRunnable.run(CameraCommandExecutor.java:52 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at java.util.concurrent.FutureTask.run(FutureTask.java:266 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641 )07 -07 11 :03 :49.003 1727 1826 I ICameraDeviceUserWrapper: at java.lang.Thread.run(Thread.java:919 )
(2)、ICameraDeviceUserWrapper.submitRequestList() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 F:\Khadas_Edge_Android_Q\frameworks\base\core\java\android\hardware\camera2\impl\ICameraDeviceUserWrapper.java public class ICameraDeviceUserWrapper { ... public SubmitInfo submitRequest (CaptureRequest request, boolean streaming) throws CameraAccessException { try { return mRemoteDevice.submitRequest(request, streaming); } catch (Throwable t) { CameraManager.throwAsPublicException(t); throw new UnsupportedOperationException("Unexpected exception" , t); } } }
(3)、Camera3Device::RequestThread::unpauseForNewRequests() ->Stack Trace 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Stack Trace: RELADDR FUNCTION FILE:LINE 0010 c575 android::Camera3Device::RequestThread::unpauseForNewRequests()+64 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:6218 000f ebc3 android::Camera3Device::RequestThread::queueRequestList(android::List<android::sp<android::Camera3Device::CaptureRequest> >&, long long *)+198 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:4992 000f e8bd android::Camera3Device::submitRequestsHelper(android::List<android::List<android::CameraDeviceBase::PhysicalCameraSettings> const > const &, std ::__1::list <std ::__1::unordered_map <int , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > >, std ::__1::hash<int >, std ::__1::equal_to<int >, std ::__1::allocator<std ::__1::pair <int const , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > > > > const , std ::__1::allocator<std ::__1::unordered_map <int , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > >, std ::__1::hash<int >, std ::__1::equal_to<int >, std ::__1::allocator<std ::__1::pair <int const , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > > > > const > > const &, bool , long long *)+248 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:967 001019 d5 android::Camera3Device::captureList(android::List<android::List<android::CameraDeviceBase::PhysicalCameraSettings> const > const &, std ::__1::list <std ::__1::unordered_map <int , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > >, std ::__1::hash<int >, std ::__1::equal_to<int >, std ::__1::allocator<std ::__1::pair <int const , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > > > > const , std ::__1::allocator<std ::__1::unordered_map <int , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > >, std ::__1::hash<int >, std ::__1::equal_to<int >, std ::__1::allocator<std ::__1::pair <int const , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > > > > const > > const &, long long *)+52 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:1523 000 d9e69 android::CameraDeviceClient::submitRequestList(std ::__1::vector <android::hardware::camera2::CaptureRequest, std ::__1::allocator<android::hardware::camera2::CaptureRequest> > const &, bool , android::hardware::camera2::utils::SubmitInfo*)+3432 frameworks/av/services/camera/libcameraservice/api2/CameraDeviceClient.cpp:405 000 da42b non-virtual thunk to android::CameraDeviceClient::submitRequestList(std ::__1::vector <android::hardware::camera2::CaptureRequest, std ::__1::allocator<android::hardware::camera2::CaptureRequest> > const &, bool , android::hardware::camera2::utils::SubmitInfo*)+14 aeabi_div0.c:? 00028385 android::hardware::camera2::BnCameraDeviceUser::onTransact(unsigned int , android::Parcel const &, android::Parcel*, unsigned int )+332 out/soong/.intermediates/frameworks/av/camera/libcamera_client/android_arm_armv7-a-neon_cortex-a15_core_shared/gen/aidl/frameworks/av/camera/aidl/android/hardware/camera2/ICameraDeviceUser.cpp:884 00032 ed1 android::BBinder::transact(unsigned int , android::Parcel const &, android::Parcel*, unsigned int )+72 frameworks/native/libs/binder/Binder.cpp:134 0003b 117 android::IPCThreadState::executeCommand(int )+770 frameworks/native/libs/binder/IPCThreadState.cpp:1213 0003 ad53 android::IPCThreadState::getAndExecuteCommand()+98 frameworks/native/libs/binder/IPCThreadState.cpp:514 0003b 2ef android::IPCThreadState::joinThreadPool(bool )+38 frameworks/native/libs/binder/IPCThreadState.cpp:594 00054665 android::PoolThread::threadLoop()+12 frameworks/native/libs/binder/ProcessState.cpp:67 0000 d8bf android::Thread::_threadLoop(void *)+186 system/core/libutils/Threads.cpp:746 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53
Camera3Device::RequestThread::threadLoop()中waitForNextRequestBatch();在等待请求,mRequestSignal.signal唤醒线程后继续运行。
(4)、Camera3Device::HalInterface::processBatchCaptureRequest->Stack Trace 1 2 3 4 5 6 7 8 9 Stack Trace: RELADDR FUNCTION FILE:LINE 0010b 155 android::Camera3Device::HalInterface::processBatchCaptureRequests(std ::__1::vector <camera3_capture_request*, std ::__1::allocator<camera3_capture_request*> >&, unsigned int *)+1296 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:4685 0010 cac9 android::Camera3Device::RequestThread::sendRequestsBatch()+264 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:5232 0010 db51 android::Camera3Device::RequestThread::threadLoop()+664 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:5526 0000 d945 android::Thread::_threadLoop(void *)+320 system/core/libutils/Threads.cpp:749 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53
(5)、Camera3HAL::process_capture_request()->Stack Trace 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Stack Trace: RELADDR FUNCTION FILE:LINE 0006 d6f3 android::camera2::Camera3HAL::process_capture_request(camera3_capture_request*)+86 hardware/rockchip/camera/AAL/Camera3HAL.cpp:323 0006 dd7d android::camera2::hal_dev_process_capture_request(camera3_device const *, camera3_capture_request*)+92 hardware/rockchip/camera/AAL/Camera3HAL.cpp:93 0001b 4bb android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::processOneCaptureRequest(android::hardware::camera::device::V3_2::CaptureRequest const &)+1286 hardware/interfaces/camera/device/3.2 /default /CameraDeviceSession.cpp:1258 0001 af49 android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::processCaptureRequest(android::hardware::hidl_vec<android::hardware::camera::device::V3_2::CaptureRequest> const &, android::hardware::hidl_vec<android::hardware::camera::device::V3_2::BufferCache> const &, std ::__1::function<void (android::hardware::camera::common::V1_0::Status, unsigned int )>)+52 hardware/interfaces/camera/device/3.2 /default /CameraDeviceSession.cpp:1146 00004 aa5 android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::TrampolineSessionInterface_3_2::processCaptureRequest(android::hardware::hidl_vec<android::hardware::camera::device::V3_2::CaptureRequest> const &, android::hardware::hidl_vec<android::hardware::camera::device::V3_2::BufferCache> const &, std ::__1::function<void (android::hardware::camera::common::V1_0::Status, unsigned int )>)+72 hardware/interfaces/camera/device/3.3 /default /CameraDeviceSession.h:100 0001f 8b5 android::hardware::camera::device::V3_2::BnHwCameraDeviceSession::_hidl_processCaptureRequest(android::hidl::base::V1_0::BnHwBase*, android::hardware::Parcel const &, android::hardware::Parcel*, std ::__1::function<void (android::hardware::Parcel&)>)+348 out/soong/.intermediates/hardware/interfaces/camera/device/3.2 /android.hardware.camera.device@3.2 _genc++/gen/android/hardware/camera/device/3.2 /CameraDeviceSessionAll.cpp:1055 0000b 699 android::hardware::camera::device::V3_3::BnHwCameraDeviceSession::onTransact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+464 out/soong/.intermediates/hardware/interfaces/camera/device/3.3 /android.hardware.camera.device@3.3 _genc++/gen/android/hardware/camera/device/3.3 /CameraDeviceSessionAll.cpp:523 000689 a1 android::hardware::BHwBinder::transact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+52 system/libhwbinder/Binder.cpp:116 v------> android::hardware::IPCThreadState::executeCommand(int ) system/libhwbinder/IPCThreadState.cpp:1204 0006 af8d android::hardware::IPCThreadState::getAndExecuteCommand()+924 system/libhwbinder/IPCThreadState.cpp:461 0006b e61 android::hardware::IPCThreadState::joinThreadPool(bool )+56 system/libhwbinder/IPCThreadState.cpp:561 v------> int android::hardware::defaultPassthroughServiceImplementation<android::hardware::camera::provider::V2_4::ICameraProvider>(std ::__1::basic_string<char , std ::__1::char_traits<char >, std ::__1::allocator<char > > const &, unsigned int ) system/libhidl/transport/include/hidl/LegacySupport.h:85 000010b 9 main+116 hardware/interfaces/camera/provider/2.4 /default /service.cpp:49 00059127 __libc_init+66 bionic/libc/bionic/libc_init_dynamic.cpp:136 0000102f _start_main+38 bionic/libc/arch-common/bionic/crtbegin.c:45 00004456 <unknown> <anonymous:ec7ce000>
(四)、processCaptureResult() (1)、CameraDeviceSession::ResultBatcher::invokeProcessCaptureResultCallback()->Stack Trace 1 2 3 4 5 6 7 8 9 10 11 12 13 Stack Trace: RELADDR FUNCTION FILE:LINE 00018b 5d android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::ResultBatcher::invokeProcessCaptureResultCallback(android::hardware::hidl_vec<android::hardware::camera::device::V3_2::CaptureResult>&, bool )+316 hardware/interfaces/camera/device/3.2 /default /CameraDeviceSession.cpp:748 000195 a5 android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::ResultBatcher::processOneCaptureResult(android::hardware::camera::device::V3_2::CaptureResult&)+64 hardware/interfaces/camera/device/3.2 /default /CameraDeviceSession.cpp:763 00019735 android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::ResultBatcher::processCaptureResult(android::hardware::camera::device::V3_2::CaptureResult&)+100 hardware/interfaces/camera/device/3.2 /default /CameraDeviceSession.cpp:772 00016641 android::hardware::camera::device::V3_2::implementation::CameraDeviceSession::sProcessCaptureResult(camera3_callback_ops const *, camera3_capture_result const *)+160 hardware/interfaces/camera/device/3.2 /default /CameraDeviceSession.cpp:1584 000741e9 android::camera2::ResultProcessor::returnPendingBuffers(android::camera2::ResultProcessor::RequestState_t*)+484 hardware/rockchip/camera/AAL/ResultProcessor.cpp:477 00073 d1f android::camera2::ResultProcessor::handleBufferDone(android::camera2::ResultProcessor::Message&)+326 hardware/rockchip/camera/AAL/ResultProcessor.cpp:420 0007357b android::camera2::ResultProcessor::messageThreadLoop()+198 hardware/rockchip/camera/AAL/ResultProcessor.cpp:159 0008f 2e1 android::camera2::MessageThread::threadLoop(void *)+8 hardware/rockchip/camera/common/MessageThread.h:66 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53
(2)、Camera3Device::processCaptureResult()->Stack Trace 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Stack Trace: RELADDR FUNCTION FILE:LINE 00100f 15 android::Camera3Device::processCaptureResult(camera3_capture_result const *)+84 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:3625 001006f 5 android::Camera3Device::processOneCaptureResultLocked(android::hardware::camera::device::V3_2::CaptureResult const &, android::hardware::hidl_vec<android::hardware::camera::device::V3_4::PhysicalCameraMetadata>)+1064 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:1454 001009 dd android::Camera3Device::processCaptureResult(android::hardware::hidl_vec<android::hardware::camera::device::V3_2::CaptureResult> const &)+224 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:1278 00100 af3 virtual thunk to android::Camera3Device::processCaptureResult(android::hardware::hidl_vec<android::hardware::camera::device::V3_2::CaptureResult> const &)+10 aeabi_div0.c:? 00019 d15 android::hardware::camera::device::V3_2::BnHwCameraDeviceCallback::_hidl_processCaptureResult(android::hidl::base::V1_0::BnHwBase*, android::hardware::Parcel const &, android::hardware::Parcel*, std ::__1::function<void (android::hardware::Parcel&)>)+212 out/soong/.intermediates/hardware/interfaces/camera/device/3.2 /android.hardware.camera.device@3.2 _genc++/gen/android/hardware/camera/device/3.2 /CameraDeviceCallbackAll.cpp:422 0001 ef41 android::hardware::camera::device::V3_5::BnHwCameraDeviceCallback::onTransact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+288 out/soong/.intermediates/hardware/interfaces/camera/device/3.5 /android.hardware.camera.device@3.5 _genc++/gen/android/hardware/camera/device/3.5 /CameraDeviceCallbackAll.cpp:679 000689 a1 android::hardware::BHwBinder::transact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+52 system/libhwbinder/Binder.cpp:116 v------> android::hardware::IPCThreadState::executeCommand(int ) system/libhwbinder/IPCThreadState.cpp:1204 0006 af8d android::hardware::IPCThreadState::getAndExecuteCommand()+924 system/libhwbinder/IPCThreadState.cpp:461 0006b e61 android::hardware::IPCThreadState::joinThreadPool(bool )+56 system/libhwbinder/IPCThreadState.cpp:561 00076f 0d android::hardware::PoolThread::threadLoop()+12 system/libhwbinder/ProcessState.cpp:61 0000 d8bf android::Thread::_threadLoop(void *)+186 system/core/libutils/Threads.cpp:746 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53
(3)、Camera3OutputStream::returnBufferCheckedLocked()->Stack Trace 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Stack Trace: RELADDR FUNCTION FILE:LINE 0011 ac87 android::camera3::Camera3OutputStream::returnBufferCheckedLocked(camera3_stream_buffer const &, long long , bool , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > const &, android::sp<android::Fence>*)+50 frameworks/av/services/camera/libcameraservice/device3/Camera3OutputStream.cpp:219 001184 cd android::camera3::Camera3IOStreamBase::returnAnyBufferLocked(camera3_stream_buffer const &, long long , bool , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > const &)+124 frameworks/av/services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp:242 0011 abfd android::camera3::Camera3OutputStream::returnBufferLocked(camera3_stream_buffer const &, long long , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > const &)+60 frameworks/av/services/camera/libcameraservice/device3/Camera3OutputStream.cpp:196 00117089 android::camera3::Camera3Stream::returnBuffer(camera3_stream_buffer const &, long long , bool , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > const &, unsigned long long )+240 frameworks/av/services/camera/libcameraservice/device3/Camera3Stream.cpp:708 000f fcc7 android::Camera3Device::returnOutputBuffers(camera3_stream_buffer const *, unsigned int , long long , bool , std ::__1::unordered_map <int , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > >, std ::__1::hash<int >, std ::__1::equal_to<int >, std ::__1::allocator<std ::__1::pair <int const , std ::__1::vector <unsigned int , std ::__1::allocator<unsigned int > > > > > const &, android::hardware::camera2::impl::CaptureResultExtras const &)+334 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:3185 001013 df android::Camera3Device::processCaptureResult(camera3_capture_result const *)+1310 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:3772 001006f 5 android::Camera3Device::processOneCaptureResultLocked(android::hardware::camera::device::V3_2::CaptureResult const &, android::hardware::hidl_vec<android::hardware::camera::device::V3_4::PhysicalCameraMetadata>)+1064 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:1454 001009 dd android::Camera3Device::processCaptureResult(android::hardware::hidl_vec<android::hardware::camera::device::V3_2::CaptureResult> const &)+224 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:1278 00100 af3 virtual thunk to android::Camera3Device::processCaptureResult(android::hardware::hidl_vec<android::hardware::camera::device::V3_2::CaptureResult> const &)+10 aeabi_div0.c:? 00019 d15 android::hardware::camera::device::V3_2::BnHwCameraDeviceCallback::_hidl_processCaptureResult(android::hidl::base::V1_0::BnHwBase*, android::hardware::Parcel const &, android::hardware::Parcel*, std ::__1::function<void (android::hardware::Parcel&)>)+212 out/soong/.intermediates/hardware/interfaces/camera/device/3.2 /android.hardware.camera.device@3.2 _genc++/gen/android/hardware/camera/device/3.2 /CameraDeviceCallbackAll.cpp:422 0001 ef41 android::hardware::camera::device::V3_5::BnHwCameraDeviceCallback::onTransact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+288 out/soong/.intermediates/hardware/interfaces/camera/device/3.5 /android.hardware.camera.device@3.5 _genc++/gen/android/hardware/camera/device/3.5 /CameraDeviceCallbackAll.cpp:679 000689 a1 android::hardware::BHwBinder::transact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+52 system/libhwbinder/Binder.cpp:116 v------> android::hardware::IPCThreadState::executeCommand(int ) system/libhwbinder/IPCThreadState.cpp:1204 0006 af8d android::hardware::IPCThreadState::getAndExecuteCommand()+924 system/libhwbinder/IPCThreadState.cpp:461 0006b e61 android::hardware::IPCThreadState::joinThreadPool(bool )+56 system/libhwbinder/IPCThreadState.cpp:561 00076f 0d android::hardware::PoolThread::threadLoop()+12 system/libhwbinder/ProcessState.cpp:61 0000 d8bf android::Thread::_threadLoop(void *)+186 system/core/libutils/Threads.cpp:746 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53
(4)、queueBufferToConsumer() 1 2 3 4 5 6 7 8 9 F:\Khadas_Edge_Android_Q\frameworks\av\services\camera\libcameraservice\device3\Camera3OutputStream.cpp status_t Camera3OutputStream::queueBufferToConsumer (sp<ANativeWindow>& consumer, ANativeWindowBuffer* buffer, int anwReleaseFence) { return consumer->queueBuffer(consumer.get(), buffer, anwReleaseFence); }
(5)、Camera3Device::insertResultLocked()->Stack Trace 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Stack Trace: RELADDR FUNCTION FILE:LINE 00108 d31 android::Camera3Device::insertResultLocked(android::CaptureResult*, unsigned int )+344 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:3466 00109699 android::Camera3Device::sendCaptureResult(android::CameraMetadata&, android::hardware::camera2::impl::CaptureResultExtras&, android::CameraMetadata&, unsigned int , bool , bool , std ::__1::vector <android::hardware::camera2::impl::PhysicalCaptureResultInfo, std ::__1::allocator<android::hardware::camera2::impl::PhysicalCaptureResultInfo> > const &)+1480 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:3614 00101573 android::Camera3Device::processCaptureResult(camera3_capture_result const *)+1714 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:3790 001006f 5 android::Camera3Device::processOneCaptureResultLocked(android::hardware::camera::device::V3_2::CaptureResult const &, android::hardware::hidl_vec<android::hardware::camera::device::V3_4::PhysicalCameraMetadata>)+1064 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:1454 001009 dd android::Camera3Device::processCaptureResult(android::hardware::hidl_vec<android::hardware::camera::device::V3_2::CaptureResult> const &)+224 frameworks/av/services/camera/libcameraservice/device3/Camera3Device.cpp:1278 00100 af3 virtual thunk to android::Camera3Device::processCaptureResult(android::hardware::hidl_vec<android::hardware::camera::device::V3_2::CaptureResult> const &)+10 aeabi_div0.c:? 00019 d15 android::hardware::camera::device::V3_2::BnHwCameraDeviceCallback::_hidl_processCaptureResult(android::hidl::base::V1_0::BnHwBase*, android::hardware::Parcel const &, android::hardware::Parcel*, std ::__1::function<void (android::hardware::Parcel&)>)+212 out/soong/.intermediates/hardware/interfaces/camera/device/3.2 /android.hardware.camera.device@3.2 _genc++/gen/android/hardware/camera/device/3.2 /CameraDeviceCallbackAll.cpp:422 0001 ef41 android::hardware::camera::device::V3_5::BnHwCameraDeviceCallback::onTransact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+288 out/soong/.intermediates/hardware/interfaces/camera/device/3.5 /android.hardware.camera.device@3.5 _genc++/gen/android/hardware/camera/device/3.5 /CameraDeviceCallbackAll.cpp:679 000689 a1 android::hardware::BHwBinder::transact(unsigned int , android::hardware::Parcel const &, android::hardware::Parcel*, unsigned int , std ::__1::function<void (android::hardware::Parcel&)>)+52 system/libhwbinder/Binder.cpp:116 v------> android::hardware::IPCThreadState::executeCommand(int ) system/libhwbinder/IPCThreadState.cpp:1204 0006 af8d android::hardware::IPCThreadState::getAndExecuteCommand()+924 system/libhwbinder/IPCThreadState.cpp:461 0006b e61 android::hardware::IPCThreadState::joinThreadPool(bool )+56 system/libhwbinder/IPCThreadState.cpp:561 00076f 0d android::hardware::PoolThread::threadLoop()+12 system/libhwbinder/ProcessState.cpp:61 0000 d8bf android::Thread::_threadLoop(void *)+186 system/core/libutils/Threads.cpp:746 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53
在 Camera3Device::insertResultLocked() 中的 mResultSignal 信号到底是发给谁呢?
通过搜索代码可以知道,在 FrameProcessorBase 帧处理线程中将会接收该信号。而帧处理线程是在 CameraDeviceClient 对象的 CameraDeviceClient::initializeImpl() 中启动的(open camera阶段调用到该函数)。
(6)、CameraDeviceClient::onResultAvailable()->Stack Trace 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 Stack Trace: RELADDR FUNCTION FILE:LINE 000e0559 android::CameraDeviceClient::onResultAvailable(android::CaptureResult const &)+92 frameworks/av/services/camera/libcameraservice/api2/CameraDeviceClient.cpp:2026 000b bc39 android::camera2::FrameProcessorBase::processListeners(android::CaptureResult const &, android::sp<android::CameraDeviceBase> const &)+464 frameworks/av/services/camera/libcameraservice/common/FrameProcessorBase.cpp:229 000b ba4f android::camera2::FrameProcessorBase::processSingleFrame(android::CaptureResult&, android::sp<android::CameraDeviceBase> const &)+54 frameworks/av/services/camera/libcameraservice/common/FrameProcessorBase.cpp:180 000b b893 android::camera2::FrameProcessorBase::processNewFrames(android::sp<android::CameraDeviceBase> const &)+222 frameworks/av/services/camera/libcameraservice/common/FrameProcessorBase.cpp:156 000b b75f android::camera2::FrameProcessorBase::threadLoop()+106 frameworks/av/services/camera/libcameraservice/common/FrameProcessorBase.cpp:126 0000 d945 android::Thread::_threadLoop(void *)+320 system/core/libutils/Threads.cpp:749 000 a6867 __pthread_start(void *)+20 bionic/libc/bionic/pthread_create.cpp:338 00060087 __start_thread+30 bionic/libc/bionic/clone.cpp:53 F:\Khadas_Edge_Android_Q\frameworks\av\services\camera\libcameraservice\api2\CameraDeviceClient.cpp void CameraDeviceClient::onResultAvailable (const CaptureResult& result) { ATRACE_CALL(); ALOGV("%s" , __FUNCTION__); CallStack stack ; stack .update(); stack .log ("CameraDeviceClient::onResultAvailable" ); sp<hardware::camera2::ICameraDeviceCallbacks> remoteCb = mRemoteCallback; if (remoteCb != NULL ) { remoteCb->onResultReceived(result.mMetadata, result.mResultExtras, result.mPhysicalMetadatas); } for (size_t i = 0 ; i < mCompositeStreamMap.size(); i++) { mCompositeStreamMap.valueAt(i)->onResultAvailable(result); } }
(7)、Stack::CameraDeviceCallbacks.onResultReceived() 1 2 3 4 5 6 07 -08 07 :21 :08.192 4654 4671 I CameraDevice-JV-0 : onResultReceived07 -08 07 :21 :08.192 4654 4671 I CameraDevice-JV-0 : java.lang.RuntimeException: here07 -08 07 :21 :08.192 4654 4671 I CameraDevice-JV-0 : at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.onResultReceived(CameraDeviceImpl.java:2135 )07 -08 07 :21 :08.192 4654 4671 I CameraDevice-JV-0 : at android.hardware.camera2.ICameraDeviceCallbacks$Stub.onTransact(ICameraDeviceCallbacks.java:180 )07 -08 07 :21 :08.192 4654 4671 I CameraDevice-JV-0 : at android.os.Binder.execTransactInternal(Binder.java:1021 )07 -08 07 :21 :08.192 4654 4671 I CameraDevice-JV-0 : at android.os.Binder.execTransact(Binder.java:994 )