Loading media/codec2/vndk/C2AllocatorIon.cpp +22 −15 Original line number Diff line number Diff line Loading @@ -207,6 +207,7 @@ public: c2_status_t err = mapInternal(mapSize, mapOffset, alignmentBytes, prot, flags, &(map.addr), addr); if (map.addr) { std::lock_guard<std::mutex> guard(mMutexMappings); mMappings.push_back(map); } return err; Loading @@ -217,6 +218,8 @@ public: ALOGD("tried to unmap unmapped buffer"); return C2_NOT_FOUND; } { // Scope for the lock_guard of mMutexMappings. std::lock_guard<std::mutex> guard(mMutexMappings); for (auto it = mMappings.begin(); it != mMappings.end(); ++it) { if (addr != (uint8_t *)it->addr + it->alignmentBytes || size + it->alignmentBytes != it->size) { Loading @@ -231,9 +234,11 @@ public: *fence = C2Fence(); // not using fences } (void)mMappings.erase(it); ALOGV("successfully unmapped: addr=%p size=%zu fd=%d", addr, size, mHandle.bufferFd()); ALOGV("successfully unmapped: addr=%p size=%zu fd=%d", addr, size, mHandle.bufferFd()); return C2_OK; } } ALOGD("unmap failed to find specified map"); return C2_BAD_VALUE; } Loading @@ -241,6 +246,7 @@ public: virtual ~Impl() { if (!mMappings.empty()) { ALOGD("Dangling mappings!"); std::lock_guard<std::mutex> guard(mMutexMappings); for (const Mapping &map : mMappings) { (void)munmap(map.addr, map.size); } Loading Loading @@ -320,6 +326,7 @@ protected: size_t size; }; std::list<Mapping> mMappings; std::mutex mMutexMappings; }; class C2AllocationIon::ImplV2 : public C2AllocationIon::Impl { Loading Loading
media/codec2/vndk/C2AllocatorIon.cpp +22 −15 Original line number Diff line number Diff line Loading @@ -207,6 +207,7 @@ public: c2_status_t err = mapInternal(mapSize, mapOffset, alignmentBytes, prot, flags, &(map.addr), addr); if (map.addr) { std::lock_guard<std::mutex> guard(mMutexMappings); mMappings.push_back(map); } return err; Loading @@ -217,6 +218,8 @@ public: ALOGD("tried to unmap unmapped buffer"); return C2_NOT_FOUND; } { // Scope for the lock_guard of mMutexMappings. std::lock_guard<std::mutex> guard(mMutexMappings); for (auto it = mMappings.begin(); it != mMappings.end(); ++it) { if (addr != (uint8_t *)it->addr + it->alignmentBytes || size + it->alignmentBytes != it->size) { Loading @@ -231,9 +234,11 @@ public: *fence = C2Fence(); // not using fences } (void)mMappings.erase(it); ALOGV("successfully unmapped: addr=%p size=%zu fd=%d", addr, size, mHandle.bufferFd()); ALOGV("successfully unmapped: addr=%p size=%zu fd=%d", addr, size, mHandle.bufferFd()); return C2_OK; } } ALOGD("unmap failed to find specified map"); return C2_BAD_VALUE; } Loading @@ -241,6 +246,7 @@ public: virtual ~Impl() { if (!mMappings.empty()) { ALOGD("Dangling mappings!"); std::lock_guard<std::mutex> guard(mMutexMappings); for (const Mapping &map : mMappings) { (void)munmap(map.addr, map.size); } Loading Loading @@ -320,6 +326,7 @@ protected: size_t size; }; std::list<Mapping> mMappings; std::mutex mMutexMappings; }; class C2AllocationIon::ImplV2 : public C2AllocationIon::Impl { Loading