Loading services/camera/virtualcamera/VirtualCameraTestInstance.cc +22 −7 Original line number Diff line number Diff line Loading @@ -125,10 +125,18 @@ ScopedAStatus VirtualCameraTestInstance::onStreamConfigured( ALOGV("%s: streamId %d, %dx%d pixFmt=%s", __func__, streamId, width, height, toString(pixelFormat).c_str()); std::lock_guard<std::mutex> lock(mLock); mRenderer = std::make_shared<TestPatternRenderer>( auto renderer = std::make_shared<TestPatternRenderer>( nativeWindowFromSurface(surface), mFps); mRenderer->start(); std::lock_guard<std::mutex> lock(mLock); if (mInputRenderers.try_emplace(streamId, renderer).second) { renderer->start(); } else { ALOGE( "%s: Input stream with id %d is already active, ignoring " "onStreamConfigured call", __func__, streamId); } return ScopedAStatus::ok(); } Loading @@ -141,10 +149,17 @@ ScopedAStatus VirtualCameraTestInstance::onProcessCaptureRequest( ScopedAStatus VirtualCameraTestInstance::onStreamClosed(const int32_t streamId) { ALOGV("%s: streamId %d", __func__, streamId); std::shared_ptr<TestPatternRenderer> renderer; { std::lock_guard<std::mutex> lock(mLock); if (mRenderer != nullptr) { mRenderer->stop(); mRenderer.reset(); auto it = mInputRenderers.find(streamId); if (it != mInputRenderers.end()) { renderer = std::move(it->second); mInputRenderers.erase(it); } } if (renderer != nullptr) { renderer->stop(); } return ScopedAStatus::ok(); } Loading services/camera/virtualcamera/VirtualCameraTestInstance.h +5 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ #define ANDROID_COMPANION_VIRTUALCAMERA_VIRTUALCAMERATESTINSTANCE_H #include <atomic> #include <condition_variable> #include <map> #include <memory> #include <thread> Loading Loading @@ -80,7 +80,10 @@ class VirtualCameraTestInstance const int mFps; std::mutex mLock; std::shared_ptr<TestPatternRenderer> mRenderer GUARDED_BY(mLock); // Map maintaining streamId -> TestPatternRenderer mapping for active // input streams. std::map<int, std::shared_ptr<TestPatternRenderer>> mInputRenderers GUARDED_BY(mLock); }; } // namespace virtualcamera Loading Loading
services/camera/virtualcamera/VirtualCameraTestInstance.cc +22 −7 Original line number Diff line number Diff line Loading @@ -125,10 +125,18 @@ ScopedAStatus VirtualCameraTestInstance::onStreamConfigured( ALOGV("%s: streamId %d, %dx%d pixFmt=%s", __func__, streamId, width, height, toString(pixelFormat).c_str()); std::lock_guard<std::mutex> lock(mLock); mRenderer = std::make_shared<TestPatternRenderer>( auto renderer = std::make_shared<TestPatternRenderer>( nativeWindowFromSurface(surface), mFps); mRenderer->start(); std::lock_guard<std::mutex> lock(mLock); if (mInputRenderers.try_emplace(streamId, renderer).second) { renderer->start(); } else { ALOGE( "%s: Input stream with id %d is already active, ignoring " "onStreamConfigured call", __func__, streamId); } return ScopedAStatus::ok(); } Loading @@ -141,10 +149,17 @@ ScopedAStatus VirtualCameraTestInstance::onProcessCaptureRequest( ScopedAStatus VirtualCameraTestInstance::onStreamClosed(const int32_t streamId) { ALOGV("%s: streamId %d", __func__, streamId); std::shared_ptr<TestPatternRenderer> renderer; { std::lock_guard<std::mutex> lock(mLock); if (mRenderer != nullptr) { mRenderer->stop(); mRenderer.reset(); auto it = mInputRenderers.find(streamId); if (it != mInputRenderers.end()) { renderer = std::move(it->second); mInputRenderers.erase(it); } } if (renderer != nullptr) { renderer->stop(); } return ScopedAStatus::ok(); } Loading
services/camera/virtualcamera/VirtualCameraTestInstance.h +5 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ #define ANDROID_COMPANION_VIRTUALCAMERA_VIRTUALCAMERATESTINSTANCE_H #include <atomic> #include <condition_variable> #include <map> #include <memory> #include <thread> Loading Loading @@ -80,7 +80,10 @@ class VirtualCameraTestInstance const int mFps; std::mutex mLock; std::shared_ptr<TestPatternRenderer> mRenderer GUARDED_BY(mLock); // Map maintaining streamId -> TestPatternRenderer mapping for active // input streams. std::map<int, std::shared_ptr<TestPatternRenderer>> mInputRenderers GUARDED_BY(mLock); }; } // namespace virtualcamera Loading