Merge changes from topic "share-buffer"
am: 54c3572e99

Change-Id: I4a8bb74e3dee81cdd0fc478c49acd0771467f227
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Stream.h b/audio/core/all-versions/default/include/core/all-versions/default/Stream.h
index 375759d..7cf12dd 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/Stream.h
+++ b/audio/core/all-versions/default/include/core/all-versions/default/Stream.h
@@ -169,6 +169,8 @@
             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 @@
                 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;
         }