Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45d4d302 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

hidl_memory no longer owns passed-in handles.

So clean them up when done.

Bug: 33812533
Test: mma
Change-Id: Ic2fdfa703547a210b9915288d5a77dc8e329a1c6
parent c2566d26
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ Return<void> StreamMmap<T>::createMmapBuffer(int32_t minSizeFrames, size_t frame
                                             IStream::createMmapBuffer_cb _hidl_cb) {
    Result retval(Result::NOT_SUPPORTED);
    MmapBufferInfo info;
    native_handle_t* hidlHandle = nullptr;

    if (mStream->create_mmap_buffer != NULL) {
        struct audio_mmap_buffer_info halInfo;
@@ -134,7 +135,7 @@ Return<void> StreamMmap<T>::createMmapBuffer(int32_t minSizeFrames, size_t frame
                "create_mmap_buffer",
                mStream->create_mmap_buffer(mStream, minSizeFrames, &halInfo));
        if (retval == Result::OK) {
            native_handle_t* hidlHandle = native_handle_create(1, 0);
            hidlHandle = native_handle_create(1, 0);
            hidlHandle->data[0] = halInfo.shared_memory_fd;
            info.sharedMemory = hidl_memory("audio_buffer", hidlHandle,
                                            frameSize *halInfo.buffer_size_frames);
@@ -143,6 +144,10 @@ Return<void> StreamMmap<T>::createMmapBuffer(int32_t minSizeFrames, size_t frame
        }
    }
    _hidl_cb(retval, info);
    if (hidlHandle != nullptr) {
        native_handle_close(hidlHandle);
        native_handle_delete(hidlHandle);
    }
    return Void();
}