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

Commit 86910f0f authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio default HAL: hidl_memory size must be positive



hidl_memory size is not used on the framework side but is checked by the
hidl framework to be a sensible value.
Due to a hack in O and P, the value can be negative, this leads to
errors in HIDL.

This patch make sure the hidl_memory size is always positive and thus
not affected by the hack.

Test: adb shell data/nativetest64/write_sine/write_sine -pl -m3 -x
Bug: 38118159
Change-Id: Ie53c46c558e8042d74ee32b55219195da82e4bcc
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 51cdd133
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -169,6 +169,8 @@ Return<void> StreamMmap<T>::createMmapBuffer(int32_t minSizeFrames, size_t frame
            bool applicationShareable =
                halInfo.flags & AUDIO_MMAP_APPLICATION_SHAREABLE || halInfo.buffer_size_frames < 0;
            halInfo.buffer_size_frames = abs(halInfo.buffer_size_frames);
            info.sharedMemory =  // hidl_memory size must always be positive
                hidl_memory("audio_buffer", hidlHandle, frameSize * halInfo.buffer_size_frames);
#ifdef AUDIO_HAL_VERSION_2_0
            if (applicationShareable) {
                halInfo.buffer_size_frames *= -1;
@@ -178,9 +180,6 @@ Return<void> StreamMmap<T>::createMmapBuffer(int32_t minSizeFrames, size_t frame
                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;
            info.burstSizeFrames = halInfo.burst_size_frames;
        }