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

Commit 616d82dd authored by Kevin Rocard's avatar Kevin Rocard Committed by android-build-merger
Browse files

Aaudio: Implement app shareable flag instead of -size hack

am: 51cdd133

Change-Id: Ifbf493566c45e003ddba23996c8722f3f4c74d4f
parents d0331964 51cdd133
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -163,6 +163,22 @@ Return<void> StreamMmap<T>::createMmapBuffer(int32_t minSizeFrames, size_t frame
        if (retval == Result::OK) {
            hidlHandle = native_handle_create(1, 0);
            hidlHandle->data[0] = halInfo.shared_memory_fd;

            // Negative buffer size frame is a legacy hack to indicate that the buffer
            // is shareable to applications before the relevant flag was introduced
            bool applicationShareable =
                halInfo.flags & AUDIO_MMAP_APPLICATION_SHAREABLE || halInfo.buffer_size_frames < 0;
            halInfo.buffer_size_frames = abs(halInfo.buffer_size_frames);
#ifdef AUDIO_HAL_VERSION_2_0
            if (applicationShareable) {
                halInfo.buffer_size_frames *= -1;
            }
#else
            info.flags =
                halInfo.flags | (applicationShareable ? MmapBufferFlag::APPLICATION_SHAREABLE
                                                      : MmapBufferFlag::NONE);
#endif

            info.sharedMemory =
                hidl_memory("audio_buffer", hidlHandle, frameSize * halInfo.buffer_size_frames);
            info.bufferSizeFrames = halInfo.buffer_size_frames;