OSDN Git Service

audioserver: enable AAudioService for MR1
authorPhil Burk <philburk@google.com>
Fri, 29 Sep 2017 22:06:40 +0000 (15:06 -0700)
committerPhil Burk <philburk@google.com>
Sun, 1 Oct 2017 18:55:50 +0000 (11:55 -0700)
Another CL in OC-DEV may have turned it off.
This was added to resolve merge conflicts and to
only enable AAudioService when supported by the vendor.

Bug: 65280854
Bug: 65262790
Test: Enter  adb shell setprop aaudio.mmap_policy 1
Test: Enter  adb shell killall audioserver
Test: Enter  adb shell dumpsys media.aaudio
Test: It should print "Can't find service: media.aaudio".
Test: Enter  adb shell setprop aaudio.mmap_policy 2
Test: Enter  adb shell killall audioserver
Test: Enter  adb shell dumpsys media.aaudio
Test: It should print a short dump because the service is running.

Change-Id: Ic68d136c99c16134aa704495311ab25285fd76a9

media/audioserver/main_audioserver.cpp

index 34c629b..474ef97 100644 (file)
 #include <hwbinder/ProcessState.h>
 
 // from LOCAL_C_INCLUDES
+#include "aaudio/AAudioTesting.h"
 #include "AudioFlinger.h"
 #include "AudioPolicyService.h"
 #include "AAudioService.h"
+#include "utility/AAudioUtilities.h"
 #include "MediaLogService.h"
 #include "SoundTriggerHwService.h"
 
@@ -131,7 +133,16 @@ int main(int argc __unused, char **argv)
         ALOGI("ServiceManager: %p", sm.get());
         AudioFlinger::instantiate();
         AudioPolicyService::instantiate();
-        AAudioService::instantiate();
+
+        // AAudioService should only be used in OC-MR1 and later.
+        // And only enable the AAudioService if the system MMAP policy explicitly allows it.
+        // This prevents a client from misusing AAudioService when it is not supported.
+        aaudio_policy_t mmapPolicy = property_get_int32(AAUDIO_PROP_MMAP_POLICY,
+                                                        AAUDIO_POLICY_NEVER);
+        if (mmapPolicy == AAUDIO_POLICY_AUTO || mmapPolicy == AAUDIO_POLICY_ALWAYS) {
+            AAudioService::instantiate();
+        }
+
         SoundTriggerHwService::instantiate();
         ProcessState::self()->startThreadPool();