Merge changes from topic "share-buffer"

* changes:
  Audio default HAL: hidl_memory size must be positive
  Aaudio: Implement app shareable flag instead of -size hack
This commit is contained in:
Treehugger Robot 2018-08-17 23:03:44 +00:00 committed by Gerrit Code Review
commit 54c3572e99

View file

@ -163,8 +163,23 @@ 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;
info.sharedMemory =
// 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);
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;
}
#else
info.flags =
halInfo.flags | (applicationShareable ? MmapBufferFlag::APPLICATION_SHAREABLE
: MmapBufferFlag::NONE);
#endif
info.bufferSizeFrames = halInfo.buffer_size_frames;
info.burstSizeFrames = halInfo.burst_size_frames;
}