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

Commit 9560b4cf authored by Kevin Rocard's avatar Kevin Rocard Committed by android-build-merger
Browse files

Merge "Aaudio: Implement app shareable flag instead of -size hack"

am: 51d361e7

Change-Id: Iad460714000b179e96f984c2c48e70831cf15405
parents 88ab23b3 51d361e7
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -178,6 +178,13 @@ status_t StreamHalHidl::createMmapBuffer(int32_t minSizeFrames,
                    if (handle->numFds > 0) {
                        info->shared_memory_fd = handle->data[0];
                        info->buffer_size_frames = hidlInfo.bufferSizeFrames;
                        // Negative buffer size frame was a hack in O and P to
                        // indicate that the buffer is shareable to applications
                        if (info->buffer_size_frames < 0) {
                            info->buffer_size_frames *= -1;
                            info->flags = audio_mmap_buffer_flag(
                                    info->flags | AUDIO_MMAP_APPLICATION_SHAREABLE);
                        }
                        info->burst_size_frames = hidlInfo.burstSizeFrames;
                        // info->shared_memory_address is not needed in HIDL context
                        info->shared_memory_address = NULL;
+8 −0
Original line number Diff line number Diff line
@@ -188,7 +188,15 @@ status_t StreamHalHidl::createMmapBuffer(int32_t minSizeFrames,
                    const native_handle *handle = hidlInfo.sharedMemory.handle();
                    if (handle->numFds > 0) {
                        info->shared_memory_fd = handle->data[0];
                        info->flags = audio_mmap_buffer_flag(hidlInfo.flags);
                        info->buffer_size_frames = hidlInfo.bufferSizeFrames;
                        // Negative buffer size frame was a hack in O and P to
                        // indicate that the buffer is shareable to applications
                        if (info->buffer_size_frames < 0) {
                            info->buffer_size_frames *= -1;
                            info->flags = audio_mmap_buffer_flag(
                                    info->flags | AUDIO_MMAP_APPLICATION_SHAREABLE);
                        }
                        info->burst_size_frames = hidlInfo.burstSizeFrames;
                        // info->shared_memory_address is not needed in HIDL context
                        info->shared_memory_address = NULL;
+4 −8
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ aaudio_result_t AAudioServiceEndpointMMAP::open(const aaudio::AAudioStreamReques
        minSizeFrames = AAUDIO_BUFFER_CAPACITY_MIN;
    }
    status = mMmapStream->createMmapBuffer(minSizeFrames, &mMmapBufferinfo);
    bool isBufferShareable = mMmapBufferinfo.flags & AUDIO_MMAP_APPLICATION_SHAREABLE;
    if (status != OK) {
        ALOGE("%s() - createMmapBuffer() failed with status %d %s",
              __func__, status, strerror(-status));
@@ -198,18 +199,13 @@ aaudio_result_t AAudioServiceEndpointMMAP::open(const aaudio::AAudioStreamReques
        ALOGD("%s() createMmapBuffer() returned = %d, buffer_size = %d, burst_size %d"
                      ", Sharable FD: %s",
              __func__, status,
              abs(mMmapBufferinfo.buffer_size_frames),
              mMmapBufferinfo.buffer_size_frames,
              mMmapBufferinfo.burst_size_frames,
              mMmapBufferinfo.buffer_size_frames < 0 ? "Yes" : "No");
              isBufferShareable ? "Yes" : "No");
    }

    setBufferCapacity(mMmapBufferinfo.buffer_size_frames);
    // The audio HAL indicates if the shared memory fd can be shared outside of audioserver
    // by returning a negative buffer size
    if (getBufferCapacity() < 0) {
        // Exclusive mode can be used by client or service.
        setBufferCapacity(-getBufferCapacity());
    } else {
    if (!isBufferShareable) {
        // Exclusive mode can only be used by the service because the FD cannot be shared.
        uid_t audioServiceUid = getuid();
        if ((mMmapClient.clientUid != audioServiceUid) &&