diff options
author | Martijn Coenen <maco@google.com> | 2017-01-02 15:20:38 +0100 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2017-01-05 08:58:11 +0100 |
commit | d272cb9e881c0aa23e4964f101131ab68affd85d (patch) | |
tree | 63227aa465afcd18aadf115dd332d9ae14075a25 /transport/memory | |
parent | 7e6404dd880b1f25c932f264c0ba2e00e79c536e (diff) | |
download | libhidl-d272cb9e881c0aa23e4964f101131ab68affd85d.tar.gz |
Callback elision for HIDL interfaces.
Test: mma, hidl_test
Bug: 31380743
Change-Id: If5f0dc0279e717dafaf416776be89cc854c6f856
Diffstat (limited to 'transport/memory')
-rw-r--r-- | transport/memory/1.0/default/AshmemMapper.cpp | 13 | ||||
-rw-r--r-- | transport/memory/1.0/default/AshmemMapper.h | 3 |
2 files changed, 6 insertions, 10 deletions
diff --git a/transport/memory/1.0/default/AshmemMapper.cpp b/transport/memory/1.0/default/AshmemMapper.cpp index 37eb8af..bef4767 100644 --- a/transport/memory/1.0/default/AshmemMapper.cpp +++ b/transport/memory/1.0/default/AshmemMapper.cpp @@ -27,10 +27,9 @@ namespace V1_0 { namespace implementation { // Methods from ::android::hidl::memory::V1_0::IMapper follow. -Return<void> AshmemMapper::mapMemory(const hidl_memory& mem, mapMemory_cb _hidl_cb) { +Return<sp<IMemory>> AshmemMapper::mapMemory(const hidl_memory& mem) { if (mem.handle()->numFds == 0) { - _hidl_cb(nullptr); - return Void(); + return nullptr; } int fd = mem.handle()->data[0]; @@ -38,14 +37,10 @@ Return<void> AshmemMapper::mapMemory(const hidl_memory& mem, mapMemory_cb _hidl_ if (data == MAP_FAILED) { // mmap never maps at address zero without MAP_FIXED, so we can avoid // exposing clients to MAP_FAILED. - _hidl_cb(nullptr); - return Void(); + return nullptr; } - sp<IMemory> memory = new AshmemMemory(mem, data); - - _hidl_cb(memory); - return Void(); + return new AshmemMemory(mem, data); } } // namespace implementation diff --git a/transport/memory/1.0/default/AshmemMapper.h b/transport/memory/1.0/default/AshmemMapper.h index c6cfc37..3d3a7e1 100644 --- a/transport/memory/1.0/default/AshmemMapper.h +++ b/transport/memory/1.0/default/AshmemMapper.h @@ -28,6 +28,7 @@ namespace V1_0 { namespace implementation { using ::android::hidl::memory::V1_0::IMapper; +using ::android::hidl::memory::V1_0::IMemory; using ::android::hardware::hidl_array; using ::android::hardware::hidl_memory; using ::android::hardware::hidl_string; @@ -38,7 +39,7 @@ using ::android::sp; struct AshmemMapper : public IMapper { // Methods from ::android::hidl::memory::V1_0::IMapper follow. - Return<void> mapMemory(const hidl_memory& mem, mapMemory_cb _hidl_cb) override; + Return<sp<IMemory>> mapMemory(const hidl_memory& mem) override; }; |