From: Phil Burk Date: Fri, 29 Sep 2017 22:06:40 +0000 (-0700) Subject: audioserver: enable AAudioService for MR1 X-Git-Tag: android-x86-8.1-r1~32^2~2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5b38eb309cebf994402f0a2461dae763bcd6b81a;p=android-x86%2Fframeworks-av.git audioserver: enable AAudioService for MR1 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 --- diff --git a/media/audioserver/main_audioserver.cpp b/media/audioserver/main_audioserver.cpp index 34c629b3b7..474ef97aa2 100644 --- a/media/audioserver/main_audioserver.cpp +++ b/media/audioserver/main_audioserver.cpp @@ -32,9 +32,11 @@ #include // 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();