From dce54a1492c410ad0d93253b341fb33305337505 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 10 Mar 2014 12:19:46 -0700 Subject: audio policy: add option to use new policy manager Add build option USE_LEGACY_AUDIO_POLICY to use either new audio policy manager in local AudioPolicyManager.cpp or the legacy AudioPolicyManagerBase.cpp via the policy HAL. New features will be implemented only by the new audio policy manager. Platform customiization will be by config file or new policy HAL. AudioPolicyClientImplLegacy.cpp copied from AudioPolicyClientImpl.cpp AudioPolicyInterfaceImplLegacy.cpp copied from AudioPolicyInterfaceImpl.cpp New implementations of AudioPolicyInterface and AudioPolicyClient talking directly to AudioPolicyManager. Change-Id: I7a320883a1de13de2c9295343e996addf2f3c154 --- services/audiopolicy/AudioPolicyService.cpp | 30 ++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'services/audiopolicy/AudioPolicyService.cpp') diff --git a/services/audiopolicy/AudioPolicyService.cpp b/services/audiopolicy/AudioPolicyService.cpp index 49145a5..037faa7 100644 --- a/services/audiopolicy/AudioPolicyService.cpp +++ b/services/audiopolicy/AudioPolicyService.cpp @@ -60,7 +60,8 @@ namespace { // ---------------------------------------------------------------------------- AudioPolicyService::AudioPolicyService() - : BnAudioPolicyService(), mpAudioPolicyDev(NULL), mpAudioPolicy(NULL) + : BnAudioPolicyService(), mpAudioPolicyDev(NULL), mpAudioPolicy(NULL), + mAudioPolicyManager(NULL), mAudioPolicyClient(NULL) { char value[PROPERTY_VALUE_MAX]; const struct hw_module_t *module; @@ -75,12 +76,15 @@ AudioPolicyService::AudioPolicyService() mAudioCommandThread = new AudioCommandThread(String8("ApmAudio"), this); // start output activity command thread mOutputCommandThread = new AudioCommandThread(String8("ApmOutput"), this); + +#ifdef USE_LEGACY_AUDIO_POLICY + ALOGI("AudioPolicyService CSTOR in legacy mode"); + /* instantiate the audio policy manager */ rc = hw_get_module(AUDIO_POLICY_HARDWARE_MODULE_ID, &module); if (rc) { return; } - rc = audio_policy_dev_open(module, &mpAudioPolicyDev); ALOGE_IF(rc, "couldn't open audio policy device (%s)", strerror(-rc)); if (rc) { @@ -99,8 +103,13 @@ AudioPolicyService::AudioPolicyService() if (rc) { return; } - ALOGI("Loaded audio policy from %s (%s)", module->name, module->id); +#else + ALOGI("AudioPolicyService CSTOR in new mode"); + + mAudioPolicyClient = new AudioPolicyClient(this); + mAudioPolicyManager = new AudioPolicyManager(mAudioPolicyClient); +#endif // load audio pre processing modules if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) { @@ -130,12 +139,17 @@ AudioPolicyService::~AudioPolicyService() } mInputs.clear(); +#ifdef USE_LEGACY_AUDIO_POLICY if (mpAudioPolicy != NULL && mpAudioPolicyDev != NULL) { mpAudioPolicyDev->destroy_audio_policy(mpAudioPolicyDev, mpAudioPolicy); } if (mpAudioPolicyDev != NULL) { audio_policy_dev_close(mpAudioPolicyDev); } +#else + delete mAudioPolicyManager; + delete mAudioPolicyClient; +#endif } @@ -163,7 +177,11 @@ status_t AudioPolicyService::dumpInternals(int fd) char buffer[SIZE]; String8 result; +#ifdef USE_LEGACY_AUDIO_POLICY snprintf(buffer, SIZE, "PolicyManager Interface: %p\n", mpAudioPolicy); +#else + snprintf(buffer, SIZE, "AudioPolicyManager: %p\n", mAudioPolicyManager); +#endif result.append(buffer); snprintf(buffer, SIZE, "Command Thread: %p\n", mAudioCommandThread.get()); result.append(buffer); @@ -193,9 +211,15 @@ status_t AudioPolicyService::dump(int fd, const Vector& args __unused) mTonePlaybackThread->dump(fd); } +#ifdef USE_LEGACY_AUDIO_POLICY if (mpAudioPolicy) { mpAudioPolicy->dump(mpAudioPolicy, fd); } +#else + if (mAudioPolicyManager) { + mAudioPolicyManager->dump(fd); + } +#endif if (locked) mLock.unlock(); } -- cgit v1.1