diff --git a/libs/audioflinger/Android.mk b/libs/audioflinger/Android.mk index 7ed6a5fb7fe2d..ec9e332bb97ae 100644 --- a/libs/audioflinger/Android.mk +++ b/libs/audioflinger/Android.mk @@ -54,6 +54,12 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libmedia +ifeq ($(TARGET_SIMULATOR),true) + LOCAL_LDLIBS += -ldl +else + LOCAL_SHARED_LIBRARIES += libdl +endif + LOCAL_MODULE:= libaudiopolicygeneric ifeq ($(BOARD_HAVE_BLUETOOTH),true) @@ -64,8 +70,6 @@ ifeq ($(AUDIO_POLICY_TEST),true) LOCAL_CFLAGS += -DAUDIO_POLICY_TEST endif -LOCAL_PRELINK_MODULE := false - include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -83,7 +87,9 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libbinder \ libmedia \ - libhardware_legacy + libhardware_legacy \ + libaudiopolicygeneric \ + libaudiopolicy ifeq ($(strip $(BOARD_USES_GENERIC_AUDIO)),true) LOCAL_STATIC_LIBRARIES += libaudiointerface diff --git a/libs/audioflinger/AudioPolicyManagerGeneric.cpp b/libs/audioflinger/AudioPolicyManagerGeneric.cpp index cf9ab88cb1004..4b31815cdfbee 100644 --- a/libs/audioflinger/AudioPolicyManagerGeneric.cpp +++ b/libs/audioflinger/AudioPolicyManagerGeneric.cpp @@ -460,17 +460,6 @@ status_t AudioPolicyManagerGeneric::getStreamVolumeIndex(AudioSystem::stream_typ // --- class factory - -extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface) -{ - return new AudioPolicyManagerGeneric(clientInterface); -} - -extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface) -{ - delete interface; -} - AudioPolicyManagerGeneric::AudioPolicyManagerGeneric(AudioPolicyClientInterface *clientInterface) : #ifdef AUDIO_POLICY_TEST diff --git a/libs/audioflinger/AudioPolicyService.cpp b/libs/audioflinger/AudioPolicyService.cpp index 4810a44e9e612..7f6c4ed4eef86 100644 --- a/libs/audioflinger/AudioPolicyService.cpp +++ b/libs/audioflinger/AudioPolicyService.cpp @@ -23,6 +23,7 @@ #include #include #include "AudioPolicyService.h" +#include "AudioPolicyManagerGeneric.h" #include #include @@ -35,9 +36,6 @@ namespace android { -const char *AudioPolicyService::sAudioPolicyLibrary = "/system/lib/libaudiopolicy.so"; -const char *AudioPolicyService::sAudioPolicyGenericLibrary = "/system/lib/libaudiopolicygeneric.so"; - static bool checkPermission() { #ifndef HAVE_ANDROID_OS return true; @@ -51,47 +49,29 @@ static bool checkPermission() { // ---------------------------------------------------------------------------- AudioPolicyService::AudioPolicyService() - : BnAudioPolicyService() , mpPolicyManager(NULL), mpPolicyManagerLibHandle(NULL) + : BnAudioPolicyService() , mpPolicyManager(NULL) { - const char *audioPolicyLibrary; char value[PROPERTY_VALUE_MAX]; -#if (defined GENERIC_AUDIO) || (defined AUDIO_POLICY_TEST) - audioPolicyLibrary = sAudioPolicyGenericLibrary; - LOGV("build for GENERIC_AUDIO - using generic audio policy"); -#else - // if running in emulation - use the emulator driver - if (property_get("ro.kernel.qemu", value, 0)) { - LOGV("Running in emulation - using generic audio policy"); - audioPolicyLibrary = sAudioPolicyGenericLibrary; - } - else { - LOGV("Using hardware specific audio policy"); - audioPolicyLibrary = sAudioPolicyLibrary; - } -#endif - - - mpPolicyManagerLibHandle = dlopen(audioPolicyLibrary, RTLD_NOW | RTLD_LOCAL); - if (mpPolicyManagerLibHandle == NULL) { - LOGW("Could not load libaudio policy library"); - return; - } - - AudioPolicyInterface *(*createManager)(AudioPolicyClientInterface *) = - reinterpret_cast(dlsym(mpPolicyManagerLibHandle, "createAudioPolicyManager")); - - if (createManager == NULL ) { - LOGW("Could not get createAudioPolicyManager method"); - return; - } - // start tone playback thread mTonePlaybacThread = new AudioCommandThread(); // start audio commands thread mAudioCommandThread = new AudioCommandThread(); - mpPolicyManager = (*createManager)(this); +#if (defined GENERIC_AUDIO) || (defined AUDIO_POLICY_TEST) + mpPolicyManager = new AudioPolicyManagerGeneric(this); + LOGV("build for GENERIC_AUDIO - using generic audio policy"); +#else + // if running in emulation - use the emulator driver + if (property_get("ro.kernel.qemu", value, 0)) { + LOGV("Running in emulation - using generic audio policy"); + mpPolicyManager = new AudioPolicyManagerGeneric(this); + } + else { + LOGV("Using hardware specific audio policy"); + mpPolicyManager = createAudioPolicyManager(this); + } +#endif // load properties property_get("ro.camera.sound.forced", value, "0"); @@ -106,14 +86,7 @@ AudioPolicyService::~AudioPolicyService() mAudioCommandThread.clear(); if (mpPolicyManager) { - void(*destroyManager)(AudioPolicyInterface *) = - reinterpret_cast(dlsym(mpPolicyManagerLibHandle, "destroyAudioPolicyManager")); - - if (destroyManager == NULL ) { - LOGW("Could not get destroyAudioPolicyManager method"); - return; - } - (*destroyManager)(mpPolicyManager); + delete mpPolicyManager; } } diff --git a/libs/audioflinger/AudioPolicyService.h b/libs/audioflinger/AudioPolicyService.h index 47173dd7d6b3c..1c469751ea449 100644 --- a/libs/audioflinger/AudioPolicyService.h +++ b/libs/audioflinger/AudioPolicyService.h @@ -109,8 +109,6 @@ private: AudioPolicyService(); virtual ~AudioPolicyService(); - static const char *sAudioPolicyLibrary; - static const char *sAudioPolicyGenericLibrary; // Thread used for tone playback and to send audio config commands to audio flinger // For tone playback, using a separate thread is necessary to avoid deadlock with mLock because startTone() // and stopTone() are normally called with mLock locked and requesting a tone start or stop will cause @@ -185,7 +183,6 @@ private: AudioPolicyInterface* mpPolicyManager; // the platform specific policy manager sp mAudioCommandThread; // audio commands thread sp mTonePlaybacThread; // tone playback thread - void *mpPolicyManagerLibHandle; }; }; // namespace android