Skip to content

Commit

Permalink
audio policy: use factory to create audio policy manager
Browse files Browse the repository at this point in the history
Use the class factory to create the audio policy mamager
instead of AudioPolicyManager class constructor and
use a pointer to an AudioPolicyInterface.

Change-Id: Ibb5a8eee5d597db67cf13f279c909181cfee9949
  • Loading branch information
Eric Laurent committed Jun 10, 2014
1 parent 7e45ef9 commit f269b8e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CleanSpec.mk
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libaudiopolicy
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/libaudiopolicy.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libaudiopolicyservice_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libaudiopolicymanager_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/libaudiopolicyservice.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/libaudiopolicymanager.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libaudiopolicyservice_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libaudiopolicymanager_intermediates)

# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
Expand Down
16 changes: 15 additions & 1 deletion services/audiopolicy/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ LOCAL_CFLAGS += -fvisibility=hidden

include $(BUILD_SHARED_LIBRARY)


ifneq ($(USE_LEGACY_AUDIO_POLICY), 1)
ifneq ($(USE_CUSTOM_AUDIO_POLICY), 1)

include $(CLEAR_VARS)

Expand All @@ -62,6 +62,20 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_STATIC_LIBRARIES := \
libmedia_helper

LOCAL_MODULE:= libaudiopolicymanagerdefault

include $(BUILD_SHARED_LIBRARY)

ifneq ($(USE_CUSTOM_AUDIO_POLICY), 1)

include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
AudioPolicyFactory.cpp

LOCAL_SHARED_LIBRARIES := \
libaudiopolicymanagerdefault

LOCAL_MODULE:= libaudiopolicymanager

include $(BUILD_SHARED_LIBRARY)
Expand Down
32 changes: 32 additions & 0 deletions services/audiopolicy/AudioPolicyFactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "AudioPolicyManager.h"

namespace android {

extern "C" AudioPolicyInterface* createAudioPolicyManager(
AudioPolicyClientInterface *clientInterface)
{
return new AudioPolicyManager(clientInterface);
}

extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface)
{
delete interface;
}

}; // namespace android
4 changes: 2 additions & 2 deletions services/audiopolicy/AudioPolicyService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ AudioPolicyService::AudioPolicyService()
ALOGI("AudioPolicyService CSTOR in new mode");

mAudioPolicyClient = new AudioPolicyClient(this);
mAudioPolicyManager = new AudioPolicyManager(mAudioPolicyClient);
mAudioPolicyManager = createAudioPolicyManager(mAudioPolicyClient);
#endif

// load audio pre processing modules
Expand Down Expand Up @@ -145,7 +145,7 @@ AudioPolicyService::~AudioPolicyService()
audio_policy_dev_close(mpAudioPolicyDev);
}
#else
delete mAudioPolicyManager;
destroyAudioPolicyManager(mAudioPolicyManager);
delete mAudioPolicyClient;
#endif

Expand Down
2 changes: 1 addition & 1 deletion services/audiopolicy/AudioPolicyService.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class AudioPolicyService :
sp<AudioCommandThread> mOutputCommandThread; // process stop and release output
struct audio_policy_device *mpAudioPolicyDev;
struct audio_policy *mpAudioPolicy;
AudioPolicyManager *mAudioPolicyManager;
AudioPolicyInterface *mAudioPolicyManager;
AudioPolicyClient *mAudioPolicyClient;

KeyedVector< audio_source_t, InputSourceDesc* > mInputSources;
Expand Down

0 comments on commit f269b8e

Please sign in to comment.